Returns the Stream Handler.

@param protocol
the protocol to use
354896
public Object getURLStreamHandler(String protocol) {

    URLStreamHandler handler = (URLStreamHandler) handlers.get(protocol);
    if (handler == null) {

      boolean checkedWithFactory = false;

      // Use the factory (if any)
      if (factory != null) {
        handler = factory.createURLStreamHandler(protocol);
        checkedWithFactory = true;
      }

      // Try java protocol handler
      if (handler == null) {
        final String packagePrefixList = System.getProperty(PROTOCOL_PATH_PROP, "");
        StringTokenizer packagePrefixIter = new StringTokenizer(packagePrefixList, "|");

        while (handler == null && packagePrefixIter.hasMoreTokens()) {

          String packagePrefix = packagePrefixIter.nextToken().trim();
          try {
            String clsName = packagePrefix + "." + protocol + ".Handler";
            Class<?> cls = null;
            try {
              ClassLoader cl = ClassLoader.getSystemClassLoader();
              cls = Class.forName(clsName, true, cl);
            } catch (ClassNotFoundException e) {
              ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
              if (contextLoader != null) {
                cls = Class.forName(clsName, true, contextLoader);
              }
            }
            if (cls != null) {
              handler = (URLStreamHandler) cls.newInstance();
            }
          } catch (ReflectiveOperationException ignored) {
            // Shouldn't happen, but code below handles the error.
          }
        }
      }

      // Fallback to built-in stream handler.
      // Makes okhttp the default http/https handler
      if (handler == null) {
        try {
          if (protocol.equals("file")) {
            // https://github.com/google/j2objc/issues/912
            handler = new sun.net.www.protocol.file.Handler();
          } else if (protocol.equals("jar")) {
            throw new UnsupportedOperationException("Jar streams are not supported.");
          } else if (protocol.equals("http")) {
            handler = new IosHttpHandler();
          } else if (protocol.equals("https")) {
            try {
              String name = "com.google.j2objc.net.IosHttpsHandler";
              handler = (URLStreamHandler) Class.forName(name).newInstance();
            } catch (Exception e) {
              throw new LibraryNotLinkedError("Https support", "jre_ssl",
                  "JavaxNetSslHttpsURLConnection");
            }
          }
        } catch (Exception e) {
          throw new AssertionError(e);
        }
      }

      synchronized (streamHandlerLock) {
        URLStreamHandler handler2 = null;

        // Check again with hashtable just in case another
        // thread created a handler since we last checked
        handler2 = (URLStreamHandler) handlers.get(protocol);

        if (handler2 != null) {
          return handler2;
        }

        // Check with factory if another thread set a
        // factory since our last check
        if (!checkedWithFactory && factory != null) {
          handler2 = factory.createURLStreamHandler(protocol);
        }

        if (handler2 != null) {
          // The handler from the factory must be given more
          // importance. Discard the default handler that
          // this thread created.
          handler = handler2;
        }

        // Insert this handler into the hashtable
        if (handler != null) {
          handlers.put(protocol, handler);
        }
      }
    }

    return handler;
  }
1199034
def is_stream_handler(self, request):
        
        try:
            handler = self.get(request)[0]
        except (NotFound, MethodNotSupported):
            return False
        if hasattr(handler, "view_class") and hasattr(
            handler.view_class, request.method.lower()
        ):
            handler = getattr(handler.view_class, request.method.lower())
        return hasattr(handler, "is_stream")
1183829
@Override
    public Packet getPacket(final Protocol p) throws IOException, PacketParseException {
        if (this.protocol == p) {
            return this;
        }

        final Packet child = getNextPacket();
        if (child != null && child.getProtocol() == p) {
            return child;
        }

        if (child == null) {
            return checkParent(p);
        }

        return child.getPacket(p);
    }
1207401
@Override
    public String getProtocol() {
        String protocol = this.request.getVersion();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "getProtocol: " + protocol);
        }
        return protocol;
    }
