| 1 | /* | |
| 2 | * Copyright (c) 2014 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.glassfish.grizzly.Grizzly; | |
| 19 | import org.glassfish.grizzly.http.server.HttpServer; | |
| 20 | import org.glassfish.grizzly.http.server.StaticHttpHandler; | |
| 21 | import org.glassfish.hk2.api.ServiceLocator; | |
| 22 | import org.glassfish.jersey.server.ResourceConfig; | |
| 23 | import org.maxur.perfmodel.backend.service.WebServer; | |
| 24 | ||
| 25 | import javax.inject.Inject; | |
| 26 | import javax.inject.Named; | |
| 27 | import javax.ws.rs.ext.Provider; | |
| 28 | import java.net.URI; | |
| 29 | ||
| 30 | import static org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer; | |
| 31 | ||
| 32 | @Provider | |
| 33 | public class WebServerGrizzlyImpl extends WebServer { | |
| 34 | ||
| 35 | private HttpServer httpServer; | |
| 36 | ||
| 37 | @Inject | |
| 38 | private ResourceConfig config; | |
| 39 | ||
| 40 | @Inject | |
| 41 | private ServiceLocator locator; | |
| 42 | ||
| 43 | @SuppressWarnings("unused") | |
| 44 | @Named("webapp.folderName") | |
| 45 | private String webappFolderName; | |
| 46 | ||
| 47 | @SuppressWarnings("unused") | |
| 48 | @Named("webapp.url") | |
| 49 | private String webappUrl; | |
| 50 | ||
| 51 | ||
| 52 | @Override | |
| 53 | protected void launch() { | |
| 54 | httpServer = createHttpServer( | |
| 55 | URI.create(webappUrl + REST_APP_URL), | |
| 56 | config, | |
| 57 | locator | |
| 58 | ); | |
| 59 |
1
1. launch : removed call to org/glassfish/grizzly/http/server/ServerConfiguration::addHttpHandler → NO_COVERAGE |
httpServer.getServerConfiguration().addHttpHandler( |
| 60 | new StaticHttpHandler(webappFolderName), | |
| 61 | WEB_APP_URL | |
| 62 | ); | |
| 63 | } | |
| 64 | ||
| 65 | @Override | |
| 66 | protected void shutdown() { | |
| 67 |
1
1. shutdown : removed call to org/glassfish/grizzly/http/server/HttpServer::shutdownNow → NO_COVERAGE |
httpServer.shutdownNow(); |
| 68 | } | |
| 69 | ||
| 70 | @Override | |
| 71 | protected String version() { | |
| 72 |
1
1. version : mutated return of Object value for org/maxur/perfmodel/backend/service/impl/WebServerGrizzlyImpl::version to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return "Grizzly Http Server " + Grizzly.getDotedVersion(); |
| 73 | } | |
| 74 | ||
| 75 | @Override | |
| 76 | public boolean isStarted() { | |
| 77 |
1
1. isStarted : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return httpServer.isStarted(); |
| 78 | } | |
| 79 | } | |
Mutations | ||
| 59 |
1.1 |
|
| 67 |
1.1 |
|
| 72 |
1.1 |
|
| 77 |
1.1 |