Last active
July 13, 2018 08:45
-
-
Save ldclakmal/ece63588a8227849644d948379e830e2 to your computer and use it in GitHub Desktop.
Microservice runner with netty-transports.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.wso2.cse.rest; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.wso2.cse.configuration.AuthInterceptor; | |
| import org.wso2.cse.service.Constant; | |
| import org.wso2.msf4j.MicroservicesRunner; | |
| import java.io.File; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.nio.file.Files; | |
| import java.nio.file.Path; | |
| import java.nio.file.Paths; | |
| import java.nio.file.StandardCopyOption; | |
| /** | |
| * Application entry point. | |
| */ | |
| public class Application { | |
| private static final Logger logger = LoggerFactory.getLogger(Application.class); | |
| public static void main(String[] args) { | |
| Path confFilePath = Constant.Configuration.CONF_PATH.resolve(Paths.get(Constant.Configuration.NETTY_TRANSPORT_CONF)); | |
| InputStream inputStream = Application.class.getResourceAsStream(File.separator + Constant.Configuration.NETTY_TRANSPORT_CONF); | |
| try { | |
| Files.createDirectories(Constant.Configuration.CONF_PATH); | |
| Files.copy(inputStream, confFilePath, StandardCopyOption.REPLACE_EXISTING); | |
| logger.debug("Copied resource {} into {}", Constant.Configuration.NETTY_TRANSPORT_CONF, confFilePath); | |
| } catch (IOException e) { | |
| logger.error("Failed to create and copy resource to {}", confFilePath); | |
| } | |
| System.setProperty("transports.netty.conf", Constant.Configuration.CONF_PATH.resolve(Constant.Configuration.NETTY_TRANSPORT_CONF).toString()); | |
| logger.info("Set system properties before start microservice"); | |
| new MicroservicesRunner() | |
| .addGlobalRequestInterceptor(new AuthInterceptor()) | |
| .deploy(new CSEService()) | |
| .start(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment