提交 b6d6f9d8 编写于 作者: sinat_25235033's avatar sinat_25235033

delete unused code in sample-bootstrap, simplify the demo

上级 cf54bfec
......@@ -8,6 +8,5 @@
- load data from default dataSource - `sureness.yml`
- use default sureness config
- use default `jwt auth, basic auth, digest auth` to authenticate and authorize
- contain `restful api,websocket`
- project's protected entrance is `SurenessFilterExample`
- suggest use postman to test, test case is in `sample-bootstrap-postman.json`, user can load it in postman
......@@ -8,6 +8,5 @@ sureness 10分钟例子项目
- 从默认的配置文件`sureness.yml`加载账户信息,资源角色,过滤资源等信息
- 使用默认的`sureness-config`
- 使用默认的`jwt auth,basic auth,digest auth`方式认证鉴权
- 例子中包含`restful api,websocket`
- 保护入口: `SurenessFilterExample`
- 推荐使用`postman`测试,测试样例为`sample-bootstrap-postman.json`,导入`postman`即可
......@@ -23,36 +23,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.usthe.sureness</groupId>
<artifactId>sureness-core</artifactId>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>provided</scope>
</dependency>
<!-- java api-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -76,50 +56,6 @@
</execution>
</executions>
</plugin>
<!-- java code style check -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.8</version>
<configuration>
<rulesets>
<ruleset>rulesets/java/ali-comment.xml</ruleset>
<ruleset>rulesets/java/ali-concurrent.xml</ruleset>
<ruleset>rulesets/java/ali-constant.xml</ruleset>
<ruleset>rulesets/java/ali-exception.xml</ruleset>
<ruleset>rulesets/java/ali-flowcontrol.xml</ruleset>
<ruleset>rulesets/java/ali-naming.xml</ruleset>
<ruleset>rulesets/java/ali-oop.xml</ruleset>
<ruleset>rulesets/java/ali-orm.xml</ruleset>
<ruleset>rulesets/java/ali-other.xml</ruleset>
<ruleset>rulesets/java/ali-set.xml</ruleset>
</rulesets>
<printFailingErrors>true</printFailingErrors>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.alibaba.p3c</groupId>
<artifactId>p3c-pmd</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
</plugin>
<!-- java doc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
......
package com.usthe.sureness.sample.bootstrap.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* webSocket endpoint config
* @author tomsun28
* @date 22:52 2019-05-26
*/
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
package com.usthe.sureness.sample.bootstrap.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
/**
* websocket simulate api, for testing websocket
* @author tomsun28
* @date 22:21 2019-05-26
*/
@Component
@ServerEndpoint(value = "/webSocket/demo")
public class WebSocketEndpoint {
private static final Logger logger = LoggerFactory.getLogger(WebSocketEndpoint.class);
@OnOpen
public void onOpen(Session session) {
logger.info("webSocket: /webSocket/demo onOpen, session is : {} ", session);
}
@OnMessage
public void onMessage(String message, Session session) {
logger.info("webSocket: /webSocket/demo receive message: {}, the session is : {} ",
message, session);
}
@OnClose
public void onClose() {
logger.info("webSocket: /webSocket/demo on Close");
}
@OnError
public void onError(Session session, Throwable error) {
logger.error("webSocket: /webSocket/demo on Error, the session is {} ",
session, error);
}
}
## -- sureness.yml txt dataSource-- ##
## -- sureness.yml document dataSource-- ##
# load api resource which need be protected, config role who can access these resource.
# resources that are not configured are also authenticated and protected by default, but not authorized
......
package com.usthe.sureness.sample.bootstrap.controller;
import org.junit.Test;
/**
* @author tomsun28
* @date 23:01 2019-05-26
*/
public class WebSocketEndpointTest {
@Test
public void onOpen() {
}
@Test
public void onMessage() {
}
@Test
public void onClose() {
}
@Test
public void onError() {
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册