Package ch.ethz.iks.r_osgi

Examples of ch.ethz.iks.r_osgi.RemoteOSGiException


            throw e;
          }
        } else {
          try {
            if (!primary.isConnected()) {
              throw new RemoteOSGiException("channel went down"); //$NON-NLS-1$
            }
            return primary.invokeMethod(mapping.getMapped(primary),
                methodSignature, args);
          } catch (final RemoteOSGiException e) {
            if (policy == FAILOVER_REDUNDANCY_POLICY) {
View Full Code Here


          if (reply != null) {

            try {
              networkChannel.sendMessage(reply);
            } catch (final NotSerializableException nse) {
              throw new RemoteOSGiException("Error sending " //$NON-NLS-1$
                  + reply, nse);
            } catch (NullPointerException npe) {
              // channel got closed             
            } catch (final IOException e) {
              dispose();
View Full Code Here

   * @category ChannelEndpoint
   */
  public Object invokeMethod(final String service,
      final String methodSignature, final Object[] args) throws Throwable {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed"); //$NON-NLS-1$
    }
    // check arguments for streams and replace with placeholder
    for (int i = 0; i < args.length; i++) {
      if (args[i] instanceof InputStream) {
        args[i] = getInputStreamPlaceholder((InputStream) args[i]);
      } else if (args[i] instanceof OutputStream) {
        args[i] = getOutputStreamPlaceholder((OutputStream) args[i]);
      }
    }

    final RemoteCallMessage invokeMsg = new RemoteCallMessage();
    invokeMsg.setServiceID(URI.create(service).getFragment());
    invokeMsg.setMethodSignature(methodSignature);
    invokeMsg.setArgs(args);

    try {
      // send the message and get a MethodResultMessage in return
      final RemoteCallResultMessage resultMsg = (RemoteCallResultMessage) sendAndWait(invokeMsg);
      if (resultMsg.causedException()) {
        throw resultMsg.getException();
      }
      final Object result = resultMsg.getResult();
      if (result instanceof InputStreamHandle) {
        return getInputStreamProxy((InputStreamHandle) result);
      } else if (result instanceof OutputStreamHandle) {
        return getOutputStreamProxy((OutputStreamHandle) result);
      } else {
        return result;
      }
    } catch (final RemoteOSGiException e) {
      throw new RemoteOSGiException("Method invocation of " //$NON-NLS-1$
          + service + " " + methodSignature + " failed.", e); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
View Full Code Here

  }

  void asyncRemoteCall(final String fragment, final String methodSignature,
      final Object[] args, final AsyncRemoteCallCallback callback) {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed"); //$NON-NLS-1$
    }
    // check arguments for streams and replace with placeholder
    for (int i = 0; i < args.length; i++) {
      if (args[i] instanceof InputStream) {
        args[i] = getInputStreamPlaceholder((InputStream) args[i]);
      } else if (args[i] instanceof OutputStream) {
        args[i] = getOutputStreamPlaceholder((OutputStream) args[i]);
      }
    }

    final Integer xid = new Integer(RemoteOSGiServiceImpl.nextXid());

    synchronized (callbacks) {
      callbacks.put(xid, new AsyncCallback() {
        public void result(final RemoteOSGiMessage msg) {
          final RemoteCallResultMessage resultMsg = (RemoteCallResultMessage) msg;
          if (resultMsg.causedException()) {
            callback.remoteCallResult(false, resultMsg
                .getException());
          }
          final Object result = resultMsg.getResult();
          final Object res;
          if (result instanceof InputStreamHandle) {
            res = getInputStreamProxy((InputStreamHandle) result);
          } else if (result instanceof OutputStreamHandle) {
            res = getOutputStreamProxy((OutputStreamHandle) result);
          } else {
            res = result;
          }
          callback.remoteCallResult(true, res);
        }
      });
    }

    final RemoteCallMessage invokeMsg = new RemoteCallMessage();
    invokeMsg.setServiceID(fragment);
    invokeMsg.setMethodSignature(methodSignature);
    invokeMsg.setArgs(args);
    invokeMsg.setXID(xid.shortValue());

    try {
      send(invokeMsg);
    } catch (final RemoteOSGiException e) {
      callbacks.remove(xid);
      callback
          .remoteCallResult(
              false,
              new RemoteOSGiException(
                  "Method invocation of " //$NON-NLS-1$
                      + getRemoteAddress()
                      + "#" + fragment + " " + methodSignature + " failed.", e)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
  }
View Full Code Here

    return networkChannel != null;
  }

  public String toString() {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed"); //$NON-NLS-1$
    }
    return "ChannelEndpoint(" + networkChannel.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

   * @return the channel ID.
   * @category ChannelEndpoint
   */
  public URI getRemoteAddress() {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed"); //$NON-NLS-1$
    }
    return networkChannel.getRemoteAddress();
  }
View Full Code Here

   *
   * @return
   */
  URI getLocalAddress() {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed"); //$NON-NLS-1$
    }
    return networkChannel.getLocalAddress();
  }
View Full Code Here

   *             in case of network errors.
   */
  void getProxyBundle(final RemoteServiceReference ref) throws IOException,
      RemoteOSGiException {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed."); //$NON-NLS-1$
    }

    // build the RequestServiceMessage
    final RequestServiceMessage req = new RequestServiceMessage();
    req.setServiceID(ref.getURI().getFragment());
View Full Code Here

     
    } catch (final BundleException e) {
      final Throwable nested = e.getNestedException() == null ? e : e
          .getNestedException();
      nested.printStackTrace();
      throw new RemoteOSGiException(
          "Could not install the generated bundle " + ref.toString(), //$NON-NLS-1$
          nested);
    }
  }
View Full Code Here

   *            the remote service reference to the service for which the
   *            bundle clone is requested.
   */
  void getCloneBundle(final RemoteServiceReference ref) {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed."); //$NON-NLS-1$
    }

    // build the RequestBundleMessage
    final RequestBundleMessage req = new RequestBundleMessage();
    req.setServiceID(ref.getURI().getFragment());
View Full Code Here

TOP

Related Classes of ch.ethz.iks.r_osgi.RemoteOSGiException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.