[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497439#comment-16497439
 ] 

ASF GitHub Bot commented on SCB-617:
------------------------------------

wujimin commented on a change in pull request #731: [SCB-617] Graceful shutdown 
with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192278176
 
 

 ##########
 File path: 
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerProviderManager.java
 ##########
 @@ -17,39 +17,72 @@
 
 package org.apache.servicecomb.core.provider.producer;
 
+import java.io.Closeable;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
 
 import javax.inject.Inject;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.core.ProducerProvider;
 import org.apache.servicecomb.core.definition.MicroserviceMeta;
 import org.apache.servicecomb.core.definition.MicroserviceMetaManager;
+import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.core.definition.SchemaMeta;
 import org.apache.servicecomb.core.definition.SchemaUtils;
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ProducerProviderManager {
+public class ProducerProviderManager implements BootListener {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProducerProviderManager.class);
+
   @Autowired(required = false)
   private List<ProducerProvider> producerProviderList = 
Collections.emptyList();
 
   @Inject
   private MicroserviceMetaManager microserviceMetaManager;
 
+  private MicroserviceMeta microserviceMeta;
+
   public void init() throws Exception {
     for (ProducerProvider provider : producerProviderList) {
       provider.init();
     }
 
     Microservice microservice = RegistryUtils.getMicroservice();
-    MicroserviceMeta microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
+    microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
     for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
       String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
       microservice.addSchema(schemaMeta.getSchemaId(), content);
     }
   }
+
+  @Override
+  public void onBootEvent(BootEvent event) {
+    if (!EventType.AFTER_CLOSE.equals(event.getEventType())) {
+      return;
+    }
+
+    for (OperationMeta operationMeta : microserviceMeta.getOperations()) {
+      if (ExecutorService.class.isInstance(operationMeta.getExecutor())) {
 
 Review comment:
   1.ExecutorService is not closeable
   2.if someone want to do this, it's not our duty to invoke close.

----------------------------------------------------------------
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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> ----------------------------------------
>
>                 Key: SCB-617
>                 URL: https://issues.apache.org/jira/browse/SCB-617
>             Project: Apache ServiceComb
>          Issue Type: Bug
>          Components: Java-Chassis
>            Reporter: wujimin
>            Assignee: wujimin
>            Priority: Major
>             Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to