use of act.app.util.NamedPort in project actframework by actframework.
the class AppConfig method namedPorts.
public List<NamedPort> namedPorts() {
if (null == namedPorts) {
String s = get(NAMED_PORTS, null);
if (null == s) {
namedPorts = cliOverHttp() ? C.list(new NamedPort(PORT_CLI_OVER_HTTP, cliOverHttpPort())) : C.<NamedPort>list();
} else {
String[] sa = (s.split("[,;]+"));
ListBuilder<NamedPort> builder = ListBuilder.create();
for (String s0 : sa) {
String[] sa0 = s0.split(":");
E.invalidConfigurationIf(2 != sa0.length, "Unknown named port configuration: %s", s);
String name = sa0[0].trim();
String val = sa0[1].trim();
NamedPort port = new NamedPort(name, Integer.parseInt(val));
if (!builder.contains(port)) {
builder.add(port);
} else {
throw E.invalidConfiguration("port[%s] already configured", name);
}
}
if (cliOverHttp()) {
builder.add(new NamedPort(PORT_CLI_OVER_HTTP, cliOverHttpPort()));
}
namedPorts = builder.toList();
}
}
return namedPorts;
}
use of act.app.util.NamedPort in project actframework by actframework.
the class ApiManager method load.
public void load(App app) {
LOGGER.info("start compiling API book");
Router router = app.router();
AppConfig config = app.config();
Set<Class> controllerClasses = new HashSet<>();
load(router, null, config, controllerClasses);
for (NamedPort port : app.config().namedPorts()) {
router = app.router(port);
load(router, port, config, controllerClasses);
}
if (Act.isDev()) {
exploreDescriptions(controllerClasses);
}
}
use of act.app.util.NamedPort in project actframework by actframework.
the class App method initRouters.
private void initRouters() {
router = new Router(this);
moreRouters = new HashMap<>();
List<NamedPort> ports = config().namedPorts();
for (NamedPort port : ports) {
moreRouters.put(port, new Router(this, port.name()));
}
if (config.cliOverHttp()) {
NamedPort cliOverHttp = new NamedPort(AppConfig.PORT_CLI_OVER_HTTP, config.cliOverHttpPort());
moreRouters.put(cliOverHttp, new Router(this, AppConfig.PORT_CLI_OVER_HTTP));
}
}
use of act.app.util.NamedPort in project actframework by actframework.
the class Act method hook.
public static void hook(App app) {
int port = app.config().httpPort();
NetworkHandler networkHandler = new NetworkHandler(app);
network.register(port, false, networkHandler);
if (app.config().supportSsl()) {
network.register(appConfig().httpsPort(), true, networkHandler);
}
List<NamedPort> portList = app.config().namedPorts();
for (NamedPort np : portList) {
network.register(np.port(), false, new NetworkHandler(app, np));
}
}
Aggregations