org.ops4j.pax.exam.rbc.internal
Class RemoteBundleContextImpl

java.lang.Object
  extended by org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, RemoteBundleContext

public class RemoteBundleContextImpl
extends java.lang.Object
implements RemoteBundleContext, java.io.Serializable

RemoteBundleContext implementaton.

Since:
0.1.0, June 10, 2008
Author:
Toni Menzel (tonit), Alin Dreghiciu (adreghiciu@gmail.com)
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.ops4j.pax.exam.rbc.internal.RemoteBundleContext
NO_WAIT, WAIT_FOREVER
 
Constructor Summary
RemoteBundleContextImpl(org.osgi.framework.BundleContext bundleContext)
          Constructor.
 
Method Summary
 long installBundle(java.lang.String bundleUrl)
          Installs a bundle remotly.
 long installBundle(java.lang.String bundleLocation, byte[] bundle)
          Installs a bundle remotly given the bundle content.
 java.lang.Object remoteCall(java.lang.Class<?> serviceType, java.lang.String methodName, java.lang.Class<?>[] methodParams, long timeoutInMillis, java.lang.Object... actualParams)
          Makes a remote call on a service.
 void setBundleStartLevel(long bundleId, int startLevel)
          Sets bundle start level.
 void startBundle(long bundleId)
          Starts a bundle.
 void stopBundle(long bundleId)
          Stops a bundle.
 void waitForState(long bundleId, int state, long timeoutInMillis)
          Waits for a bundle to be in a certain state and returns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteBundleContextImpl

public RemoteBundleContextImpl(org.osgi.framework.BundleContext bundleContext)
Constructor.

Parameters:
bundleContext - bundle context (cannot be null)
Throws:
java.lang.IllegalArgumentException - - If bundle context is null
Method Detail

remoteCall

public java.lang.Object remoteCall(java.lang.Class<?> serviceType,
                                   java.lang.String methodName,
                                   java.lang.Class<?>[] methodParams,
                                   long timeoutInMillis,
                                   java.lang.Object... actualParams)
                            throws NoSuchServiceException,
                                   java.lang.NoSuchMethodException,
                                   java.lang.IllegalAccessException,
                                   java.lang.reflect.InvocationTargetException
Makes a remote call on a service.

Specified by:
remoteCall in interface RemoteBundleContext
Parameters:
serviceType - service class of the remote service
methodName - method name
methodParams - method parameters types
timeoutInMillis - timeout for looking up the service
actualParams - actual parameters (must match the given method params)
Returns:
remote call rsult
Throws:
NoSuchServiceException - - If a service of the specified type cannot be located
java.lang.NoSuchMethodException - - If the given method cannot be found
java.lang.IllegalAccessException - - Specified method cannot be accessed
java.lang.reflect.InvocationTargetException - - Wraps an eventual exception occured during method invocation

installBundle

public long installBundle(java.lang.String bundleUrl)
                   throws org.osgi.framework.BundleException
Installs a bundle remotly.

Specified by:
installBundle in interface RemoteBundleContext
Parameters:
bundleUrl - url of the bundle to be installed. The url must be accessible from the remote OSGi container.
Returns:
bundle id of the installed bundle
Throws:
org.osgi.framework.BundleException - - Re-thrown from installing the bundle

installBundle

public long installBundle(java.lang.String bundleLocation,
                          byte[] bundle)
                   throws org.osgi.framework.BundleException
Installs a bundle remotly given the bundle content.

Specified by:
installBundle in interface RemoteBundleContext
Parameters:
bundleLocation - bundle location
bundle - bundle content as a byte array
Returns:
bundle id of the installed bundle
Throws:
org.osgi.framework.BundleException - - Re-thrown from installing the bundle

startBundle

public void startBundle(long bundleId)
                 throws org.osgi.framework.BundleException
Starts a bundle.

Specified by:
startBundle in interface RemoteBundleContext
Parameters:
bundleId - id of the bundle to be started
Throws:
org.osgi.framework.BundleException - - Re-thrown from starting the bundle

stopBundle

public void stopBundle(long bundleId)
                throws org.osgi.framework.BundleException
Stops a bundle.

Specified by:
stopBundle in interface RemoteBundleContext
Parameters:
bundleId - id of the bundle to be stopped
Throws:
org.osgi.framework.BundleException - - Re-thrown from stopping the bundle

setBundleStartLevel

public void setBundleStartLevel(long bundleId,
                                int startLevel)
                         throws java.rmi.RemoteException,
                                org.osgi.framework.BundleException
Sets bundle start level.

Specified by:
setBundleStartLevel in interface RemoteBundleContext
Parameters:
bundleId - id of the bundle to which the start level should be set
startLevel - bundle start level
Throws:
java.rmi.RemoteException - - Remote communication related exception (mandatory by RMI)
org.osgi.framework.BundleException - - If bundle level cannot be set

waitForState

public void waitForState(long bundleId,
                         int state,
                         long timeoutInMillis)
                  throws TimeoutException
Waits for a bundle to be in a certain state and returns.

Specified by:
waitForState in interface RemoteBundleContext
Parameters:
bundleId - bundle id
state - expected state
timeoutInMillis - max time to wait for state
Throws:
TimeoutException - - if timeout occured and expected state has not being reached


Copyright © 2006-2012 OPS4J - Open Participation Software for Java. All Rights Reserved.