/** * (non-Javadoc) * * @see Service#start() */ @Override public void start() { try { /* * Validate required resources */ // validateInjectedResources(); if (disableServerFlag) { System.out.println( "WsCommunicationsServerCloudPluginRoot - Local Server is Disable, no started"); return; } System.out.println("WsCommunicationsServerCloudPluginRoot - Starting plugin"); /* * Get all network interfaces of the device */ Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface networkInterface = interfaces.nextElement(); /** If not a loopback interfaces (127.0.0.1) and is active */ if (!networkInterface.isLoopback() && networkInterface.isUp()) { /* * Get his inet addresses */ Enumeration<InetAddress> addresses = networkInterface.getInetAddresses(); /* * Create a cloud service for each ip */ for (InetAddress address : Collections.list(addresses)) { /** look only for ipv4 addresses */ if (address instanceof Inet6Address) { continue; } WebSocketImpl.DEBUG = false; InetSocketAddress inetSocketAddress = new InetSocketAddress(address, WsCommunicationCloudServer.DEFAULT_PORT); wsCommunicationCloudServer = new WsCommunicationCloudServer(inetSocketAddress); wsCommunicationCloudServer.registerFermatPacketProcessor( new ComponentRegistrationRequestPacketProcessor()); wsCommunicationCloudServer.registerFermatPacketProcessor( new ComponentConnectionRequestPacketProcessor()); wsCommunicationCloudServer.registerFermatPacketProcessor( new DiscoveryComponentConnectionRequestPacketProcessor()); wsCommunicationCloudServer.registerFermatPacketProcessor( new RequestListComponentRegisterPacketProcessor()); wsCommunicationCloudServer.start(); /* * Start the ping agent */ wsCommunicationsCloudServerPingAgent = new WsCommunicationsCloudServerPingAgent(wsCommunicationCloudServer); wsCommunicationsCloudServerPingAgent.start(); System.out.println( "New CommunicationChannelAddress linked on " + networkInterface.getName()); System.out.println("Host = " + inetSocketAddress.getHostString()); System.out.println("Port = " + inetSocketAddress.getPort()); System.out.println( "Communication Service Manager on " + networkInterface.getName() + " started."); break; } } } /* * Create and start the restlet server */ RestletCommunicationCloudServer rlCommunicationCloudServer = new RestletCommunicationCloudServer(wsCommunicationCloudServer); rlCommunicationCloudServer.start(); /* * Start the socket to handle the request of Component Registered List */ // SocketServerInitialization socketServerInitialization =new // SocketServerInitialization(wsCommunicationCloudServer); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } /* * Set the new status of the service */ this.serviceStatus = ServiceStatus.STARTED; }