JAMES-1842: Introduce GuiceJamesServer interface
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/fdb400d4 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/fdb400d4 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/fdb400d4 Branch: refs/heads/master Commit: fdb400d41c9add031b0af1ff17b21ceba2db0095 Parents: 932f16c Author: Antoine Duprat <[email protected]> Authored: Wed Nov 16 09:59:04 2016 +0100 Committer: Quynh Nguyen <[email protected]> Committed: Fri Nov 18 09:33:20 2016 +0700 ---------------------------------------------------------------------- .../java/org/apache/james/GuiceJamesServer.java | 30 ++++++++++++++++++++ .../org/apache/james/GuiceJamesServerImpl.java | 5 +++- 2 files changed, 34 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/fdb400d4/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java new file mode 100644 index 0000000..d77521b --- /dev/null +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java @@ -0,0 +1,30 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james; + +import org.apache.james.utils.GuiceServerProbe; + +public interface GuiceJamesServer { + + void start() throws Exception; + + void stop(); + + GuiceServerProbe serverProbe(); +} http://git-wip-us.apache.org/repos/asf/james-project/blob/fdb400d4/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServerImpl.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServerImpl.java b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServerImpl.java index 0ebd7c6..e33c72c 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServerImpl.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServerImpl.java @@ -38,7 +38,7 @@ import com.google.inject.Module; import com.google.inject.TypeLiteral; import com.google.inject.util.Modules; -public class GuiceJamesServerImpl { +public class GuiceJamesServerImpl implements GuiceJamesServer { protected final Module module; private Stager<PreDestroy> preDestroy; private GuiceProbeProvider guiceProbeProvider; @@ -62,6 +62,7 @@ public class GuiceJamesServerImpl { return new GuiceJamesServerImpl(Modules.override(module).with(overrides)); } + @Override public void start() throws Exception { Injector injector = Guice.createInjector(module); preDestroy = injector.getInstance(Key.get(new TypeLiteral<Stager<PreDestroy>>() {})); @@ -69,12 +70,14 @@ public class GuiceJamesServerImpl { guiceProbeProvider = injector.getInstance(GuiceProbeProvider.class); } + @Override public void stop() { if (preDestroy != null) { preDestroy.stage(); } } + @Override public GuiceServerProbe serverProbe() { return guiceProbeProvider.getProbe(GuiceServerProbe.class); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
