You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/10/28 02:43:01 UTC

[GitHub] [dubbo] wangzhenxyz1 opened a new issue #9150: Filter SPI Auto Load

wangzhenxyz1 opened a new issue #9150:
URL: https://github.com/apache/dubbo/issues/9150


   ExtensionLoader can not inject spring bean by type.
   ex: when I customize Filter, I wanna inject spring boot Environment bean, then will delegate SpringExtensionFactory lookup with getOptionalBean,  but getOptionalBean only can inject by type when parameter beanName is null.
   
   ### Environment
   
   * Dubbo version: 2.7.8
   * Operating System version: MacOS 11.6
   * Java version: 1.8
   
   ### Expected Behavior
   ExtensionLoader can inject spring bean by type.
   
   
   ### Actual Behavior
   
   ExtensionLoader can not inject spring bean by type.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 commented on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 commented on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-957241886


   > Pls try Dubbo 3.x
   Dubbo 3.x doesn't solve this bug!
   `    private <T> T getOptionalBean(ListableBeanFactory beanFactory, String name, Class<T> type) {
           if (StringUtils.isEmpty(name)) {
               String[] beanNamesForType = beanFactory.getBeanNamesForType(type, true, false);
               if (beanNamesForType != null) {
                   if (beanNamesForType.length == 1) {
                       return beanFactory.getBean(beanNamesForType[0], type);
                   } else if (beanNamesForType.length > 1) {
                       throw new IllegalStateException("Expect single but found " + beanNamesForType.length + " beans in spring context: " +
                           Arrays.toString(beanNamesForType));
                   }
               }
           } else {
               if (beanFactory.containsBean(name)) {
                   return beanFactory.getBean(name, type);
               }
           }
           return null;
       }`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] kylixs commented on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
kylixs commented on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-955700247


   Pls try Dubbo 3.x


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 closed issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 closed issue #9150:
URL: https://github.com/apache/dubbo/issues/9150


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 edited a comment on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 edited a comment on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-957241886






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 commented on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 commented on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-957241886


   > Pls try Dubbo 3.x
   Dubbo 3.x doesn't solve this bug!
   `    private <T> T getOptionalBean(ListableBeanFactory beanFactory, String name, Class<T> type) {
           if (StringUtils.isEmpty(name)) {
               String[] beanNamesForType = beanFactory.getBeanNamesForType(type, true, false);
               if (beanNamesForType != null) {
                   if (beanNamesForType.length == 1) {
                       return beanFactory.getBean(beanNamesForType[0], type);
                   } else if (beanNamesForType.length > 1) {
                       throw new IllegalStateException("Expect single but found " + beanNamesForType.length + " beans in spring context: " +
                           Arrays.toString(beanNamesForType));
                   }
               }
           } else {
               if (beanFactory.containsBean(name)) {
                   return beanFactory.getBean(name, type);
               }
           }
           return null;
       }`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 edited a comment on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 edited a comment on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-957241886


   > Pls try Dubbo 3.x
   Dubbo 3.x doesn't solve this bug!
   
   
   ```
   private <T> T getOptionalBean(ListableBeanFactory beanFactory, String name, Class<T> type) {
           if (StringUtils.isEmpty(name)) {
               String[] beanNamesForType = beanFactory.getBeanNamesForType(type, true, false);
               if (beanNamesForType != null) {
                   if (beanNamesForType.length == 1) {
                       return beanFactory.getBean(beanNamesForType[0], type);
                   } else if (beanNamesForType.length > 1) {
                       throw new IllegalStateException("Expect single but found " + beanNamesForType.length + " beans in spring context: " +
                           Arrays.toString(beanNamesForType));
                   }
               }
           } else {
               if (beanFactory.containsBean(name)) {
                   return beanFactory.getBean(name, type);
               }
           }
           return null;
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 commented on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 commented on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-955873921


   > Pls try Dubbo 3.x
   
   Right Now, we can not upgrade to codebase v3.x..
   2.8.x remains the majority users.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 edited a comment on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 edited a comment on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-957241886






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 edited a comment on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 edited a comment on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-957241886


   > Pls try Dubbo 3.x
   Dubbo 3.x doesn't solve this bug!
   `    
   private <T> T getOptionalBean(ListableBeanFactory beanFactory, String name, Class<T> type) {
           if (StringUtils.isEmpty(name)) {
               String[] beanNamesForType = beanFactory.getBeanNamesForType(type, true, false);
               if (beanNamesForType != null) {
                   if (beanNamesForType.length == 1) {
                       return beanFactory.getBean(beanNamesForType[0], type);
                   } else if (beanNamesForType.length > 1) {
                       throw new IllegalStateException("Expect single but found " + beanNamesForType.length + " beans in spring context: " +
                           Arrays.toString(beanNamesForType));
                   }
               }
           } else {
               if (beanFactory.containsBean(name)) {
                   return beanFactory.getBean(name, type);
               }
           }
           return null;
       }
   `


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 commented on issue #9150: Filter SPI Auto Load

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 commented on issue #9150:
URL: https://github.com/apache/dubbo/issues/9150#issuecomment-957241886


   > Pls try Dubbo 3.x
   Dubbo 3.x doesn't solve this bug!
   `    private <T> T getOptionalBean(ListableBeanFactory beanFactory, String name, Class<T> type) {
           if (StringUtils.isEmpty(name)) {
               String[] beanNamesForType = beanFactory.getBeanNamesForType(type, true, false);
               if (beanNamesForType != null) {
                   if (beanNamesForType.length == 1) {
                       return beanFactory.getBean(beanNamesForType[0], type);
                   } else if (beanNamesForType.length > 1) {
                       throw new IllegalStateException("Expect single but found " + beanNamesForType.length + " beans in spring context: " +
                           Arrays.toString(beanNamesForType));
                   }
               }
           } else {
               if (beanFactory.containsBean(name)) {
                   return beanFactory.getBean(name, type);
               }
           }
           return null;
       }`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org