View Javadoc

1   /*
2    * Copyright (c) 2015 Maxim Yunusov
3    *    Licensed under the Apache License, Version 2.0 (the "License");
4    *    you may not use this file except in compliance with the License.
5    *    You may obtain a copy of the License at
6    *
7    *        http://www.apache.org/licenses/LICENSE-2.0
8    *
9    *    Unless required by applicable law or agreed to in writing, software
10   *    distributed under the License is distributed on an "AS IS" BASIS,
11   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   *    See the License for the specific language governing permissions and
13   *    limitations under the License.
14   */
15  
16  package org.maxur.perfmodel.backend.service.impl;
17  
18  import org.jvnet.hk2.annotations.Service;
19  import org.maxur.perfmodel.backend.service.Application;
20  import org.slf4j.Logger;
21  import org.slf4j.LoggerFactory;
22  
23  import java.io.IOException;
24  
25  /**
26   * This class represents Performance Model Calculator Application.
27   * It's CLI Implementation.
28   *
29   * @author myunusov
30   * @version 1.0
31   * @since <pre>30.08.2015</pre>
32   */
33  @Service
34  public final class CliApplication extends Application {
35  
36      private static final Logger LOGGER = LoggerFactory.getLogger(CliApplication.class);
37  
38      public CliApplication() {
39      }
40  
41      @Override
42      public boolean isApplicable() {
43          return true;
44      }
45  
46      @Override
47      public void onStart() {
48          LOGGER.info("Press Enter to stop\n");
49          try {
50              //noinspection ResultOfMethodCallIgnored
51              System.in.read();
52              stop();
53          } catch (IOException e) {
54              LOGGER.error(e.getMessage(), e);
55          }
56      }
57  
58  }