curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [2/2] git commit: static version of runFromContext
Date Wed, 19 Feb 2014 08:45:40 GMT
static version of runFromContext


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a4ca2d5a
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a4ca2d5a
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a4ca2d5a

Branch: refs/heads/CURATOR-88
Commit: a4ca2d5a934a41a819d7143b85619a36bbc8842e
Parents: 4e3330a
Author: randgalt <randgalt@apache.org>
Authored: Wed Feb 19 14:15:32 2014 +0530
Committer: randgalt <randgalt@apache.org>
Committed: Wed Feb 19 14:15:32 2014 +0530

----------------------------------------------------------------------
 .../curator/x/rest/dropwizard/CuratorRestBundle.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/a4ca2d5a/curator-x-rest/src/main/java/org/apache/curator/x/rest/dropwizard/CuratorRestBundle.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/dropwizard/CuratorRestBundle.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/dropwizard/CuratorRestBundle.java
index 18a26d9..6ad93b3 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/dropwizard/CuratorRestBundle.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/dropwizard/CuratorRestBundle.java
@@ -43,11 +43,21 @@ public class CuratorRestBundle implements ConfiguredBundle<CuratorConfiguration>
     @Override
     public void run(CuratorConfiguration configuration, Environment environment) throws Exception
     {
-        CuratorRestContext context = newCuratorRestContext(configuration);
+        final CuratorRestContext context = newCuratorRestContext(configuration);
         runFromContext(environment, context);
+
+        LifeCycle.Listener listener = new AbstractLifeCycle.AbstractLifeCycleListener()
+        {
+            @Override
+            public void lifeCycleStopping(LifeCycle event)
+            {
+                closeCuratorClient(context.getClient());
+            }
+        };
+        environment.lifecycle().addLifeCycleListener(listener);
     }
 
-    public void runFromContext(Environment environment, final CuratorRestContext context)
+    public static void runFromContext(Environment environment, final CuratorRestContext context)
     {
         SingletonTypeInjectableProvider<Context, CuratorRestContext> injectable = new
SingletonTypeInjectableProvider<Context, CuratorRestContext>(CuratorRestContext.class,
context){};
         environment.jersey().register(injectable);
@@ -67,7 +77,6 @@ public class CuratorRestBundle implements ConfiguredBundle<CuratorConfiguration>
             @Override
             public void lifeCycleStopping(LifeCycle event)
             {
-                closeCuratorClient(context.getClient());
                 context.close();
             }
         };


Mime
View raw message