Package ch.ethz.iks.r_osgi

Examples of ch.ethz.iks.r_osgi.RemoteOSGiException


   * @param msg
   *            a message.
   */
  void send(final RemoteOSGiMessage msg) {
    if (networkChannel == null) {
      throw new RemoteOSGiException("Channel is closed"); //$NON-NLS-1$
    }

    if (msg.getXID() == 0) {
      msg.setXID(RemoteOSGiServiceImpl.nextXid());
    }

    try {
      try {
        networkChannel.sendMessage(msg);
        return;
      } catch (final IOException ioe) {
        // TimeOffsetMessages have to be handled differently
        // must send a new message with a new timestamp and XID
        // instead
        // of sending the same message again
        if (msg instanceof TimeOffsetMessage) {
          ((TimeOffsetMessage) msg).restamp(RemoteOSGiServiceImpl
              .nextXid());
          networkChannel.sendMessage(msg);
        } else {
          networkChannel.sendMessage(msg);
        }
      }
    } catch (final NotSerializableException nse) {
      throw new RemoteOSGiException("Error sending " + msg, nse); //$NON-NLS-1$
    } catch (final IOException ioe) {
      // failed to reconnect...
      dispose();
      throw new RemoteOSGiException("Network error", ioe); //$NON-NLS-1$
    }
  }
View Full Code Here


          m.setXID(reqMsg.getXID());
          m.setResult(StreamResultMessage.RESULT_WRITE_OK);
          return m;
        }
        default:
          throw new RemoteOSGiException(
              "Unimplemented op code for stream request " + msg); //$NON-NLS-1$
        }
      } catch (final IOException e) {
        final StreamResultMessage m = new StreamResultMessage();
        m.setXID(reqMsg.getXID());
        m.setResult(StreamResultMessage.RESULT_EXCEPTION);
        m.setException(e);
        return m;
      }
    }
    case RemoteOSGiMessage.REQUEST_BUNDLE:
      final RequestBundleMessage reqB = (RequestBundleMessage) msg;

      try {
        final String serviceID = reqB.getServiceID();

        final RemoteServiceRegistration reg = getServiceRegistration(serviceID);

        final byte[] bytes = RemoteOSGiServiceImpl.getBundle(reg
            .getReference().getBundle());

        final DeliverBundlesMessage delB = new DeliverBundlesMessage();
        delB.setXID(reqB.getXID());
        delB.setDependencies(new byte[][] { bytes });
        return delB;
      } catch (IOException ioe) {
        ioe.printStackTrace();
        return null;
      }
    case RemoteOSGiMessage.REQUEST_DEPENDENCIES:
      final RequestDependenciesMessage reqDeps = (RequestDependenciesMessage) msg;

      try {
        final byte[][] bundleBytes = RemoteOSGiServiceImpl
            .getBundlesForPackages(reqDeps.getPackages());
        final DeliverBundlesMessage delDeps = new DeliverBundlesMessage();
        delDeps.setXID(reqDeps.getXID());
        delDeps.setDependencies(bundleBytes);
        return delDeps;
      } catch (IOException ioe) {
        ioe.printStackTrace();
        return null;
      }
    default:
      throw new RemoteOSGiException("Unimplemented message " + msg); //$NON-NLS-1$
    }
  }
View Full Code Here

            && System.currentTimeMillis() < timeout) {
          blocking.wait(TIMEOUT);
          result = blocking.getResult();
        }
      } catch (InterruptedException ie) {
        throw new RemoteOSGiException(
            "Interrupted while waiting for callback", ie); //$NON-NLS-1$
      }
      if (result != null) {
        return result;
      } else if (networkChannel == null) {
        throw new RemoteOSGiException("Channel is closed"); //$NON-NLS-1$
      } else {
        throw new RemoteOSGiException(
            "Method Invocation failed, timeout exceeded."); //$NON-NLS-1$
      }
    }

  }
View Full Code Here

      if (result.causedException()) {
        throw result.getException();
      }
      return result;
    } catch (final RemoteOSGiException e) {
      throw new RemoteOSGiException("Invocation of operation " //$NON-NLS-1$
          + requestMsg.getOp() + " on stream " //$NON-NLS-1$
          + requestMsg.getStreamID() + " failed.", e); //$NON-NLS-1$
    }
  }
View Full Code Here

      break;
    case DELIVER_BUNDLES:
      msg = new DeliverBundlesMessage(input);
      break;
    default:
      throw new RemoteOSGiException("funcID " + funcID //$NON-NLS-1$
          + " not supported."); //$NON-NLS-1$
    }
    msg.funcID = funcID;
    msg.xid = xid;
    return msg;
View Full Code Here

                    reg.getProperties() });
                updateLeases(lu);
                return service;
              } catch (final ClassNotFoundException e) {
                e.printStackTrace();
                throw new RemoteOSGiException(
                    "Cannot find class " + service, e); //$NON-NLS-1$
              }
            }

            public void modifiedService(
View Full Code Here

            return (NetworkChannelFactory) networkChannelFactoryTracker
                .getService(refs[i]);
          }
        }
      }
      throw new RemoteOSGiException("No NetworkChannelFactory for " //$NON-NLS-1$
          + protocol + " found."); //$NON-NLS-1$

    } catch (final InvalidSyntaxException e) {
      // does not happen
      e.printStackTrace();
View Full Code Here

    if (channel == null) {
      try {
        connect(serviceURI);
        channel = (ChannelEndpointImpl) channels.get(uri);
      } catch (final IOException ioe) {
        throw new RemoteOSGiException("Cannot connect to " + uri); //$NON-NLS-1$
      }
    }
    return channel.getRemoteReference(serviceURI.toString());
  }
View Full Code Here

    if (channel == null) {
      try {
        connect(service);
        channel = (ChannelEndpointImpl) channels.get(uri);
      } catch (final IOException ioe) {
        throw new RemoteOSGiException("Cannot connect to " + uri); //$NON-NLS-1$
      }
    }
    if (clazz == null) {
      return channel.getAllRemoteReferences(null);
    }
View Full Code Here

    try {
      ChannelEndpointImpl channel;
      channel = ((RemoteServiceReferenceImpl) ref).getChannel();
      channel.getProxyBundle(ref);
    } catch (final UnknownHostException e) {
      throw new RemoteOSGiException(
          "Cannot resolve host " + ref.getURI(), e); //$NON-NLS-1$
    } catch (final IOException ioe) {
      throw new RemoteOSGiException("Proxy generation error", ioe); //$NON-NLS-1$
    }
  }
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.