public class RemoteFrameworkImpl extends Object implements RemoteFramework
RemoteFramework interface by instantiating a local Framework,
exporting it via an RMI registry and delegating all remote calls to the local framework.RMI_NAME_KEY, RMI_PORT_KEY, TIMEOUT_KEY| Constructor and Description |
|---|
RemoteFrameworkImpl(Map<String,String> frameworkProperties) |
| Modifier and Type | Method and Description |
|---|---|
void |
callService(String filter,
String methodName)
Looks up a service matching the given filter and invokes a service method with the given
name.
|
org.osgi.framework.launch.FrameworkFactory |
findFrameworkFactory() |
int |
getBundleState(long bundleId)
Returns the state of the bundle with the given ID.
|
RemoteServiceReference[] |
getServiceReferences(String filter)
Fetch an array of
RemoteServiceReference to interact with them, this is a snapshot of
the current state and must be recalled to update |
RemoteServiceReference[] |
getServiceReferences(String filter,
long timeout,
TimeUnit timeUnit)
Fetch an array of
RemoteServiceReference to interact with them, this is a snapshot of
the current state and must be recalled to update |
void |
init()
Initializes the framework.
|
long |
installBundle(String bundleUrl)
Installs a bundle remotely.
|
long |
installBundle(String bundleUrl,
boolean start,
int startLevel)
Installs a bundle remotely, sets its start level and optionally starts it.
|
long |
installBundle(String bundleLocation,
byte[] bundleData)
Installs a bundle remotely, given the bundle content.
|
long |
installBundle(String bundleLocation,
byte[] bundleData,
boolean start,
int startLevel)
Installs a bundle remotely, given the bundle content, autostart it if requested and set its
startlevel
|
Object |
invokeMethodOnService(RemoteServiceReference reference,
String methodName,
Class<?>[] parameterTypes,
Object[] args)
Invokes a method on this reference in the remote framework
|
Object |
invokeMethodOnService(RemoteServiceReference reference,
String methodName,
Object... args)
Invokes a method on this reference in the remote framework
|
static void |
main(String[] args) |
void |
setBundleStartLevel(long bundleId,
int startLevel)
Sets bundle start level.
|
void |
setFrameworkStartLevel(int startLevel)
Sets the framework startlevel.
|
boolean |
setFrameworkStartLevel(int startLevel,
long timeout)
Sets the framework startlevel and waits for at most the given timeout (in ms) for the
startlevel to be reached.
|
void |
start()
Starts the framework.
|
void |
startBundle(long bundleId)
Starts a bundle.
|
void |
stop()
Stops the framework.
|
void |
stopBundle(long bundleId)
Stops a bundle.
|
void |
uninstallBundle(long id) |
void |
waitForState(long bundleId,
int state,
long timeoutInMillis)
Waits for a bundle to be in a certain state and returns.
|
public RemoteFrameworkImpl(Map<String,String> frameworkProperties) throws RemoteException, AlreadyBoundException, org.osgi.framework.BundleException
RemoteExceptionAlreadyBoundExceptionorg.osgi.framework.BundleExceptionpublic void init()
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworkinit in interface RemoteFrameworkRemoteExceptionorg.osgi.framework.BundleExceptionFramework#init}public void start()
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworkstart in interface RemoteFrameworkRemoteExceptionorg.osgi.framework.BundleExceptionFramework#start}public void stop()
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworkstop in interface RemoteFrameworkRemoteExceptionorg.osgi.framework.BundleExceptionFramework#start}public long installBundle(String bundleUrl) throws RemoteException, org.osgi.framework.BundleException
RemoteFrameworkinstallBundle in interface RemoteFrameworkbundleUrl - url of the bundle to be installed. The url must be accessible from the
remote framework.RemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - Re-thrown from installing the bundlepublic long installBundle(String bundleUrl, boolean start, int startLevel) throws RemoteException, org.osgi.framework.BundleException
RemoteFrameworkinstallBundle in interface RemoteFrameworkbundleUrl - url of the bundle to be installed. The url must be accessible from the
remote framework.start - indicates whether the bundle will be startedstartLevel - start level for this bundleRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - Re-thrown from installing the bundlepublic long installBundle(String bundleLocation, byte[] bundleData, boolean start, int startLevel) throws RemoteException, org.osgi.framework.BundleException
RemoteFrameworkinstallBundle in interface RemoteFrameworkbundleLocation - The location identifier of the bundle to installbundleData - bundle content as a byte arraystart - indicates whether the bundle will be startedstartLevel - start level for this bundleRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - Re-thrown from installing the bundlepublic long installBundle(String bundleLocation, byte[] bundleData) throws RemoteException, org.osgi.framework.BundleException
RemoteFrameworkinstallBundle in interface RemoteFrameworkbundleLocation - The location identifier of the bundle to installbundleData - bundle content as a byte arrayRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - Re-thrown from installing the bundlepublic void startBundle(long bundleId)
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworkstartBundle in interface RemoteFrameworkbundleId - id of the bundle to be startedRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - Re-thrown from starting the bundlepublic void stopBundle(long bundleId)
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworkstopBundle in interface RemoteFrameworkbundleId - id of the bundle to be stoppedRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - Re-thrown from stopping the bundlepublic void setBundleStartLevel(long bundleId,
int startLevel)
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworksetBundleStartLevel in interface RemoteFrameworkbundleId - id of the bundle to which the start level should be setstartLevel - bundle start levelRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - If bundle level cannot be setpublic void uninstallBundle(long id)
throws RemoteException,
org.osgi.framework.BundleException
uninstallBundle in interface RemoteFrameworkid - of bundle to uninstallRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - If bundle cannot be foundpublic org.osgi.framework.launch.FrameworkFactory findFrameworkFactory()
public void callService(String filter, String methodName) throws RemoteException, org.osgi.framework.BundleException
RemoteFrameworkcallService in interface RemoteFrameworkfilter - LDAP service filtermethodName - service method nameRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - If bundle cannot be foundpublic void setFrameworkStartLevel(int startLevel)
throws RemoteException
RemoteFrameworksetFrameworkStartLevel in interface RemoteFrameworkRemoteExceptionStartLevel#setStartLevel(int)}public boolean setFrameworkStartLevel(int startLevel,
long timeout)
throws RemoteException
RemoteFrameworksetFrameworkStartLevel in interface RemoteFrameworkRemoteExceptionStartLevel#setStartLevel(int)}public void waitForState(long bundleId,
int state,
long timeoutInMillis)
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworkwaitForState in interface RemoteFrameworkbundleId - bundle idstate - expected statetimeoutInMillis - max time to wait for stateRemoteException - - Remote communication related exception (mandatory by RMI)org.osgi.framework.BundleException - - If bundle cannot be foundpublic int getBundleState(long bundleId)
throws RemoteException,
org.osgi.framework.BundleException
RemoteFrameworkgetBundleState in interface RemoteFrameworkbundleId - bundle IDRemoteExceptionorg.osgi.framework.BundleException - if there is no bundle with the given IDorg.osgi.framework.Bundle#getState()}public RemoteServiceReference[] getServiceReferences(String filter) throws RemoteException, org.osgi.framework.BundleException, org.osgi.framework.InvalidSyntaxException
RemoteFrameworkRemoteServiceReference to interact with them, this is a snapshot of
the current state and must be recalled to updategetServiceReferences in interface RemoteFrameworkRemoteExceptionorg.osgi.framework.BundleExceptionorg.osgi.framework.InvalidSyntaxExceptionpublic RemoteServiceReference[] getServiceReferences(String filter, long timeout, TimeUnit timeUnit) throws RemoteException, org.osgi.framework.BundleException, org.osgi.framework.InvalidSyntaxException
RemoteFrameworkRemoteServiceReference to interact with them, this is a snapshot of
the current state and must be recalled to updategetServiceReferences in interface RemoteFrameworktimeout - wait the specified amout of time in relation to the timeunit for a service
matchign the filter to appearRemoteExceptionorg.osgi.framework.BundleExceptionorg.osgi.framework.InvalidSyntaxExceptionpublic Object invokeMethodOnService(RemoteServiceReference reference, String methodName, Object... args) throws RemoteException, Exception
RemoteFrameworkinvokeMethodOnService in interface RemoteFrameworkRemoteExceptionExceptionpublic Object invokeMethodOnService(RemoteServiceReference reference, String methodName, Class<?>[] parameterTypes, Object[] args) throws RemoteException, Exception
RemoteFrameworkinvokeMethodOnService in interface RemoteFrameworkRemoteExceptionExceptionpublic static void main(String[] args) throws RemoteException, AlreadyBoundException, org.osgi.framework.BundleException, InterruptedException
RemoteExceptionAlreadyBoundExceptionorg.osgi.framework.BundleExceptionInterruptedExceptionCopyright © 2006–2015 OPS4J - Open Participation Software for Java. All rights reserved.