Package net.jini.jeri

Examples of net.jini.jeri.OutboundRequest


    /**
     * Initiates new request to connection target.  Throws an IOException if
     * the connection is currently busy.
     */
    public OutboundRequest newRequest() throws IOException {
  OutboundRequest req = null;
  markBusy();
  fetchServerInfo();
  try {
      req = new OutboundRequestImpl();
      return req;
View Full Code Here


  for (Iterator i = testCases.entrySet().iterator(); i.hasNext();) {
      Map.Entry entry = (Map.Entry) i.next();
      InvocationConstraints c = (InvocationConstraints) entry.getKey();
      System.err.println("  trying: " + c);
      OutboundRequestIterator iter = endpoint.newRequest(c);
      OutboundRequest request = iter.next();
      InvocationConstraints u = request.getUnfulfilledConstraints();
      System.err.println("returned: " + u);
      if (!entry.getValue().equals(u)) {
    throw new RuntimeException(
        "TEST FAILED: incorrect constraints returned by " +
        method);
      }
      request.getRequestOutputStream().close();
      InputStream in = request.getResponseInputStream();
      in.read();
      in.close();
  }

  synchronized (lock) {
View Full Code Here

        Endpoint e =
            se.enumerateListenEndpoints(lc);
        dispatcher.accept();
        OutboundRequestIterator ori =
            e.newRequest(InvocationConstraints.EMPTY);
        OutboundRequest or = null;
        while (ori.hasNext()) {
            or = ori.next();
            ObjectOutputStream oos = new ObjectOutputStream(
                or.getRequestOutputStream());
            oos.writeInt(1);
            oos.close();
        }
        if (dispatcher.dispatchCalled()!=1){
            throw new TestException("Dispatcher did not receive"
                + " the value sent");
        }
        if (!or.getDeliveryStatus()) {
            throw new TestException("Call on OutboundRequest"
                + ".getDeliveryStatus() returned false for an accepted"
                + " request");
        }
        ArrayList endpoints = lc.getEndpoints();
        Iterator it = endpoints.iterator();
        while (it.hasNext()){
            ((EndpointHolder)it.next()).getListenHandle().close();
        }
        dispatcher.reject();
        try {
            ori = e.newRequest(InvocationConstraints.EMPTY);
            while (ori.hasNext()) {
                or = ori.next();
                ObjectOutputStream oos = new ObjectOutputStream(
                    or.getRequestOutputStream());
                oos.writeInt(2);
                oos.close();
            }
        } catch (IOException ioe) {
            log.finest("Expected Exception: " + ioe.getMessage());
           //Expected IOException
        } catch (RuntimeException re) {
            throw new TestException("Dispatcher called after" +
                " its associated ListenHandle was closed");
        }
        if (or.getDeliveryStatus()) {
            throw new TestException("Call on OutboundRequest"
                + ".getDeliveryStatus() returned true for a failed"
                + " call");
        }
    }
View Full Code Here

        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    OutboundRequestIterator it = ep.newRequest(
                        InvocationConstraints.EMPTY);
                    OutboundRequest or = it.next();
                    final InputStream is = or.getResponseInputStream();
                    Thread input = new Thread(new Runnable() {
                        public void run() {
                            try {
                                byte[] bytes = new byte[2];
                                is.read(bytes);
                                received[0] = bytes[0];
                                received[1] = bytes[1];
                                is.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    input.start();
                    OutputStream os = or.getRequestOutputStream();
                    byte[] bytes = new byte[expectedBytes];
                    Arrays.fill(bytes,(byte)0x88);
                    os.write(bytes);
                    os.close();
                } catch (IOException e) {
View Full Code Here

        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    OutboundRequestIterator it = ep.newRequest(
                        InvocationConstraints.EMPTY);
                    OutboundRequest or = it.next();
                    OutputStream os = or.getRequestOutputStream();
                    byte[] bytes = new byte[expectedBytes];
                    Arrays.fill(bytes,(byte)0x88);
                    os.write(bytes);
                    os.close();
                } catch (IOException e) {
View Full Code Here

            Util.log(Util.CALLS,"Enter "
              + "Endpoint.newRequest(connectionEndpoint,context)");
            Util.log(Util.STACK);
            ReadCallback rcb = null;
            WriteCallback wcb = (WriteCallback) Bridge.writeCallbackLocal.get();
            OutboundRequest or = (OutboundRequest) requests.get(index);
            if (wcb != null) {
                rcb = wcb.writeCallback(or, constraints);
            }
            ObjectOutputStream oos =
                new ObjectOutputStream(or.getRequestOutputStream());
            oos.writeObject(new MarshalledObject(rcb));
            oos.flush();
            Util.log(Util.RETURN, "returned OutboundRequest: " + or);
            Util.log(Util.CALLS, "Leaving Endpoint.newRequest");
            index++;
View Full Code Here

    }

    // inherit javadoc
    public void run() throws Exception {
        int counter = 1;
        OutboundRequest request;

        FakeOutboundRequest fakeRequest = new FakeOutboundRequest();
        FakeOutboundRequestIterator iterator =
            new FakeOutboundRequestIterator(fakeRequest);
        FakeEndpoint ep = new FakeEndpoint(iterator);
View Full Code Here

        dispatcher.reject();
        try {
            OutboundRequestIterator ori =
                e.newRequest(InvocationConstraints.EMPTY);
            while (ori.hasNext()){
                OutboundRequest or = ori.next();
                ObjectOutputStream oos = new ObjectOutputStream(
                    or.getRequestOutputStream());
                oos.writeInt(1);
                oos.close();
            }
        } catch (Exception e2) {
            //Expected exception
            log.finest("Expected exception " + e2.getMessage());
        }
        if (dispatcher.dispatchCalled()!=-1){
            throw new TestException("Exception from the "
                + "dispatcher was not propagated");
        }
        dispatcher.accept();
        try {
            OutboundRequestIterator ori =
                e.newRequest(InvocationConstraints.EMPTY);
            while (ori.hasNext()) {
               OutboundRequest or = ori.next();
               ObjectOutputStream oos = new ObjectOutputStream(
               or.getRequestOutputStream());
               oos.writeInt(2);
               oos.close();
            }
        } catch (IOException ioe) {
            throw new TestException("Endpoint unavailable after"
View Full Code Here

        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    OutboundRequestIterator it = ep.newRequest(
                        InvocationConstraints.EMPTY);
                    OutboundRequest or = it.next();
                    final InputStream is = or.getResponseInputStream();
                    Thread input = new Thread(new Runnable() {
                        public void run() {
                            try {
                                byte[] bytes = new byte[2];
                                is.read(bytes);
                                received[0] = bytes[0];
                                received[1] = bytes[1];
                                is.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    input.start();
                    OutputStream os = or.getRequestOutputStream();
                    for (int i=0; i<600; i++) {
                        os.write(0x88);
                    }
                    os.close();
                } catch (IOException e) {
View Full Code Here

    }

    // inherit javadoc
    public void run() throws Exception {
        int counter = 1;
        OutboundRequest request;

        FakeOutboundRequest fakeRequest = new FakeOutboundRequest();
        FakeOutboundRequestIterator iterator =
            new FakeOutboundRequestIterator(fakeRequest);
        FakeEndpoint ep = new FakeEndpoint(iterator);
View Full Code Here

TOP

Related Classes of net.jini.jeri.OutboundRequest

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.