@Test public void callRemoteService_isCorrect() throws Exception { { final IService service1 = PhantomServiceManager.getService("remote_service_1"); Assert.assertEquals("remote_method_1", service1.call("remote_method_1")); String message1 = "hahaha"; Assert.assertEquals("remote_method_2 reply " + message1, service1.call("remote_method_2", message1)); } { final IService service2 = PhantomServiceManager.getService("remote_service_2"); Assert.assertEquals("remote_method_1", service2.call("remote_method_1")); String message2 = "hahaha"; Assert.assertEquals("remote_method_2 reply " + message2, service2.call("remote_method_2", message2)); } }
public static IService getService(String category, String name) { synchronized (CATEGORY_SERVICES_MAP) { final HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (services == null) { return null; } return new ServiceModule(services.get(name)); } }
PhantomServiceManager { public static IService getService(String category, String name) { synchronized (CATEGORY_SERVICES_MAP) { final HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (services == null) { return null; } return new ServiceModule(services.get(name)); } } }
PhantomServiceManager { public static IService getService(String category, String name) { synchronized (CATEGORY_SERVICES_MAP) { final HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (services == null) { return null; } return new ServiceModule(services.get(name)); } } private  PhantomServiceManager(); }
PhantomServiceManager { public static IService getService(String category, String name) { synchronized (CATEGORY_SERVICES_MAP) { final HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (services == null) { return null; } return new ServiceModule(services.get(name)); } } private  PhantomServiceManager(); static synchronized void init(String hostPackage,
            String hostVersionName,
            int hostVersionCode,
            String phantomVersionName,
            int phantomVersionCode); static String getHostPackage(); static String getHostVersionName(); static int getHostVersionCode(); static String getPhantomVersionName(); static int getPhantomVersionCode(); static boolean registerService(String category, String name, Object service); static boolean registerService(String name, Object service); static boolean registerService(Object service); static void unregisterService(String category); static void unregisterAllService(); static List<IService> getServices(String category); static IService getService(String category, String name); static IService getService(String name); static T getService(String name, Class<T> type); static boolean hasService(String name); static T asInterface(IService service, Class<T> type); static boolean hasService(String category, String name); }
PhantomServiceManager { public static IService getService(String category, String name) { synchronized (CATEGORY_SERVICES_MAP) { final HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (services == null) { return null; } return new ServiceModule(services.get(name)); } } private  PhantomServiceManager(); static synchronized void init(String hostPackage,
            String hostVersionName,
            int hostVersionCode,
            String phantomVersionName,
            int phantomVersionCode); static String getHostPackage(); static String getHostVersionName(); static int getHostVersionCode(); static String getPhantomVersionName(); static int getPhantomVersionCode(); static boolean registerService(String category, String name, Object service); static boolean registerService(String name, Object service); static boolean registerService(Object service); static void unregisterService(String category); static void unregisterAllService(); static List<IService> getServices(String category); static IService getService(String category, String name); static IService getService(String name); static T getService(String name, Class<T> type); static boolean hasService(String name); static T asInterface(IService service, Class<T> type); static boolean hasService(String category, String name);  }