mirror of
https://gitee.com/nutz/nutzboot.git
synced 2024-12-02 11:48:09 +08:00
Merge pull request #27 from nutzam/add_swagger_demo
add: 完善starter-swagger并添加demo
This commit is contained in:
commit
e276b42f08
@ -0,0 +1,60 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-demo-simple</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>nutzboot-demo-simple-swagger</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-nutz-mvc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-jetty</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-swagger</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.25</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/nutz/org.nutz.boot.starter.NbStarter</resource>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>io.nutz.demo.simple.MainLauncher</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,13 @@
|
||||
package io.nutz.demo.simple;
|
||||
|
||||
import org.nutz.boot.NbApp;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
@IocBean
|
||||
public class MainLauncher {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new NbApp(MainLauncher.class).run();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package io.nutz.demo.simple.module;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.GET;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@Api(value = "demo")
|
||||
@IocBean
|
||||
@At("/demo")
|
||||
public class SwaggerDemoModule {
|
||||
|
||||
@GET
|
||||
@ApiOperation(value = "心跳接口", notes = "发我一个ping,回你一个pong", httpMethod="GET")
|
||||
@At
|
||||
@Ok("json:full")
|
||||
public Object ping() {
|
||||
return new NutMap("ok", true).setv("data", "pong");
|
||||
}
|
||||
|
||||
@POST
|
||||
@ApiOperation(value = "回显接口", notes = "发我一个字符串,原样回复一个字符串", httpMethod="POST")
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "text", paramType="form", value = "想发啥就发啥", dataType="string", required = true)})
|
||||
@At
|
||||
@Ok("raw")
|
||||
public String echo(@Param("text") String text) {
|
||||
return text;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
jetty.port=8080
|
||||
jetty.host=127.0.0.1
|
||||
|
||||
swagger.info.title=NutzBoot Swagger 示例
|
||||
swagger.info.version=2.0-Beta
|
||||
swagger.info.contact.name=Wendal Chen
|
||||
swagger.info.contact.email=wendal1985@gmail.com
|
||||
swagger.info.contact.url=https://nutz.io
|
||||
swagger.info.license.name=Apache v2
|
@ -0,0 +1,7 @@
|
||||
log4j.rootLogger=debug,Console
|
||||
|
||||
log4j.logger.org.eclipse.jetty=info
|
||||
|
||||
log4j.appender.Console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.Console.layout.ConversionPattern=[%-5p] %d{HH:mm:ss.SSS} %l - %m%n
|
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello, So NB!</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h2><a href="/swagger/">查看Swagger</a></h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -15,6 +15,7 @@
|
||||
<module>nutzboot-demo-simple-jetx</module>
|
||||
<module>nutzboot-demo-simple-mvc-ngrok</module>
|
||||
<module>nutzboot-demo-simple-mvc-shiro</module>
|
||||
<module>nutzboot-demo-simple-swagger</module>
|
||||
</modules>
|
||||
<properties>
|
||||
</properties>
|
||||
|
@ -1,27 +1,28 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-parent</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>nutzboot-demo</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>nutzboot-demo-maker</module>
|
||||
<module>nutzboot-demo-simple</module>
|
||||
<module>nutzboot-demo-zbus</module>
|
||||
<module>nutzboot-demo-dubbo</module>
|
||||
|
||||
</modules>
|
||||
<properties>
|
||||
</properties>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-parent</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>nutzboot-demo</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>nutzboot-demo-maker</module>
|
||||
<module>nutzboot-demo-simple</module>
|
||||
<module>nutzboot-demo-zbus</module>
|
||||
<module>nutzboot-demo-dubbo</module>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</modules>
|
||||
<properties>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -3,7 +3,10 @@ package org.nutz.boot.starter.jetty;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -13,7 +16,6 @@ import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
@ -116,11 +118,15 @@ public class JettyStarter implements ClassLoaderAware, IocAware, ServerFace, Lif
|
||||
wac.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
|
||||
}
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
if (new File("./static").exists()) {
|
||||
resources.add(new PathResource(new File("./static")));
|
||||
for (String resourcePath : Arrays.asList("static/", "webapp/")) {
|
||||
File f = new File(resourcePath);
|
||||
if (f.exists())
|
||||
resources.add(Resource.newResource(f));
|
||||
Enumeration<URL> urls = appContext.getClassLoader().getResources(resourcePath);
|
||||
while(urls.hasMoreElements()) {
|
||||
resources.add(Resource.newResource(urls.nextElement()));
|
||||
}
|
||||
}
|
||||
resources.add(Resource.newClassPathResource("static/"));
|
||||
resources.add(Resource.newClassPathResource("webapp/"));
|
||||
wac.setBaseResource(new ResourceCollection(resources.toArray(new Resource[resources.size()])) {
|
||||
@Override
|
||||
public Resource addPath(String path) throws IOException, MalformedURLException {
|
||||
|
@ -22,7 +22,7 @@ public class QuartzStarter implements IocLoaderProvider, ServerFace {
|
||||
|
||||
public IocLoader getIocLoader() {
|
||||
if (!conf.has("cron.pkgs")) {
|
||||
conf.put("cron.pkgs", appContext.getMainClass().getPackage().getName());
|
||||
conf.put("cron.pkgs", appContext.getPackage());
|
||||
}
|
||||
return new QuartzIocLoader();
|
||||
}
|
||||
|
@ -62,7 +62,7 @@
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-servlet</artifactId>
|
||||
<version>1.5.16</version>
|
||||
<version>1.5.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
|
@ -1,8 +1,11 @@
|
||||
package org.nutz.start.swagger;
|
||||
package org.nutz.boot.starter.swagger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
@ -10,35 +13,54 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.nutz.boot.AppContext;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
import org.nutz.boot.starter.WebServletFace;
|
||||
import org.nutz.ioc.impl.PropertiesProxy;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.resource.Scans;
|
||||
|
||||
import io.swagger.models.Info;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.servlet.Reader;
|
||||
import io.swagger.util.Json;
|
||||
import io.swagger.util.Yaml;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class SwaggerServlet extends HttpServlet {
|
||||
@IocBean
|
||||
public class SwaggerServletStarter extends HttpServlet implements WebServletFace {
|
||||
|
||||
private static final long serialVersionUID = 988318972932805253L;
|
||||
|
||||
@Inject
|
||||
protected PropertiesProxy conf;
|
||||
|
||||
@Inject
|
||||
protected AppContext appContext;
|
||||
|
||||
protected Swagger swagger;
|
||||
|
||||
public SwaggerServlet setAppContext(AppContext appContext) {
|
||||
this.appContext = appContext;
|
||||
|
||||
public String getName() {
|
||||
return "swagger";
|
||||
}
|
||||
|
||||
public String getPathSpec() {
|
||||
return "/swagger/swagger.json";
|
||||
}
|
||||
|
||||
public Servlet getServlet() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<String, String> getInitParameters() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
swagger = new Swagger();
|
||||
swagger.setBasePath(config.getServletContext().getContextPath());
|
||||
PropertiesProxy conf = appContext.getConfigureLoader().get();
|
||||
swagger = conf.make(Swagger.class, "swagger.conf.");
|
||||
Info info = conf.make(Info.class, "swagger.info.");
|
||||
swagger.setInfo(info);
|
||||
HashSet<Class<?>> classes = new HashSet<>();
|
||||
String pkgName = appContext.getConfigureLoader().get().get("swagger.packageName");
|
||||
if (Strings.isBlank(pkgName)) {
|
||||
pkgName = appContext.getMainClass().getPackage().getName();
|
||||
}
|
||||
String pkgName = conf.get("swagger.resource.package", appContext.getPackage());
|
||||
for (Class<?> klass : Scans.me().scanPackage(pkgName)) {
|
||||
classes.add(klass);
|
||||
}
|
||||
@ -51,13 +73,9 @@ public class SwaggerServlet extends HttpServlet {
|
||||
if (pathInfo.endsWith("/swagger.json")) {
|
||||
response.setContentType("application/json");
|
||||
response.getWriter().println(Json.mapper().writeValueAsString(swagger));
|
||||
} else if (pathInfo.endsWith("/swagger.yaml")) {
|
||||
response.setContentType("application/yaml");
|
||||
response.getWriter().println(Yaml.mapper().writeValueAsString(swagger));
|
||||
} else if (pathInfo.endsWith("/")) {
|
||||
|
||||
} else {
|
||||
response.setStatus(404);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package org.nutz.start.swagger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
import org.nutz.boot.starter.WebServletFace;
|
||||
import org.nutz.ioc.impl.PropertiesProxy;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
@IocBean
|
||||
public class SwaggerStarter implements WebServletFace {
|
||||
|
||||
@Inject
|
||||
protected PropertiesProxy conf;
|
||||
|
||||
public String getName() {
|
||||
return "swagger";
|
||||
}
|
||||
|
||||
public String getPathSpec() {
|
||||
return "/swagger/*";
|
||||
}
|
||||
|
||||
public Servlet getServlet() {
|
||||
return new SwaggerServlet();
|
||||
}
|
||||
|
||||
public Map<String, String> getInitParameters() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
}
|
@ -1 +1 @@
|
||||
org.nutz.boot.starter.jetty.JettyStarter
|
||||
org.nutz.boot.starter.swagger.SwaggerServletStarter
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 445 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,95 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
<style>
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
margin:0;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
|
||||
<defs>
|
||||
<symbol viewBox="0 0 20 20" id="unlocked">
|
||||
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="locked">
|
||||
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="close">
|
||||
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="large-arrow">
|
||||
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="large-arrow-down">
|
||||
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
|
||||
</symbol>
|
||||
|
||||
|
||||
<symbol viewBox="0 0 24 24" id="jump-to">
|
||||
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 24 24" id="expand">
|
||||
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
|
||||
</symbol>
|
||||
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="./swagger-ui-bundle.js"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
|
||||
// Build a system
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "/swagger/swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
|
||||
window.ui = ui
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -31,13 +31,13 @@ public class ZbusStarter implements IocLoaderProvider, ServerFace {
|
||||
public void start() throws Exception {
|
||||
if (conf.getBoolean("zbus.rpc.service.enable", false)) {
|
||||
if (!conf.has("zbus.rpc.service.packageNames")) {
|
||||
conf.put("zbus.rpc.service.packageNames", appContext.getMainClass().getPackage().getName() + ".service");
|
||||
conf.put("zbus.rpc.service.packageNames", appContext.getPackage() + ".service");
|
||||
}
|
||||
ioc.get(ZbusServiceBootstrap.class).start();
|
||||
}
|
||||
if (conf.getBoolean("zbus.rpc.client.enable", false)) {
|
||||
if (!conf.has("zbus.rpc.client.packageNames")) {
|
||||
conf.put("zbus.rpc.client.packageNames", appContext.getMainClass().getPackage().getName() + ".service");
|
||||
conf.put("zbus.rpc.client.packageNames", appContext.getPackage() + ".service");
|
||||
}
|
||||
ioc.get(ZbusClientBean.class);
|
||||
}
|
||||
|
@ -100,6 +100,10 @@ public class AppContext implements LifeCycle {
|
||||
public void setMainClass(Class<?> mainClass) {
|
||||
this.mainClass = mainClass;
|
||||
}
|
||||
|
||||
public String getPackage() {
|
||||
return this.mainClass.getPackage().getName();
|
||||
}
|
||||
|
||||
public void init() throws Exception {
|
||||
for (Object object : starters) {
|
||||
|
@ -194,7 +194,7 @@ public class NbApp {
|
||||
public void prepareIoc() throws Exception {
|
||||
if (ctx.getComboIocLoader() == null) {
|
||||
int asyncPoolSize = ctx.getConfigureLoader().get().getInt("nutz.ioc.async.poolSize", 64);
|
||||
String[] args = new String[] {"*js", "ioc/", "*tx", "*async", ""+asyncPoolSize, "*anno", ctx.getMainClass().getPackage().getName()};
|
||||
String[] args = new String[] {"*js", "ioc/", "*tx", "*async", ""+asyncPoolSize, "*anno", ctx.getPackage()};
|
||||
ctx.setComboIocLoader(new ComboIocLoader(args));
|
||||
}
|
||||
// 用于加载Starter的IocLoader
|
||||
|
Loading…
Reference in New Issue
Block a user