Java Code Examples for gnu.trove.map.hash.TIntObjectHashMap#forEachEntry()

The following examples show how to use gnu.trove.map.hash.TIntObjectHashMap#forEachEntry() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestService.java    From PeonyFramwork with Apache License 2.0 6 votes vote down vote up
public void init(){
    TIntObjectHashMap<Class<?>> requestHandlerClassMap = ServiceHelper.getRequestHandlerMap();
    requestHandlerClassMap.forEachEntry(new TIntObjectProcedure<Class<?>>(){
        @Override
        public boolean execute(int i, Class<?> aClass) {
            handlerMap.put(i, (RequestHandler)BeanHelper.getServiceBean(aClass));
            timeMap.put(i,new ConcurrentLinkedDeque<>());
            return true;
        }
    });
    // 命令
    List<Class<?>> cmdClasses = ClassHelper.getClassListEndWith("com.myFruit.cmd","Cmd");
    for (Class<?> cls:cmdClasses) {

        Field[] fields = cls.getFields();
        for(Field field : fields){
            try {
                opcodeNames.put(field.getInt(null),field.getName());
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }

}
 
Example 2
Source File: NetEventService.java    From PeonyFramwork with Apache License 2.0 5 votes vote down vote up
public void init() {
    handlerMap = new HashMap<>();
    TIntObjectHashMap<Class<?>> netEventHandlerClassMap = ServiceHelper.getNetEventListenerHandlerClassMap();
    netEventHandlerClassMap.forEachEntry((i, aClass) -> {
        handlerMap.put(i, (NetEventListenerHandler) BeanHelper.getServiceBean(aClass));
        return true;
    });

    selfAddress = getServerKey(Util.getHostAddress(), Server.getEngineConfigure().getNetEventPort());
    System.err.println("selfAddress " + selfAddress);

}