Examples of Transport


Examples of org.jscep.transport.Transport

    return new URL("http", "localhost", port, PATH);
  }

  private X509Certificate getRecipient() throws Exception {
    GetCaCertRequest req = new GetCaCertRequest();
    Transport transport = new HttpGetTransport(getURL());

    CertStore store = transport.sendRequest(req,
        new GetCaCertResponseHandler());
    Collection<? extends Certificate> certs = store.getCertificates(null);

    if (certs.size() > 0) {
      return (X509Certificate) certs.iterator().next();
View Full Code Here

Examples of org.mortbay.cometd.Transport

            return;
        }

        // Look for an existing client and protect from context restarts
        Object clientObj=request.getAttribute(CLIENT_ATTR);
        Transport transport=null;
        int received=-1;
        boolean metaConnectDeliveryOnly=false;
        boolean pendingResponse=false;
        boolean metaConnect=false;
        final boolean initial;

        // Have we seen this request before
        ContinuationClient client=(clientObj instanceof ClientImpl)?(ContinuationClient)clientObj:null;
        if (client != null)
        {
            initial=false;
            // yes - extract saved properties
            transport=(Transport)request.getAttribute(TRANSPORT_ATTR);
            transport.setResponse(response);
            metaConnectDeliveryOnly=client.isMetaConnectDeliveryOnly() || transport.isMetaConnectDeliveryOnly();
            metaConnect=true;
        }
        else
        {
            initial=true;
            Message[] messages=getMessages(request);
            received=messages.length;

            /* check jsonp parameter */
            String jsonpParam=request.getParameter("jsonp");

            // Handle all received messages
            try
            {
                for (Message message : messages)
                {
                    if (jsonpParam != null)
                        message.put("jsonp",jsonpParam);

                    if (client == null)
                    {
                        String clientId = (String)message.get(AbstractBayeux.CLIENT_FIELD);
                        client=(ContinuationClient)_bayeux.getClient(clientId);

                        // If no client, SHOULD be a handshake, so force a
                        // transport and handle
                        if (client == null)
                        {
                            // Setup a browser ID
                            String browser_id=findBrowserId(request);
                            if (browser_id == null)
                                browser_id=setBrowserId(request,response);

                            if (transport == null)
                            {
                                transport=_bayeux.newTransport(client,message);
                                transport.setResponse(response);
                                metaConnectDeliveryOnly=transport.isMetaConnectDeliveryOnly();
                            }
                            _bayeux.handle(null,transport,message);
                            message=null;
                            continue;
                        }
                    }

                    String browser_id=findBrowserId(request);
                    if (browser_id != null && (client.getBrowserId() == null || !client.getBrowserId().equals(browser_id)))
                        client.setBrowserId(browser_id);

                    // resolve transport
                    if (transport == null)
                    {
                        transport=_bayeux.newTransport(client,message);
                        transport.setResponse(response);
                        metaConnectDeliveryOnly=client.isMetaConnectDeliveryOnly() || transport.isMetaConnectDeliveryOnly();
                    }

                    // Tell client to hold messages as a response is likely to
                    // be sent.
                    if (!metaConnectDeliveryOnly && !pendingResponse)
                    {
                        pendingResponse=true;
                        client.responsePending();
                    }

                    if (Bayeux.META_CONNECT.equals(message.getChannel()))
                        metaConnect=true;

                    _bayeux.handle(client,transport,message);
                }
            }
            finally
            {
                for (Message message : messages)
                    ((MessageImpl)message).decRef();
                if (pendingResponse)
                {
                    client.responded();
                }
            }
        }

        Message metaConnectReply=null;

        // Do we need to wait for messages
        if (transport != null)
        {
            metaConnectReply=transport.getMetaConnectReply();
            if (metaConnectReply != null)
            {
                long timeout=client.getTimeout();
                if (timeout < 0)
                    timeout=_bayeux.getTimeout();

                Continuation continuation=ContinuationSupport.getContinuation(request,client);

                // Get messages or wait
                synchronized(client)
                {
                    if (timeout > 0 && !client.hasNonLazyMessages() && initial && received <= 1)
                    {
                        // save state and suspend
                        request.setAttribute(CLIENT_ATTR,client);
                        request.setAttribute(TRANSPORT_ATTR,transport);
                        client.setContinuation(continuation);
                        continuation.setObject(response);
                        continuation.suspend(timeout);
                    }

                    continuation.reset();
                }

                client.setContinuation(null);
                transport.setMetaConnectReply(null);
            }
            else if (client != null)
            {
                client.access();
            }
        }

        if (client != null)
        {
            if (metaConnectDeliveryOnly && !metaConnect)
            {
                // wake up any long poll
                client.resume();
            }
            else
            {
                List<Message> messages;
                synchronized (client)
                {
                    client.doDeliverListeners();

                    ArrayQueue<Message> clientMessages = (ArrayQueue<Message>)client.getQueue();
                    // Copy the messages to avoid synchronization
                    messages = new ArrayList<Message>(clientMessages);
                    // Empty client's queue
                    clientMessages.clear();
                }

                final int size=messages.size();
                for (int i=0; i < size; i++)
                {
                    final Message message=messages.get(i);
                    final MessageImpl mesgImpl=(message instanceof MessageImpl)?(MessageImpl)message:null;

                    // Can we short cut the message?
                    if (i == 0 && size == 1 && mesgImpl != null && _refsThreshold > 0 && metaConnectReply != null && transport instanceof JSONTransport)
                    {
                        // is there a response already prepared
                        ByteBuffer buffer=mesgImpl.getBuffer();
                        if (buffer != null)
                        {
                            // Send pre-prepared buffer
                            request.setAttribute("org.mortbay.jetty.ResponseBuffer",buffer);
                            if (metaConnectReply instanceof MessageImpl)
                                ((MessageImpl)metaConnectReply).decRef();
                            metaConnectReply=null;
                            transport=null;
                            mesgImpl.decRef();
                            continue;
                        }
                        else if (mesgImpl.getRefs() >= _refsThreshold)
                        {
                            // create multi-use buffer
                            byte[] contentBytes=("[" + mesgImpl.getJSON() + ",{\"" + Bayeux.SUCCESSFUL_FIELD + "\":true,\"" + Bayeux.CHANNEL_FIELD
                                    + "\":\"" + Bayeux.META_CONNECT + "\"}]").getBytes(StringUtil.__UTF8);
                            int contentLength=contentBytes.length;

                            String headerString="HTTP/1.1 200 OK\r\n" + "Content-Type: text/json; charset=utf-8\r\n" + "Content-Length: "
                                    + contentLength + "\r\n" + "\r\n";

                            byte[] headerBytes=headerString.getBytes(StringUtil.__UTF8);

                            buffer=ByteBuffer.allocateDirect(headerBytes.length + contentLength);
                            buffer.put(headerBytes);
                            buffer.put(contentBytes);
                            buffer.flip();

                            mesgImpl.setBuffer(buffer);
                            request.setAttribute("org.mortbay.jetty.ResponseBuffer",buffer);
                            metaConnectReply=null;
                            if (metaConnectReply instanceof MessageImpl)
                                ((MessageImpl)metaConnectReply).decRef();
                            transport=null;
                            mesgImpl.decRef();
                            continue;
                        }
                    }

                    if (message != null)
                        transport.send(message);
                    if (mesgImpl != null)
                        mesgImpl.decRef();
                }

                if (metaConnectReply != null)
                {
                    metaConnectReply=_bayeux.extendSendMeta(client,metaConnectReply);
                    transport.send(metaConnectReply);
                    if (metaConnectReply instanceof MessageImpl)
                        ((MessageImpl)metaConnectReply).decRef();
                }
            }
        }

        if (transport != null)
            transport.complete();
    }
