@@ -0,0 +1,3048 @@
+/* %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *%0A * You may not use this file except in compliance with the License.%0A *%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%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 *%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A * Contributions from 2013-2017 where performed either by US government %0A * employees, or under US Veterans Health Administration contracts. %0A *%0A * US Veterans Health Administration contributions by government employees%0A * are work of the U.S. Government and are not subject to copyright%0A * protection in the United States. Portions contributed by government %0A * employees are USGovWork (17USC %C2%A7105). Not subject to copyright. %0A * %0A * Contribution by contractors to the US Veterans Health Administration%0A * during this period are contractually contributed under the%0A * Apache License, Version 2.0.%0A *%0A * See: https://www.usa.gov/government-works%0A * %0A * Contributions prior to 2013:%0A *%0A * Copyright (C) International Health Terminology Standards Development Organisation.%0A * Licensed under the Apache License, Version 2.0.%0A *%0A */%0A%0Apackage sh.isaac.api;%0A%0Aimport javax.inject.Singleton;%0A%0Aimport org.apache.logging.log4j.LogManager;%0Aimport org.apache.logging.log4j.Logger;%0Aimport org.glassfish.hk2.runlevel.ChangeableRunLevelFuture;%0Aimport org.glassfish.hk2.runlevel.ErrorInformation;%0Aimport org.glassfish.hk2.runlevel.RunLevelFuture;%0Aimport org.glassfish.hk2.runlevel.RunLevelListener;%0Aimport org.jvnet.hk2.annotations.Service;%0A%0A/**%0A * Simple class to capture otherwise-lost exceptions that happen during service shutdowns.%0A *%0A * @author %3Ca href=%22mailto:daniel.armbrust.list@gmail.com%22%3EDan Armbrust%3C/a%3E%0A */%0A@Service%0A@Singleton%0Apublic class LookupServiceRunLevelListener implements RunLevelListener%7B%0A%0A   private static final Logger LOG = LogManager.getLogger();%0A   %0A   @Override%0A   public void onProgress(ChangeableRunLevelFuture currentJob, int levelAchieved) %7B%0A      // noop%0A      %0A   %7D%0A%0A   @Override%0A   public void onCancelled(RunLevelFuture currentJob, int levelAchieved) %7B%0A      LOG.info(%22RunLevel change was cancelled?  Current Job: %7B%7D levelAchieved: %7B%7D%22, currentJob, levelAchieved);%0A   %7D%0A%0A   //TODO %5BKEC%5D it would appear that when moving down levels, HK2 doesn't throw exceptions.. it eats them.%0A   //We should decide if we should pick up the exception this way, and throw it as part of our level change, %0A   //Or, just log and let it go, since we are shutting down.%0A   @Override%0A   public void onError(RunLevelFuture currentJob, ErrorInformation errorInformation) %7B%0A      LOG.error(%22Error during Runlevel change - currentJob: %7B%7D Failed Service: %7B%7D%22, currentJob, %0A            errorInformation.getFailedDescriptor().getImplementation(), errorInformation.getError());%0A   %7D%0A%7D%0A

Fix the HK2 doesn't log errors on shutdown problem.