@Test public void registerService_shouldThrowException() throws Exception { mExceptions.expect(IllegalArgumentException.class); mExceptions.expectMessage("service class must has PhantomService annotation"); PhantomServiceManager.registerService(new RemoteServiceMissingAnnotation()); }
public static boolean registerService(String category, String name, Object service) { if (null == category || 0 == category.length() || null == name || 0 == name.length() || null == service) { return false; } synchronized (CATEGORY_SERVICES_MAP) { HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (null == services) { services = new HashMap<>(); CATEGORY_SERVICES_MAP.put(category, services); } Object hasService = services.get(name); if (null != hasService && !hasService.getClass().getName().equals(service.getClass().getName())) { return false; } services.put(name, service); } return true; }
PhantomServiceManager { public static boolean registerService(String category, String name, Object service) { if (null == category || 0 == category.length() || null == name || 0 == name.length() || null == service) { return false; } synchronized (CATEGORY_SERVICES_MAP) { HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (null == services) { services = new HashMap<>(); CATEGORY_SERVICES_MAP.put(category, services); } Object hasService = services.get(name); if (null != hasService && !hasService.getClass().getName().equals(service.getClass().getName())) { return false; } services.put(name, service); } return true; } }
PhantomServiceManager { public static boolean registerService(String category, String name, Object service) { if (null == category || 0 == category.length() || null == name || 0 == name.length() || null == service) { return false; } synchronized (CATEGORY_SERVICES_MAP) { HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (null == services) { services = new HashMap<>(); CATEGORY_SERVICES_MAP.put(category, services); } Object hasService = services.get(name); if (null != hasService && !hasService.getClass().getName().equals(service.getClass().getName())) { return false; } services.put(name, service); } return true; } private  PhantomServiceManager(); }
PhantomServiceManager { public static boolean registerService(String category, String name, Object service) { if (null == category || 0 == category.length() || null == name || 0 == name.length() || null == service) { return false; } synchronized (CATEGORY_SERVICES_MAP) { HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (null == services) { services = new HashMap<>(); CATEGORY_SERVICES_MAP.put(category, services); } Object hasService = services.get(name); if (null != hasService && !hasService.getClass().getName().equals(service.getClass().getName())) { return false; } services.put(name, service); } return true; } 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 boolean registerService(String category, String name, Object service) { if (null == category || 0 == category.length() || null == name || 0 == name.length() || null == service) { return false; } synchronized (CATEGORY_SERVICES_MAP) { HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (null == services) { services = new HashMap<>(); CATEGORY_SERVICES_MAP.put(category, services); } Object hasService = services.get(name); if (null != hasService && !hasService.getClass().getName().equals(service.getClass().getName())) { return false; } services.put(name, service); } return true; } 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);  }