zhengyangyong commented on a change in pull request #210: [SCB-244] enable
servicecomb and add demo
URL:
https://github.com/apache/incubator-servicecomb-saga/pull/210#discussion_r196996227
##########
File path:
omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaConsumerHandler.java
##########
@@ -22,30 +22,38 @@
import java.lang.invoke.MethodHandles;
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.saga.omega.context.OmegaContext;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.apache.servicecomb.core.Handler;
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import com.google.common.annotations.VisibleForTesting;
public class SagaConsumerHandler implements Handler {
private static final Logger LOG =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final OmegaContext omegaContext;
- public SagaConsumerHandler(@Autowired(required=false) OmegaContext
omegaContext) {
- this.omegaContext = omegaContext;
- if (omegaContext == null) {
- LOG.info("The OmegaContext is not injected, The SagaConsumerHandler is
disabled.");
+ private OmegaContext omegaContext;
+
+ public SagaConsumerHandler() {
+ try {
+ omegaContext = BeanUtils.getBean("omegaContext");
+ } catch (NullPointerException npe) {
+ LOG.warn("The OmegaContext is not injected, The SagaConsumerHandler is
disabled.");
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services