| 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; | |
| 17 | ||
| 18 | import org.glassfish.hk2.api.Factory; | |
| 19 | import org.glassfish.hk2.api.ServiceLocator; | |
| 20 | import org.jvnet.hk2.annotations.Service; | |
| 21 | import org.maxur.perfmodel.backend.service.impl.CliApplication; | |
| 22 | import org.maxur.perfmodel.backend.service.impl.TrayIconApplication; | |
| 23 | import org.maxur.perfmodel.backend.service.Application; | |
| 24 | import org.slf4j.Logger; | |
| 25 | ||
| 26 | import javax.inject.Inject; | |
| 27 | ||
| 28 | import static org.slf4j.LoggerFactory.getLogger; | |
| 29 | ||
| 30 | /** | |
| 31 | * @author myunusov | |
| 32 | * @version 1.0 | |
| 33 | * @since <pre>01.09.2015</pre> | |
| 34 | */ | |
| 35 | @Service | |
| 36 | public class ApplicationProvider implements Factory<Application> { | |
| 37 | ||
| 38 | private static final Logger LOGGER = getLogger(ApplicationProvider.class); | |
| 39 | ||
| 40 | private Application application; | |
| 41 | ||
| 42 | @Inject | |
| 43 | private ServiceLocator locator; | |
| 44 | ||
| 45 | @Override | |
| 46 | public Application provide() { | |
| 47 |
1
1. provide : negated conditional → NO_COVERAGE |
if (application == null) { |
| 48 | application = make(); | |
| 49 |
1
1. provide : removed call to org/glassfish/hk2/api/ServiceLocator::inject → NO_COVERAGE |
locator.inject(application); |
| 50 | } | |
| 51 |
1
1. provide : mutated return of Object value for org/maxur/perfmodel/backend/ApplicationProvider::provide to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return application; |
| 52 | } | |
| 53 | ||
| 54 | private Application make() { | |
| 55 | final Application result = new TrayIconApplication(); | |
| 56 |
1
1. make : negated conditional → NO_COVERAGE |
if (result.isApplicable()) { |
| 57 |
1
1. make : mutated return of Object value for org/maxur/perfmodel/backend/ApplicationProvider::make to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result; |
| 58 | } else { | |
| 59 | LOGGER.info("SystemTray is not supported"); | |
| 60 | } | |
| 61 |
1
1. make : mutated return of Object value for org/maxur/perfmodel/backend/ApplicationProvider::make to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new CliApplication(); |
| 62 | } | |
| 63 | ||
| 64 | @Override | |
| 65 | public void dispose(Application instance) { | |
| 66 |
1
1. dispose : removed call to org/maxur/perfmodel/backend/service/Application::stop → NO_COVERAGE |
instance.stop(); |
| 67 | } | |
| 68 | } | |
Mutations | ||
| 47 |
1.1 |
|
| 49 |
1.1 |
|
| 51 |
1.1 |
|
| 56 |
1.1 |
|
| 57 |
1.1 |
|
| 61 |
1.1 |
|
| 66 |
1.1 |