synchronized public void init(InetAddress bindAddress, Router router, DatagramProcessor datagramProcessor) throws InitializationException { this.router = router; this.datagramProcessor = datagramProcessor; try { // TODO: UPNP VIOLATION: The spec does not prohibit using the 1900 port here again, however, the // Netgear ReadyNAS miniDLNA implementation will no longer answer if it has to send search response // back via UDP unicast to port 1900... so we use an ephemeral port log.info("Creating bound socket (for datagram input/output) on: " + bindAddress); localAddress = new InetSocketAddress(bindAddress, 0); socket = new MulticastSocket(localAddress); socket.setTimeToLive(configuration.getTimeToLive()); socket.setReceiveBufferSize(262144); // Keep a backlog of incoming datagrams if we are not fast enough } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex); } }
synchronized public void init(InetAddress bindAddress, Router router) throws InitializationException { try { InetSocketAddress socketAddress = new InetSocketAddress(bindAddress, configuration.getListenPort()); server = HttpServer.create(socketAddress, configuration.getTcpConnectionBacklog()); server.createContext("/", new RequestHttpHandler(router)); log.info("Created server (for receiving TCP streams) on: " + server.getAddress()); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex.toString(), ex); } }
protected void discoverNetworkInterfaces() throws InitializationException { try { Enumeration<NetworkInterface> interfaceEnumeration = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface iface : Collections.list(interfaceEnumeration)) { //displayInterfaceInformation(iface); log.finer("Analyzing network interface: " + iface.getDisplayName()); if (isUsableNetworkInterface(iface)) { log.fine("Discovered usable network interface: " + iface.getDisplayName()); synchronized (networkInterfaces) { networkInterfaces.add(iface); } } else { log.finer("Ignoring non-usable network interface: " + iface.getDisplayName()); } } } catch (Exception ex) { throw new InitializationException("Could not not analyze local network interfaces: " + ex, ex); } }
throw new InitializationException( "This client does not work on Android. The design of HttpURLConnection is broken, we " + "can not add additional 'permitted' HTTP methods. Read the Cling manual." ); } catch (Throwable t) { throw new InitializationException( "Failed to set modified URLStreamHandlerFactory in this environment." + " Can't use bundled default client based on HTTPURLConnection, see manual."
throw new InitializationException("Could not not analyze local network interfaces: " + ex, ex);
synchronized public void init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor) throws InitializationException { this.router = router; this.networkAddressFactory = networkAddressFactory; this.datagramProcessor = datagramProcessor; this.multicastInterface = networkInterface; try { log.info("Creating wildcard socket (for receiving multicast datagrams) on port: " + configuration.getPort()); multicastAddress = new InetSocketAddress(configuration.getGroup(), configuration.getPort()); socket = new MulticastSocket(configuration.getPort()); socket.setReuseAddress(true); socket.setReceiveBufferSize(32768); // Keep a backlog of incoming datagrams if we are not fast enough log.info("Joining multicast group: " + multicastAddress + " on network interface: " + multicastInterface.getDisplayName()); socket.joinGroup(multicastAddress, multicastInterface); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex); } }
synchronized public void init(InetAddress bindAddress, final Router router) throws InitializationException { try { if (log.isLoggable(Level.FINE)) log.fine("Setting executor service on servlet container adapter"); getConfiguration().getServletContainerAdapter().setExecutorService( router.getConfiguration().getStreamServerExecutorService() ); if (log.isLoggable(Level.FINE)) log.fine("Adding connector: " + bindAddress + ":" + getConfiguration().getListenPort()); hostAddress = bindAddress.getHostAddress(); localPort = getConfiguration().getServletContainerAdapter().addConnector( hostAddress, getConfiguration().getListenPort() ); String contextPath = router.getConfiguration().getNamespace().getBasePath().getPath(); getConfiguration().getServletContainerAdapter().registerServlet(contextPath, createServlet(router)); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex.toString(), ex); } }
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException { this.configuration = configuration; log.info("Starting Jetty HttpClient..."); client = new HttpClient(); // Jetty client needs threads for its internal expiration routines, which we don't need but // can't disable, so let's abuse the request executor service for this client.setThreadPool( new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) { @Override protected void doStop() throws Exception { // Do nothing, don't shut down the Cling ExecutorService when Jetty stops! } } ); // These are some safety settings, we should never run into these timeouts as we // do our own expiration checking client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setMaxRetries(configuration.getRequestRetryCount()); try { client.start(); } catch (Exception ex) { throw new InitializationException( "Could not start Jetty HTTP client: " + ex, ex ); } }
synchronized public void init(InetAddress bindAddress, Router router, DatagramProcessor datagramProcessor) throws InitializationException { this.router = router; this.datagramProcessor = datagramProcessor; try { // TODO: UPNP VIOLATION: The spec does not prohibit using the 1900 port here again, however, the // Netgear ReadyNAS miniDLNA implementation will no longer answer if it has to send search response // back via UDP unicast to port 1900... so we use an ephemeral port log.info("Creating bound socket (for datagram input/output) on: " + bindAddress); localAddress = new InetSocketAddress(bindAddress, 0); socket = new MulticastSocket(localAddress); socket.setTimeToLive(configuration.getTimeToLive()); socket.setReceiveBufferSize(262144); // Keep a backlog of incoming datagrams if we are not fast enough } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex); } }
throw new InitializationException( "This client does not work on Android. The design of HttpURLConnection is broken, we " + "can not add additional 'permitted' HTTP methods. Read the Cling manual." ); } catch (Throwable t) { throw new InitializationException( "Failed to set modified URLStreamHandlerFactory in this environment." + " Can't use bundled default client based on HTTPURLConnection, see manual."
synchronized public void init(InetAddress bindAddress, Router router) throws InitializationException { try { InetSocketAddress socketAddress = new InetSocketAddress(bindAddress, configuration.getListenPort()); server = HttpServer.create(socketAddress, configuration.getTcpConnectionBacklog()); server.createContext("/", new RequestHttpHandler(router)); log.info("Created server (for receiving TCP streams) on: " + server.getAddress()); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex.toString(), ex); } }
protected void discoverNetworkInterfaces() throws InitializationException { try { Enumeration<NetworkInterface> interfaceEnumeration = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface iface : Collections.list(interfaceEnumeration)) { //displayInterfaceInformation(iface); log.finer("Analyzing network interface: " + iface.getDisplayName()); if (isUsableNetworkInterface(iface)) { log.fine("Discovered usable network interface: " + iface.getDisplayName()); synchronized (networkInterfaces) { networkInterfaces.add(iface); } } else { log.finer("Ignoring non-usable network interface: " + iface.getDisplayName()); } } } catch (Exception ex) { throw new InitializationException("Could not not analyze local network interfaces: " + ex, ex); } }
throw new InitializationException("Could not not analyze local network interfaces: " + ex, ex);
synchronized public void init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor) throws InitializationException { this.router = router; this.networkAddressFactory = networkAddressFactory; this.datagramProcessor = datagramProcessor; this.multicastInterface = networkInterface; try { log.info("Creating wildcard socket (for receiving multicast datagrams) on port: " + configuration.getPort()); multicastAddress = new InetSocketAddress(configuration.getGroup(), configuration.getPort()); socket = new MulticastSocket(configuration.getPort()); socket.setReuseAddress(true); socket.setReceiveBufferSize(32768); // Keep a backlog of incoming datagrams if we are not fast enough log.info("Joining multicast group: " + multicastAddress + " on network interface: " + multicastInterface.getDisplayName()); socket.joinGroup(multicastAddress, multicastInterface); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex); } }
synchronized public void init(InetAddress bindAddress, Router router) throws InitializationException { try { this.router = router; this.serverSocket = new ServerSocket( configuration.getListenPort(), configuration.getTcpConnectionBacklog(), bindAddress ); log.info("Created socket (for receiving TCP streams) on: " + serverSocket.getLocalSocketAddress()); this.globalParams .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, configuration.getDataWaitTimeoutSeconds() * 1000) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, configuration.getBufferSizeKilobytes() * 1024) .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, configuration.isStaleConnectionCheck()) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, configuration.isTcpNoDelay()); } catch (Exception ex) { throw new InitializationException("Could not initialize "+getClass().getSimpleName()+": " + ex.toString(), ex); } }
synchronized public void init(InetAddress bindAddress, final Router router) throws InitializationException { try { log.info("Setting executor service on servlet container adapter"); getConfiguration().getServletContainerAdapter().setExecutorService( router.getConfiguration().getStreamServerExecutorService() ); log.info("Adding connector: " + bindAddress + ":" + getConfiguration().getListenPort()); localPort = getConfiguration().getServletContainerAdapter().addConnector( bindAddress.getHostAddress(), getConfiguration().getListenPort() ); String contextPath = router.getConfiguration().getNamespace().getBasePath().getPath(); getConfiguration().getServletContainerAdapter().registerServlet(contextPath, createServlet(router)); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex.toString(), ex); } }
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException { this.configuration = configuration; log.info("Starting Jetty HttpClient..."); client = new HttpClient(); // Jetty client needs threads for its internal expiration routines, which we don't need but // can't disable, so let's abuse the request executor service for this client.setThreadPool( new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) { @Override protected void doStop() throws Exception { // Do nothing, don't shut down the Cling ExecutorService when Jetty stops! } } ); // These are some safety settings, we should never run into these timeouts as we // do our own expiration checking client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setMaxRetries(configuration.getRequestRetryCount()); try { client.start(); } catch (Exception ex) { throw new InitializationException( "Could not start Jetty HTTP client: " + ex, ex ); } }
synchronized public void init(InetAddress bindAddress, Router router, DatagramProcessor datagramProcessor) throws InitializationException { this.router = router; this.datagramProcessor = datagramProcessor; try { // TODO: UPNP VIOLATION: The spec does not prohibit using the 1900 port here again, however, the // Netgear ReadyNAS miniDLNA implementation will no longer answer if it has to send search response // back via UDP unicast to port 1900... so we use an ephemeral port log.info("Creating bound socket (for datagram input/output) on: " + bindAddress); localAddress = new InetSocketAddress(bindAddress, 0); socket = new MulticastSocket(localAddress); socket.setTimeToLive(configuration.getTimeToLive()); socket.setReceiveBufferSize(262144); // Keep a backlog of incoming datagrams if we are not fast enough } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex); } }
synchronized public void init(InetAddress bindAddress, Router router) throws InitializationException { try { InetSocketAddress socketAddress = new InetSocketAddress(bindAddress, configuration.getListenPort()); server = HttpServer.create(socketAddress, configuration.getTcpConnectionBacklog()); server.createContext("/", new RequestHttpHandler(router)); log.info("Created server (for receiving TCP streams) on: " + server.getAddress()); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex.toString(), ex); } }
synchronized public void init(InetAddress bindAddress, final Router router) throws InitializationException { try { if (log.isLoggable(Level.FINE)) log.fine("Setting executor service on servlet container adapter"); getConfiguration().getServletContainerAdapter().setExecutorService( router.getConfiguration().getStreamServerExecutorService() ); if (log.isLoggable(Level.FINE)) log.fine("Adding connector: " + bindAddress + ":" + getConfiguration().getListenPort()); hostAddress = bindAddress.getHostAddress(); localPort = getConfiguration().getServletContainerAdapter().addConnector( hostAddress, getConfiguration().getListenPort() ); String contextPath = router.getConfiguration().getNamespace().getBasePath().getPath(); getConfiguration().getServletContainerAdapter().registerServlet(contextPath, createServlet(router)); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex.toString(), ex); } }