1036044
void handleRequest(ByteBuf buffer) {
    long requestId = buffer.readLong();

    try {
      Object request = readRequest(buffer);
      HandlerHolder handler = handlers.get(request.getClass());
      if (handler != null) {
        handler.context.executor().execute(() -> handleRequest(requestId, request, handler));
      } else {
        handleRequestFailure(requestId, new SerializationException("unknown message type: " + request.getClass()), this.context);
      }
    } catch (SerializationException e) {
      handleRequestFailure(requestId, e, this.context);
    } finally {
      buffer.release();
    }
  }
329047
public final TcpServer handle(BiFunction<? super NettyInbound, ? super
			NettyOutbound, ? extends Publisher<Void>> handler) {
		return new TcpServerHandle(this, handler);
	}
83600
public StreamReadsRequest getStreamReadsRequest(StreamReadsRequest prototype) {
    return StreamReadsRequest.newBuilder(prototype)
        .setReferenceName(referenceName)
        .setStart(start)
        .setEnd(end)
        .build();
  }
744590
public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall(
      BidiStreamingMethod<ReqT, RespT> method) {
    return asyncStreamingRequestCall(method);
  }
954565
public com.google.protobuf.ByteString
      getHandleBytes() {
    java.lang.Object ref = handle_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      handle_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
387247
public final UdpServer handle(BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>> handler) {
		Objects.requireNonNull(handler, "handler");
		return doOnBound(c -> {
			if (log.isDebugEnabled()) {
				log.debug(format(c.channel(), "Handler is being applied: {}"), handler);
			}

			Mono.fromDirect(handler.apply((UdpInbound) c, (UdpOutbound) c))
			    .subscribe(c.disposeSubscriber());
		});
	}
1240812
protected IStreamAwareScopeHandler getStreamAwareHandler() {
        if (scope != null) {
            IScopeHandler handler = scope.getHandler();
            if (handler instanceof IStreamAwareScopeHandler) {
                return (IStreamAwareScopeHandler) handler;
            }
        }
        return null;
    }
895214
@Override
	public HttpCommandProcessor getCommandProcessor(Protocol protocol) {
		String commandProcessorName = commandProcessorNames.get(protocol);

        if (commandProcessorName == null) {
			throw new PanicInTheCougar("No HTTP Command Processor has been configured for protocol " + protocol);
        }

        HttpCommandProcessor commandProcessor = (HttpCommandProcessor)applicationContext.getBean(commandProcessorName);

        if (commandProcessor == null) {
			throw new PanicInTheCougar("No HTTP Command Processor has been configured for the name " + commandProcessorName);
        }

		return commandProcessor;
	}
1365098
synchronized ContentHandler getContentHandler()
        throws IOException
    {
        String contentType = stripOffParameters(getContentType());
        ContentHandler handler = null;
        if (contentType == null) {
            if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
                contentType = guessContentTypeFromStream(getInputStream());
            }
        }

        if (contentType == null) {
            return UnknownContentHandler.INSTANCE;
        }
        try {
            handler = (ContentHandler) handlers.get(contentType);
            if (handler != null)
                return handler;
        } catch(Exception e) {
        }

        if (factory != null)
            handler = factory.createContentHandler(contentType);
        if (handler == null) {
            try {
                handler = lookupContentHandlerClassFor(contentType);
            } catch(Exception e) {
                e.printStackTrace();
                handler = UnknownContentHandler.INSTANCE;
            }
            handlers.put(contentType, handler);
        }
        return handler;
    }
