@@ -0,0 +1,2912 @@
+/**%0A * Copyright (c) 2016-2020, Michael Yang %E6%9D%A8%E7%A6%8F%E6%B5%B7 (fuhai999@gmail.com).%0A * %3Cp%3E%0A * Licensed under the GNU Lesser General Public License (LGPL) ,Version 3.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %3Cp%3E%0A * http://www.gnu.org/licenses/lgpl-3.0.txt%0A * %3Cp%3E%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.jboot.app;%0A%0Aimport io.jboot.app.config.JbootConfigManager;%0Aimport io.jboot.core.JbootCoreConfig;%0A%0Aimport java.util.concurrent.locks.Condition;%0Aimport java.util.concurrent.locks.ReentrantLock;%0A%0A/**%0A * @author michael yang (fuhai999@gmail.com)%0A * @Date: 2020/3/24%0A */%0Apublic class JbootRpcApplication %7B%0A%0A    private static final ReentrantLock LOCK = new ReentrantLock();%0A    private static final Condition STOP = LOCK.newCondition();%0A%0A    public static void main(String%5B%5D args) %7B%0A        run(args);%0A    %7D%0A%0A    public static void setBootArg(String key, Object value) %7B%0A        JbootConfigManager.me().setBootArg(key, value);%0A    %7D%0A%0A    public static void run(String%5B%5D args) %7B%0A        JbootConfigManager.me().parseArgs(args);%0A        JbootCoreConfig coreConfig = new JbootCoreConfig();%0A        new RPCServer(coreConfig).start();%0A    %7D%0A%0A%0A%0A    static class RPCServer extends Thread %7B%0A        private JbootCoreConfig coreConfig;%0A%0A        public RPCServer(JbootCoreConfig coreConfig) %7B%0A            this.coreConfig = coreConfig;%0A            doInit();%0A        %7D%0A%0A        private void doInit()%7B%0A            this.coreConfig.onStart();%0A        %7D%0A%0A        @Override%0A        public void run() %7B%0A            addHook(coreConfig);%0A            await();%0A        %7D%0A%0A        private  void await() %7B%0A            try %7B%0A                LOCK.lock();%0A                STOP.await();%0A            %7D catch (InterruptedException e) %7B%0A                System.err.println(%22jboot rpc application has stopped, interrupted by other thread!%22);%0A            %7D finally %7B%0A                LOCK.unlock();%0A            %7D%0A        %7D%0A%0A        private void addHook(JbootCoreConfig config) %7B%0A            Runtime.getRuntime().addShutdownHook(new Thread(() -%3E %7B%0A                try %7B%0A                    config.onStop();%0A                %7D catch (Exception e) %7B%0A                    System.err.println(%22jboot rpc stop exception : %22 + e.toString());%0A                %7D%0A%0A                System.err.println(%22jboot rpc application exit, all service stopped.%22);%0A                try %7B%0A                    LOCK.lock();%0A                    STOP.signal();%0A                %7D finally %7B%0A                    LOCK.unlock();%0A                %7D%0A            %7D, %22jboot-rpc-application-hook%22));%0A        %7D%0A    %7D%0A%0A%7D%0A

add JbootRpcApplication for start RPC services only