spring启动后保存某个接口的子类bean[to be pretty]

XXX implements implements InitializingBean{

@Override
public void afterPropertiesSet() throws Exception {

private static Map nameAndSubClassMap = new HashMap<>();

/**
 * getBeansOfType 获取bean(包括其子类实例)
 */
Map machineMap = SpringContextUtil.getApplicationContext().getBeansOfType(Interf.class);
machineMap.values().forEach(iInterf -> {
    stateMachineMap.put(iInterf.getClassName, iInterf);
});

}

你可能感兴趣的:(spring)