View Full Code Here

Examples of org.objectweb.celtix.transports.Transport

    public void testConstruction() {    
       
        ObjectMessageContext objectCtx = new ObjectMessageContextImpl();
        RMSource source = EasyMock.createMock(RMSource.class);
        AbstractBindingBase binding = EasyMock.createMock(AbstractBindingBase.class);
        Transport transport = EasyMock.createMock(Transport.class);
        HandlerChainInvoker hci = new HandlerChainInvoker(new ArrayList<Handler>());
       
        Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
        sid.setValue("TerminatedSequence");
        SourceSequence seq = new SourceSequence(sid, null, null);
View Full Code Here

Examples of org.objectweb.celtix.transports.Transport

        EasyMock.expectLastCall().andReturn(Boolean.valueOf(isRequestor)).times(2);
        contexts.get(i).get(SERVER_ADDRESSING_PROPERTIES_OUTBOUND);
        EasyMock.expectLastCall().andReturn(maps);
        sequences.get(i).getIdentifier();
        EasyMock.expectLastCall().andReturn(identifiers.get(i));
        Transport transport = isRequestor
                              ? control.createMock(ClientTransport.class)
                              : control.createMock(ServerTransport.class);
        if (isRequestor) {
            handler.getClientTransport();
            EasyMock.expectLastCall().andReturn(transport).times(2);
        } else {
            handler.getServerTransport();
            EasyMock.expectLastCall().andReturn(transport).times(1);
        }
        AbstractBindingBase binding =
            control.createMock(AbstractBindingBase.class);
        handler.getBinding();
        EasyMock.expectLastCall().andReturn(binding);
        HandlerInvoker handlerInvoker =
            control.createMock(HandlerInvoker.class);
        binding.createHandlerInvoker();
        EasyMock.expectLastCall().andReturn(handlerInvoker);
        AbstractBindingImpl bindingImpl =
            control.createMock(AbstractBindingImpl.class);
        binding.getBindingImpl();
        EasyMock.expectLastCall().andReturn(bindingImpl).times(isRequestor
                                                               ? 6
                                                               : 5);
        bindingImpl.createBindingMessageContext(contexts.get(i));
        MessageContext bindingContext =
            control.createMock(MessageContext.class);
        EasyMock.expectLastCall().andReturn(bindingContext);
        OutputStreamMessageContext outputStreamContext =
            control.createMock(OutputStreamMessageContext.class);
        transport.createOutputStreamContext(bindingContext);
        EasyMock.expectLastCall().andReturn(outputStreamContext);
       
        if (isRequestor) {
            setUpClientDispatch(handlerInvoker,
                                contexts.get(i),
View Full Code Here

Examples of org.objectweb.celtix.transports.Transport

     * BusLifeCycleListener.preShutdown()).
     *
     * @return
     */
    protected Transport getTransport() {
        Transport ret = null;
        if (handler.getClientBinding() == null) {
            ret = handler.getTransport();
        } else {
            try {
                ret = ((AbstractClientBinding)handler.getClientBinding()).getTransport();
View Full Code Here

Examples of org.objectweb.celtix.transports.Transport

     * @param context the message context
     * @return an appropriate Request for the context
     */
    private Request createClientRequest(ObjectMessageContext context) {
        AbstractBindingBase binding = handler.getBinding();
        Transport transport = handler.getClientTransport();
        Request request = new Request(binding, transport, context);
        request.setOneway(ContextUtils.isOneway(context));
        return request;
    }
View Full Code Here

Examples of org.platformlayer.ops.firewall.Transport

    Protocol protocol = null;
    if (model.protocol != null) {
      protocol = EnumUtils.valueOfCaseInsensitive(Protocol.class, model.protocol);
    }

    Transport transport = null;
    // if (model.transport != null) {
    // protocol = EnumUtils.valueOfCaseInsensitive(Transport.class, model.transport);
    // }

    List<Integer> ports = Lists.newArrayList();
View Full Code Here

Examples of rtpi.transport.Transport

      System.err.println("Invalid multicast address - exiting!");
      System.exit(0);
  }

  UnreliableUdpMulticast reliabilityService=null;
  Transport rtcpTransport=null;
 
  try {
      reliabilityService=new UnreliableUdpMulticast(group, port, ttl, 5000000, 10000);
      rtcpTransport = new IPMCTransport(group, port+1, ttl, 5000000);
  } catch (Exception ex) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.