@Test public void testStartup() { RpcStartupHookProvider provider = new RpcStartupHookProvider(); provider.onStartup(); Map<String, Handler> servicesMap = provider.serviceMap; Assert.assertTrue(servicesMap.size() > 0); System.out.println("serviceMap size = " + servicesMap.size()); }
@Override public void onStartup() { System.out.println("Handler scanning package = " + config.getHandlerPackage()); List<String> handlers; try (ScanResult scanResult = new ClassGraph() .whitelistPackages(config.getHandlerPackage()) .enableAllInfo() .scan()) { handlers = scanResult .getClassesWithAnnotation(ServiceHandler.class.getName()) .getNames(); } System.out.println("RpcStartupHookProvider: handlers size " + handlers.size()); for(String className: handlers) { try { Class handler = Class.forName(className); ServiceHandler a = (ServiceHandler)handler.getAnnotation(ServiceHandler.class); serviceMap.put(a.id(), (Handler)handler.getConstructor().newInstance()); System.out.println("RpcStartupHookProvider add id " + a.id() + " map to " + className); if(config.isRegisterService()) Server.serviceIds.add(a.id().replace('/', '.')); } catch (Exception e) { e.printStackTrace(); } } pathResourceProviders = SingletonServiceFactory.getBeans(PathResourceProvider.class); predicatedHandlersProviders = SingletonServiceFactory.getBeans(PredicatedHandlersProvider.class); }
RpcStartupHookProvider implements StartupHookProvider { @Override public void onStartup() { System.out.println("Handler scanning package = " + config.getHandlerPackage()); List<String> handlers; try (ScanResult scanResult = new ClassGraph() .whitelistPackages(config.getHandlerPackage()) .enableAllInfo() .scan()) { handlers = scanResult .getClassesWithAnnotation(ServiceHandler.class.getName()) .getNames(); } System.out.println("RpcStartupHookProvider: handlers size " + handlers.size()); for(String className: handlers) { try { Class handler = Class.forName(className); ServiceHandler a = (ServiceHandler)handler.getAnnotation(ServiceHandler.class); serviceMap.put(a.id(), (Handler)handler.getConstructor().newInstance()); System.out.println("RpcStartupHookProvider add id " + a.id() + " map to " + className); if(config.isRegisterService()) Server.serviceIds.add(a.id().replace('/', '.')); } catch (Exception e) { e.printStackTrace(); } } pathResourceProviders = SingletonServiceFactory.getBeans(PathResourceProvider.class); predicatedHandlersProviders = SingletonServiceFactory.getBeans(PredicatedHandlersProvider.class); } }
RpcStartupHookProvider implements StartupHookProvider { @Override public void onStartup() { System.out.println("Handler scanning package = " + config.getHandlerPackage()); List<String> handlers; try (ScanResult scanResult = new ClassGraph() .whitelistPackages(config.getHandlerPackage()) .enableAllInfo() .scan()) { handlers = scanResult .getClassesWithAnnotation(ServiceHandler.class.getName()) .getNames(); } System.out.println("RpcStartupHookProvider: handlers size " + handlers.size()); for(String className: handlers) { try { Class handler = Class.forName(className); ServiceHandler a = (ServiceHandler)handler.getAnnotation(ServiceHandler.class); serviceMap.put(a.id(), (Handler)handler.getConstructor().newInstance()); System.out.println("RpcStartupHookProvider add id " + a.id() + " map to " + className); if(config.isRegisterService()) Server.serviceIds.add(a.id().replace('/', '.')); } catch (Exception e) { e.printStackTrace(); } } pathResourceProviders = SingletonServiceFactory.getBeans(PathResourceProvider.class); predicatedHandlersProviders = SingletonServiceFactory.getBeans(PredicatedHandlersProvider.class); }  }
RpcStartupHookProvider implements StartupHookProvider { @Override public void onStartup() { System.out.println("Handler scanning package = " + config.getHandlerPackage()); List<String> handlers; try (ScanResult scanResult = new ClassGraph() .whitelistPackages(config.getHandlerPackage()) .enableAllInfo() .scan()) { handlers = scanResult .getClassesWithAnnotation(ServiceHandler.class.getName()) .getNames(); } System.out.println("RpcStartupHookProvider: handlers size " + handlers.size()); for(String className: handlers) { try { Class handler = Class.forName(className); ServiceHandler a = (ServiceHandler)handler.getAnnotation(ServiceHandler.class); serviceMap.put(a.id(), (Handler)handler.getConstructor().newInstance()); System.out.println("RpcStartupHookProvider add id " + a.id() + " map to " + className); if(config.isRegisterService()) Server.serviceIds.add(a.id().replace('/', '.')); } catch (Exception e) { e.printStackTrace(); } } pathResourceProviders = SingletonServiceFactory.getBeans(PathResourceProvider.class); predicatedHandlersProviders = SingletonServiceFactory.getBeans(PredicatedHandlersProvider.class); }  @Override void onStartup(); }
RpcStartupHookProvider implements StartupHookProvider { @Override public void onStartup() { System.out.println("Handler scanning package = " + config.getHandlerPackage()); List<String> handlers; try (ScanResult scanResult = new ClassGraph() .whitelistPackages(config.getHandlerPackage()) .enableAllInfo() .scan()) { handlers = scanResult .getClassesWithAnnotation(ServiceHandler.class.getName()) .getNames(); } System.out.println("RpcStartupHookProvider: handlers size " + handlers.size()); for(String className: handlers) { try { Class handler = Class.forName(className); ServiceHandler a = (ServiceHandler)handler.getAnnotation(ServiceHandler.class); serviceMap.put(a.id(), (Handler)handler.getConstructor().newInstance()); System.out.println("RpcStartupHookProvider add id " + a.id() + " map to " + className); if(config.isRegisterService()) Server.serviceIds.add(a.id().replace('/', '.')); } catch (Exception e) { e.printStackTrace(); } } pathResourceProviders = SingletonServiceFactory.getBeans(PathResourceProvider.class); predicatedHandlersProviders = SingletonServiceFactory.getBeans(PredicatedHandlersProvider.class); }  @Override void onStartup();  }