426361
@Override
    public URLStreamHandler createURLStreamHandler(final String protocol) {
        if (null == protocol) {
            throw new IllegalArgumentException("null protocol not allowed");
        }
        if (logger.isTraceEnabled()) {
            logger.trace("need to create URLStreamHandler for protocol {}", protocol);
        }

        final String proto = protocol.toLowerCase();
        if (PROTO_HTTP.equals(proto) || PROTO_HTTPS.equals(proto)) {
            return new URLStreamHandler() {
                @Override
                protected URLConnection openConnection(final URL url) throws IOException {
                    if (logger.isTraceEnabled()) {
                        logger.trace("should open connection to {}", url.toExternalForm());
                    }

                    // URLConnection only has a protected ctor, so we need to go through the URL ctor with the matching handler
                    final URLConnection defaultUrlConnection =
                            new URL(protocol, url.getHost(), url.getPort(), url.getFile(), handlers.get(protocol))
                                    .openConnection();

                    if (!cache.urlShouldBeCached(url)) {
                        if (logger.isTraceEnabled()) {
                            logger.trace("not using cache for {}", url);
                        }
                        return defaultUrlConnection;
                    }

                    final Path cacheFile = cache.filenameForURL(url);
                    // now wrap the defaultUrlConnection
                    if (cache.isCached(url)) {
                        // if cached, always use http connection to prevent ssl handshake. As we are reading from the
                        // cache, this is enough
                        return new CachingHttpURLConnection(cache, (HttpURLConnection) defaultUrlConnection);
                    } else {
                        switch (proto) {
                            case PROTO_HTTP:
                                return new CachingHttpURLConnection(cache, (HttpURLConnection) defaultUrlConnection);
                            case PROTO_HTTPS:
                                return new CachingHttpsURLConnection(cache, (HttpsURLConnection) defaultUrlConnection);
                        }
                    }
                    throw new IOException("no matching handler");
                }

                @Override
                protected URLConnection openConnection(final URL u, final Proxy p) throws IOException {
                    if (logger.isTraceEnabled()) {
                        logger.trace("should open connection to {} via {}", u.toExternalForm(), p);
                    }
                    // URLConnection only has a protected ctor, so we need to go through the URL ctor with the
                    // matching handler to get a default implementation of the needed URLStreamHandler
                    final URLConnection defaultUrlConnection =
                            new URL(protocol, u.getHost(), u.getPort(), u.getFile(), handlers.get(protocol))
                                    .openConnection(p);

                    return defaultUrlConnection;
                }
            };
        }
        // return null to use default ones
        return null;
    }
1118639
@SuppressWarnings("unchecked")
    public <E> MessageHandler<? super E> getMessageHandler(Class<E> type) {
        return (MessageHandler<? super E>) receivedMessageHandlers.get(type);
    }
1302291
@SuppressWarnings("unchecked")
    @Override
    public void addStreamListener(final StreamListener<? extends Packet> listener) {

        try {
            final Method method = listener.getClass().getMethod("endStream", Stream.class);
            final ParameterizedType parameterizedType = (ParameterizedType) method.getGenericParameterTypes()[0];
            final Type[] parameterArgTypes = parameterizedType.getActualTypeArguments();

            // TODO: could actually be more.
            final Type parameterArgType = parameterArgTypes[0];
            final Class<?> parameterArgClass = (Class<?>) parameterArgType;
            if (parameterArgClass.equals(SipPacket.class)) {
                if (this.sipStreamHandler == null) {
                    this.sipStreamHandler = new SipStreamHandler(this.framerManager);
                }
                this.sipStreamHandler.addListener((StreamListener<SipPacket>) listener);
            } else if (parameterArgClass.equals(RtpPacket.class)) {
                if (this.rtpStreamHandler == null) {
                    this.rtpStreamHandler = new RtpStreamHandler(this.framerManager);
                }
                this.rtpStreamHandler.addListener((StreamListener<RtpPacket>) listener);
            }

        } catch (final ArrayIndexOutOfBoundsException e) {
            throw new RuntimeException("Unable to figure out the paramterized type", e);
        } catch (final SecurityException e) {
            throw new RuntimeException("Unable to access method information due to security constraints", e);
        } catch (final NoSuchMethodException e) {
            throw new RuntimeException("The startStream method doesn't exist. Signature changed?", e);
        } catch (final ClassCastException e) {
            // means that the user had not parameterized the StreamListener
            // interface, which means that we cannot actually detect streams.
            throw new IllegalArgumentException("The supplied listener has not been parameterized");
        }
    }
168775
@NotNull
  public <T> T getObject(@NotNull final String hash, @NotNull final StreamHandler<T> handler) throws IOException {
    return doWork(auth -> {
      final ObjectRes links = doRequest(auth, new MetaGet(), AuthHelper.join(auth.getHref(), PATH_OBJECTS + "/" + hash));
      if (links == null) {
        throw new FileNotFoundException();
      }
      return getObject(new Meta(hash, -1), links, handler);
    }, Operation.Download);
  }