當前位置: 首頁>>代碼示例>>Java>>正文


Java Router類代碼示例

本文整理匯總了Java中org.fourthline.cling.transport.Router的典型用法代碼示例。如果您正苦於以下問題:Java Router類的具體用法?Java Router怎麽用?Java Router使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Router類屬於org.fourthline.cling.transport包,在下文中一共展示了Router類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
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);
    }
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:21,代碼來源:AsyncServletStreamServerImpl.java

示例2: createServlet

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
protected Servlet createServlet(final Router router) {
    return new HttpServlet() {
        @Override
        protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            if (log.isLoggable(Level.FINE))
                log.fine(
                    "Handling Servlet request asynchronously: " + req
                );

            AsyncContext async = req.startAsync();
            async.setTimeout(getConfiguration().getAsyncTimeoutSeconds()*1000);

            AsyncServletUpnpStream stream =
                new AsyncServletUpnpStream(router.getProtocolFactory(), async, req) {
                    @Override
                    protected Connection createConnection() {
                        return new AsyncServletConnection(getRequest());
                    }
                };

            router.received(stream);
        }
    };
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:25,代碼來源:AsyncServletStreamServerImpl.java

示例3: init

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
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);
        }
    }
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:20,代碼來源:DatagramIOImpl.java

示例4: init

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
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);
        }

    }
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:27,代碼來源:StreamServerImpl.java

示例5: init

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
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);
    }
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:27,代碼來源:MulticastReceiverImpl.java

示例6: makeUpnpService

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
private UpnpService makeUpnpService() {
    return new UpnpServiceImpl(createConfiguration()) {
        @Override protected Router createRouter(ProtocolFactory protocolFactory, Registry registry) {
            return new AndroidRouter(getConfiguration(), protocolFactory,  UpnpServiceService.this);
        }
        @Override public synchronized void shutdown() {
            // First have to remove the receiver, so Android won't complain about it leaking
            // when the main UI thread exits.
            ((AndroidRouter)getRouter()).unregisterBroadcastReceiver();

            // Now we can concurrently run the Cling shutdown code, without occupying the
            // Android main UI thread. This will complete probably after the main UI thread
            // is done.
            super.shutdown(true);
        }
    };
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:18,代碼來源:UpnpServiceService.java

示例7: onCreate

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
/**
 * Starts the UPnP service.
 */
@Override
public void onCreate() {
    super.onCreate();

    upnpService = new UpnpServiceImpl(createConfiguration()) {

        @Override
        protected Router createRouter(ProtocolFactory protocolFactory, Registry registry) {
            return ArchosUpnpServiceImpl.this.createRouter(
                    getConfiguration(),
                    protocolFactory,
                    ArchosUpnpServiceImpl.this
            );
        }

        @Override
        public synchronized void shutdown() {
            // First have to remove the receiver, so Android won't complain about it leaking
            // when the main UI thread exits.
            ((AndroidRouter)getRouter()).unregisterBroadcastReceiver();

            // Now we can concurrently run the Cling shutdown code, without occupying the
            // Android main UI thread. This will complete probably after the main UI thread
            // is done.
            super.shutdown(true);
        }
    };
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:32,代碼來源:ArchosUpnpServiceImpl.java

示例8: init

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
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);
    }
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:14,代碼來源:StreamServerImpl.java

示例9: onCreate

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
/**
 * Starts the UPnP service.
 */
@Override
public void onCreate() {
    super.onCreate();

    upnpService = new UpnpServiceImpl(createConfiguration()) {

        @Override
        protected Router createRouter(ProtocolFactory protocolFactory, Registry registry) {
            return AndroidUpnpServiceImpl.this.createRouter(
                getConfiguration(),
                protocolFactory,
                AndroidUpnpServiceImpl.this
            );
        }

        @Override
        public synchronized void shutdown() {
            // First have to remove the receiver, so Android won't complain about it leaking
            // when the main UI thread exits.
            ((AndroidRouter)getRouter()).unregisterBroadcastReceiver();

            // Now we can concurrently run the Cling shutdown code, without occupying the
            // Android main UI thread. This will complete probably after the main UI thread
            // is done.
            super.shutdown(true);
        }
    };
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:32,代碼來源:AndroidUpnpServiceImpl.java

示例10: getRouter

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
@Override
public Router getRouter() {
    return routerInstance.get();
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:5,代碼來源:ManagedUpnpService.java

示例11: RequestHttpHandler

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
public RequestHttpHandler(Router router) {
    this.router = router;
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:4,代碼來源:StreamServerImpl.java

示例12: createRouter

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
protected Router createRouter(ProtocolFactory protocolFactory, Registry registry) {
    return new RouterImpl(getConfiguration(), protocolFactory);
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:4,代碼來源:UpnpServiceImpl.java

示例13: getRouter

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
public Router getRouter() {
    return router;
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:4,代碼來源:UpnpServiceImpl.java

示例14: onOptionsItemSelected

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case 0:
            if (upnpService == null)
                break;
            Toast.makeText(this, R.string.searchingLAN, Toast.LENGTH_SHORT).show();
            upnpService.getRegistry().removeAllRemoteDevices();
            upnpService.getControlPoint().search();
            break;
        // DOC:OPTIONAL
        case 1:
            if (upnpService != null) {
                Router router = upnpService.get().getRouter();
                try {
                    if (router.isEnabled()) {
                        Toast.makeText(this, R.string.disablingRouter, Toast.LENGTH_SHORT)
                                .show();
                        router.disable();
                    } else {
                        Toast.makeText(this, R.string.enablingRouter, Toast.LENGTH_SHORT)
                                .show();
                        router.enable();
                    }
                } catch (RouterException ex) {
                    Toast.makeText(this,
                            getText(R.string.errorSwitchingRouter) + ex.toString(),
                            Toast.LENGTH_LONG).show();
                    ex.printStackTrace(System.err);
                }
            }
            break;
        case 2:
            Logger logger = Logger.getLogger("org.fourthline.cling");
            if (logger.getLevel() != null && !logger.getLevel().equals(Level.INFO)) {
                Toast.makeText(this, R.string.disablingDebugLogging, Toast.LENGTH_SHORT).show();
                logger.setLevel(Level.INFO);
            } else {
                Toast.makeText(this, R.string.enablingDebugLogging, Toast.LENGTH_SHORT).show();
                logger.setLevel(Level.FINEST);
            }
            break;
    // DOC:OPTIONAL
    }
    return false;
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:47,代碼來源:BrowserActivity.java

示例15: init

import org.fourthline.cling.transport.Router; //導入依賴的package包/類
/**
 * Configures the service and starts any listening sockets.
 *
 * @param bindAddress The address to bind any sockets on.
 * @param router The router which handles the incoming {@link org.fourthline.cling.transport.spi.UpnpStream}.
 * @throws InitializationException If the service could not be initialized or started.
 */
public void init(InetAddress bindAddress, Router router) throws InitializationException;
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:9,代碼來源:StreamServer.java


注:本文中的org.fourthline.cling.transport.Router類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。