package com.ctrip.hermes.rest.common;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.ctrip.hermes.core.utils.PlexusComponentLocator;
import com.ctrip.hermes.rest.service.SubscriptionRegisterService;
import com.yammer.metrics.Metrics;

public class GatewayListener implements ServletContextListener {

	private SubscriptionRegisterService subsribeRegistry = PlexusComponentLocator
	      .lookup(SubscriptionRegisterService.class);

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		subsribeRegistry.start();
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		subsribeRegistry.stop();

		Metrics.defaultRegistry().shutdown();
		
	}

}

@@ -32,16 +32,66 @@
 ommon;%0A%0A
+import java.io.File;%0Aimport java.io.IOException;%0A%0A
 import j
@@ -124,16 +124,16 @@
 tEvent;%0A
-
 import j
@@ -295,16 +295,45 @@
 ervice;%0A
+import com.dianping.cat.Cat;%0A
 import c
@@ -560,32 +560,32 @@
 s);%0A%0A%09@Override%0A
-
 %09public void con
@@ -619,32 +619,423 @@
 extEvent sce) %7B%0A
+%09%09File catConfigFile = new File(%22/opt/ctrip/data/cat/client.xml%22);%0A%09%09if (!catConfigFile.isFile() %7C%7C !catConfigFile.canRead()) %7B%0A%09%09%09try %7B%0A%09%09%09%09throw new IllegalStateException(%0A%09%09%09%09%09%09  String.format(%22Cat config file %25s not found%22, catConfigFile.getCanonicalPath()));%0A%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09// todo: handle exception%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09Cat.initialize(catConfigFile);%0A%0A
 %09%09subsribeRegist

add cat.xml into rest