Browse Source

Upgrade to Blade 2.0.12 (#4139)

* Updating Blade version

* Updating Blade version

* Updating Blade version

* Updating Blade version

* Updating Blade version

* Upgrade to Blade 2.0.12
biezhi 6 years ago
parent
commit
d01bbc9e07

+ 12 - 8
frameworks/Java/blade/README.md

@@ -1,6 +1,6 @@
 # Blade Benchmarking Test
 # Blade Benchmarking Test
 
 
-This is the Blade portion of a [benchmarking test suite](../) comparing a variety of web development platforms. The test utilizes Blade routes, JSON serialization, Blade-JDBC for ORM.
+This is the Blade portion of a [benchmarking test suite](../) comparing a variety of web development platforms. The test utilizes Blade routes, JSON serialization, [Anima](https://github.com/biezhi/anima) for ORM.
 
 
 ### Tests
 ### Tests
 
 
@@ -9,13 +9,9 @@ This is the Blade portion of a [benchmarking test suite](../) comparing a variet
 
 
 ## Infrastructure Software Versions
 ## Infrastructure Software Versions
 
 
-* [Blade 2.0.3](https://github.com/biezhi/blade)
+* [Blade 2.0.12.ALPHA](https://github.com/biezhi/blade)
 * [Java OpenJDK 1.8](http://openjdk.java.net/)
 * [Java OpenJDK 1.8](http://openjdk.java.net/)
-* [HikariCP 2.7.1](https://github.com/brettwooldridge/HikariCP)
-
-## References
-
-* https://github.com/netty/netty/tree/master/example/src/main/java/io/netty/example/http/snoop
+* [HikariCP 3.2.0](https://github.com/brettwooldridge/HikariCP)
 
 
 ## Test URLs
 ## Test URLs
 
 
@@ -29,4 +25,12 @@ http://localhost:9000/db?queries=5
 
 
 ### Plain Text Test
 ### Plain Text Test
 
 
-http://localhost:9000/plaintext
+http://localhost:9000/plaintext
+
+### Update Test
+
+http://localhost:9000/updates?queries=2
+
+### Fortunes Test
+
+http://localhost:9000/fortunes

+ 26 - 22
frameworks/Java/blade/benchmark_config.json

@@ -1,26 +1,30 @@
 {
 {
   "framework": "blade",
   "framework": "blade",
-  "tests": [{
-    "default": {
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "plaintext_url": "/plaintext",
-      "port": 9000,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "MySQL",
-      "framework": "blade",
-      "language": "Java",
-      "flavor": "None",
-      "orm": "Full",
-      "platform": "None",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "blade",
-      "notes": "",
-      "versus": "blade"
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "db_url": "/db",
+        "query_url": "/queries?queries=",
+        "fortune_url": "/fortunes",
+        "plaintext_url": "/plaintext",
+        "update_url": "/updates?queries=",
+        "port": 9000,
+        "approach": "Realistic",
+        "classification": "Fullstack",
+        "database": "MySQL",
+        "framework": "blade",
+        "language": "Java",
+        "flavor": "None",
+        "orm": "Full",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "blade",
+        "notes": "",
+        "versus": "blade"
+      }
     }
     }
-  }]
+  ]
 }
 }

+ 7 - 3
frameworks/Java/blade/blade.dockerfile

@@ -1,7 +1,11 @@
-FROM maven:3.5.3-jdk-10-slim as maven
+FROM maven:3.5.3-jdk-8-slim as maven
 WORKDIR /blade
 WORKDIR /blade
-COPY package.xml package.xml
 COPY pom.xml pom.xml
 COPY pom.xml pom.xml
 COPY src src
 COPY src src
 RUN mvn package -q
 RUN mvn package -q
-CMD ["java", "-Xms2G", "-Xmx2G", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-jar", "target/dist/hello-blade-1.0.0-BUILD-SNAPSHOT/hello-blade-1.0.0-BUILD-SNAPSHOT.jar"]
+
+FROM openjdk:8-jdk
+WORKDIR /blade
+COPY --from=maven /blade/target/hello-blade-latest.jar app.jar
+
+CMD ["java", "-server", "-Xms1G", "-Xmx1G", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-jar", "app.jar","--server.performance=true"]

+ 0 - 36
frameworks/Java/blade/package.xml

@@ -1,36 +0,0 @@
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
-
-    <id>customAssembly</id>
-    <!-- dir -->
-    <formats>
-        <format>dir</format>
-    </formats>
-
-    <includeBaseDirectory>false</includeBaseDirectory>
-
-    <fileSets>
-        <fileSet>
-            <directory>src/main/resources/</directory>
-            <outputDirectory>/resources</outputDirectory>
-        </fileSet>
-    </fileSets>
-
-    <dependencySets>
-        <dependencySet>
-            <outputDirectory>/lib</outputDirectory>
-            <scope>runtime</scope>
-            <excludes>
-                <exclude>${project.groupId}:${project.artifactId}</exclude>
-            </excludes>
-        </dependencySet>
-        <dependencySet>
-            <outputDirectory>/</outputDirectory>
-            <includes>
-                <include>${project.groupId}:${project.artifactId}</include>
-            </includes>
-        </dependencySet>
-    </dependencySets>
-
-</assembly>

+ 40 - 51
frameworks/Java/blade/pom.xml

@@ -6,82 +6,83 @@
 
 
     <groupId>hello.world</groupId>
     <groupId>hello.world</groupId>
     <artifactId>hello-blade</artifactId>
     <artifactId>hello-blade</artifactId>
-    <version>1.0.0-BUILD-SNAPSHOT</version>
+    <version>latest</version>
 
 
     <properties>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
         <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
         <java.version>1.8</java.version>
         <java.version>1.8</java.version>
+        <blade.version>2.0.12.ALPHA</blade.version>
+        <netty.version>4.1.30.Final</netty.version>
+        <anima.version>0.2.4</anima.version>
+        <hikaricp.version>3.2.0</hikaricp.version>
+        <mysql-conn.version>5.1.47</mysql-conn.version>
+        <blade-jetbrick.version>0.1.3</blade-jetbrick.version>
     </properties>
     </properties>
 
 
     <dependencies>
     <dependencies>
         <dependency>
         <dependency>
             <groupId>com.bladejava</groupId>
             <groupId>com.bladejava</groupId>
             <artifactId>blade-mvc</artifactId>
             <artifactId>blade-mvc</artifactId>
-            <version>2.0.7-beta2</version>
+            <version>${blade.version}</version>
         </dependency>
         </dependency>
 
 
         <dependency>
         <dependency>
-            <groupId>com.bladejava</groupId>
-            <artifactId>blade-jdbc</artifactId>
-            <version>0.2.2-RELEASE</version>
+            <groupId>io.github.biezhi</groupId>
+            <artifactId>anima</artifactId>
+            <version>${anima.version}</version>
         </dependency>
         </dependency>
 
 
         <dependency>
         <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty-transport-native-epoll</artifactId>
-            <version>4.1.22.Final</version>
-            <classifier>linux-x86_64</classifier>
+            <groupId>com.bladejava</groupId>
+            <artifactId>blade-template-jetbrick</artifactId>
+            <version>${blade-jetbrick.version}</version>
         </dependency>
         </dependency>
 
 
         <dependency>
         <dependency>
             <groupId>mysql</groupId>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <artifactId>mysql-connector-java</artifactId>
-            <version>5.1.47</version>
+            <version>${mysql-conn.version}</version>
         </dependency>
         </dependency>
 
 
         <dependency>
         <dependency>
             <groupId>com.zaxxer</groupId>
             <groupId>com.zaxxer</groupId>
             <artifactId>HikariCP</artifactId>
             <artifactId>HikariCP</artifactId>
-            <version>2.7.8</version>
+            <version>${hikaricp.version}</version>
         </dependency>
         </dependency>
 
 
-    </dependencies>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-transport-native-epoll</artifactId>
+            <version>${netty.version}</version>
+            <classifier>linux-x86_64</classifier>
+        </dependency>
 
 
-    <repositories>
-        <repository>
-            <id>oss-releases</id>
-            <url>https://oss.sonatype.org/content/repositories/releases</url>
-            <releases>
-                <enabled>true</enabled>
-            </releases>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-        </repository>
-    </repositories>
+    </dependencies>
 
 
     <build>
     <build>
         <resources>
         <resources>
             <resource>
             <resource>
                 <directory>src/main/java</directory>
                 <directory>src/main/java</directory>
                 <filtering>false</filtering>
                 <filtering>false</filtering>
-                <excludes>
-                    <exclude>**/*.java</exclude>
-                </excludes>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>false</filtering>
             </resource>
             </resource>
         </resources>
         </resources>
         <extensions>
         <extensions>
             <extension>
             <extension>
                 <groupId>kr.motd.maven</groupId>
                 <groupId>kr.motd.maven</groupId>
                 <artifactId>os-maven-plugin</artifactId>
                 <artifactId>os-maven-plugin</artifactId>
-                <version>1.5.0.Final</version>
+                <version>1.6.1</version>
             </extension>
             </extension>
         </extensions>
         </extensions>
         <plugins>
         <plugins>
             <plugin>
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.0</version>
                 <configuration>
                 <configuration>
                     <source>1.8</source>
                     <source>1.8</source>
                     <target>1.8</target>
                     <target>1.8</target>
@@ -90,12 +91,18 @@
             </plugin>
             </plugin>
             <plugin>
             <plugin>
                 <artifactId>maven-assembly-plugin</artifactId>
                 <artifactId>maven-assembly-plugin</artifactId>
+                <version>3.1.0</version>
                 <configuration>
                 <configuration>
+                    <finalName>${project.build.finalName}</finalName>
                     <appendAssemblyId>false</appendAssemblyId>
                     <appendAssemblyId>false</appendAssemblyId>
-                    <descriptors>
-                        <descriptor>package.xml</descriptor>
-                    </descriptors>
-                    <outputDirectory>${project.build.directory}/dist/</outputDirectory>
+                    <archive>
+                        <manifest>
+                            <mainClass>hello.Application</mainClass>
+                        </manifest>
+                    </archive>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
                 </configuration>
                 </configuration>
                 <executions>
                 <executions>
                     <execution>
                     <execution>
@@ -107,25 +114,7 @@
                     </execution>
                     </execution>
                 </executions>
                 </executions>
             </plugin>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <version>2.4</version>
-                <configuration>
-                    <archive>
-                        <manifest>
-                            <mainClass>hello.Application</mainClass>
-                            <classpathPrefix>lib/</classpathPrefix>
-                            <addClasspath>true</addClasspath>
-                        </manifest>
-                        <manifestEntries>
-                            <!-- Add the path to the configuration file under Class-Path -->
-                            <Class-Path>resources/</Class-Path>
-                        </manifestEntries>
-                    </archive>
-                </configuration>
-            </plugin>
         </plugins>
         </plugins>
     </build>
     </build>
 
 
-</project>
+</project>

+ 92 - 47
frameworks/Java/blade/src/main/java/hello/Application.java

@@ -1,72 +1,117 @@
 package hello;
 package hello;
 
 
 import com.blade.Blade;
 import com.blade.Blade;
-import com.blade.server.netty.HttpConst;
+import com.blade.mvc.Const;
+import com.blade.mvc.RouteContext;
+import com.blade.mvc.http.StringBody;
+import hello.model.Fortune;
 import hello.model.Message;
 import hello.model.Message;
 import hello.model.World;
 import hello.model.World;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.util.AsciiString;
-import io.netty.util.CharsetUtil;
 
 
-import java.util.Optional;
-import java.util.Random;
+import java.util.List;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.ThreadLocalRandom;
+import java.util.stream.Stream;
+
+import static io.github.biezhi.anima.Anima.select;
+import static io.github.biezhi.anima.Anima.update;
+import static java.util.Comparator.comparing;
+import static java.util.stream.Collectors.toList;
 
 
 /**
 /**
  * Blade Application
  * Blade Application
  *
  *
  * @author biezhi
  * @author biezhi
- * @date 2017/9/22
+ * @date 2018/10/17
  */
  */
 public class Application {
 public class Application {
 
 
-    private static final int          DB_ROWS                  = 308;
-    private static final byte[]       STATIC_PLAINTEXT         = "Hello, World!".getBytes(CharsetUtil.UTF_8);
-    private static final ByteBuf      PLAINTEXT_CONTENT_BUFFER = Unpooled.unreleasableBuffer(Unpooled.directBuffer().writeBytes(STATIC_PLAINTEXT));
-    private static final CharSequence PLAINTEXT_CLHEADER_VALUE = AsciiString.cached(String.valueOf(STATIC_PLAINTEXT.length));
+    private static final StringBody PLAINTEXT      = StringBody.of("Hello, World!");
+    private static final String JSON_CONTENT_TYPE  = "application/json";
+    private static final String SERVER_HEADER      = "Server";
+    private static final String SERVER_VALUE       = "Blade-" + Const.VERSION;
+    private static final String ADDITIONAL_FORTUNE = "Additional fortune added at request time.";
 
 
-    private static int getQueries(Optional<String> queryCount) {
-        if (!queryCount.isPresent()) {
-            return 1;
-        }
-        int count;
+    private static final int DB_ROWS = 10000;
+
+    private static int getQueries(String queries) {
         try {
         try {
-            count = Integer.parseInt(queryCount.get());
-        } catch (NumberFormatException ignored) {
+            int count = Integer.valueOf(queries);
+            return Math.min(500, Math.max(1, count));
+        } catch (Exception e) {
             return 1;
             return 1;
         }
         }
-        count = count < 1 ? 1 : count;
-        count = count > 500 ? 500 : count;
-        return count;
+    }
+
+    private static Integer generateId() {
+        return 1 + ThreadLocalRandom.current().nextInt(DB_ROWS);
+    }
+
+    private static List<Integer> generateIdList(int size) {
+        return Stream.iterate(0, num -> num + 1).limit(size)
+                .map(i -> generateId())
+                .collect(toList());
+    }
+
+    private static void db(RouteContext ctx) {
+        World world = select().from(World.class).byId(generateId());
+        ctx.json(world).contentType(JSON_CONTENT_TYPE).header(SERVER_HEADER, SERVER_VALUE);
+    }
+
+    private static void queries(RouteContext ctx) {
+        int queries = getQueries(ctx.fromString("queries", "1"));
+
+        List<Integer> idList = generateIdList(queries);
+
+        List<World> worlds = idList.stream()
+                .map(id -> select().from(World.class).byId(id))
+                .collect(toList());
+        ctx.json(worlds).contentType(JSON_CONTENT_TYPE).header(SERVER_HEADER, SERVER_VALUE);
+    }
+
+    private static void updates(RouteContext ctx) {
+        int queries = getQueries(ctx.fromString("queries", "1"));
+
+        List<Integer> idList = generateIdList(queries);
+
+        List<World> worlds = idList.stream()
+                .map(id -> select().from(World.class).byId(id))
+                .peek(Application::updateWorld).collect(toList());
+
+        ctx.json(worlds).contentType(JSON_CONTENT_TYPE).header(SERVER_HEADER, SERVER_VALUE);
+    }
+
+    private static void updateWorld(World world) {
+        int number = generateId();
+
+        update().from(World.class)
+                .set("randomNumber", number)
+                .where("id", world.getId())
+                .execute();
+
+        world.setRandomNumber(number);
+    }
+
+    private static void fortunes(RouteContext ctx) {
+        List<Fortune> fortunes = select().from(Fortune.class).all();
+
+        fortunes.add(new Fortune(0, ADDITIONAL_FORTUNE));
+        fortunes.sort(comparing(Fortune::getMessage));
+
+        ctx.attribute("fortunes", fortunes);
+        ctx.header(SERVER_HEADER, SERVER_VALUE);
+        ctx.render("fortunes.html");
     }
     }
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
-        Blade.me()
-                .get("/json", (request, response) -> {
-                    response.contentType(HttpConst.getContentType("application/json"));
-                    response.json(new Message());
-                })
-                .get("/db", (request, response) -> {
-                    final Random random = ThreadLocalRandom.current();
-                    response.contentType(HttpConst.getContentType("application/json"));
-                    response.json(new World().find(random.nextInt(DB_ROWS) + 1));
-                })
-                .get("/queries", (request, response) -> {
-                    int           queries = getQueries(request.query("queries"));
-                    final World[] worlds  = new World[queries];
-                    final Random  random  = ThreadLocalRandom.current();
-                    for (int i = 0; i < queries; i++) {
-                        worlds[i] = new World().find(random.nextInt(DB_ROWS) + 1);
-                    }
-                    response.contentType(HttpConst.getContentType("application/json"));
-                    response.json(worlds);
-                })
-                .get("/plaintext", (request, response) -> {
-                    response.contentType(HttpConst.getContentType("text/plain"));
-                    response.header(HttpConst.CONTENT_LENGTH, PLAINTEXT_CLHEADER_VALUE);
-                    response.body(PLAINTEXT_CONTENT_BUFFER.duplicate());
-                })
+        Blade.of()
+                .get("/json", ctx -> ctx.json(new Message()).contentType(JSON_CONTENT_TYPE)
+                        .header(SERVER_HEADER, SERVER_VALUE))
+                .get("/plaintext", ctx -> ctx.body(PLAINTEXT).contentType("text/plain")
+                        .header(SERVER_HEADER, SERVER_VALUE))
+                .get("/db", Application::db)
+                .get("/queries", Application::queries)
+                .get("/updates", Application::updates)
+                .get("/fortunes", Application::fortunes)
                 .disableSession()
                 .disableSession()
                 .start(Application.class, args);
                 .start(Application.class, args);
     }
     }

+ 48 - 0
frameworks/Java/blade/src/main/java/hello/Bootstrap.java

@@ -0,0 +1,48 @@
+package hello;
+
+import com.blade.Blade;
+import com.blade.ioc.annotation.Bean;
+import com.blade.loader.BladeLoader;
+import com.blade.mvc.view.template.JetbrickTemplateEngine;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import io.github.biezhi.anima.Anima;
+
+/**
+ * Application Bootstrap
+ *
+ * @author biezhi
+ * @date 2018/10/17
+ */
+@Bean
+public class Bootstrap implements BladeLoader {
+
+    @Override
+    public void load(Blade blade) {
+        try {
+            JetbrickTemplateEngine templateEngine = new JetbrickTemplateEngine();
+            blade.templateEngine(templateEngine);
+
+            HikariConfig config = new HikariConfig();
+
+            String url                   = blade.env("jdbc.url", "");
+            String username              = blade.env("jdbc.username", "");
+            String password              = blade.env("jdbc.password", "");
+            String cachePrepStmts        = blade.env("datasource.cachePrepStmts", "true");
+            String prepStmtCacheSize     = blade.env("datasource.prepStmtCacheSize", "250");
+            String prepStmtCacheSqlLimit = blade.env("datasource.prepStmtCacheSqlLimit", "2048");
+
+            config.setJdbcUrl(url);
+            config.setUsername(username);
+            config.setPassword(password);
+            config.addDataSourceProperty("cachePrepStmts", cachePrepStmts);
+            config.addDataSourceProperty("prepStmtCacheSize", prepStmtCacheSize);
+            config.addDataSourceProperty("prepStmtCacheSqlLimit", prepStmtCacheSqlLimit);
+
+            HikariDataSource ds = new HikariDataSource(config);
+            Anima.open(ds);
+        } catch (Exception e) {
+            System.out.println("Connection database fail");
+        }
+    }
+}

+ 0 - 38
frameworks/Java/blade/src/main/java/hello/DbConfig.java

@@ -1,38 +0,0 @@
-package hello;
-
-import com.blade.Blade;
-import com.blade.event.BeanProcessor;
-import com.blade.ioc.annotation.Bean;
-import com.blade.jdbc.Base;
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-
-/**
- * @author biezhi
- * @date 2017/9/22
- */
-@Bean
-public class DbConfig implements BeanProcessor {
-
-    private static final String DB_URL = "jdbc:mysql://tfb-database:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true&useSSL=false";
-
-    @Override
-    public void processor(Blade blade) {
-
-        try {
-            HikariConfig config = new HikariConfig();
-            config.setJdbcUrl(DB_URL);
-            config.setUsername("benchmarkdbuser");
-            config.setPassword("benchmarkdbpass");
-            config.addDataSourceProperty("cachePrepStmts", "true");
-            config.addDataSourceProperty("prepStmtCacheSize", "250");
-            config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
-
-            HikariDataSource ds = new HikariDataSource(config);
-            Base.open(ds);
-        } catch (Exception e){
-            System.out.println("Connection database fail");
-        }
-
-    }
-}

+ 35 - 0
frameworks/Java/blade/src/main/java/hello/model/Fortune.java

@@ -0,0 +1,35 @@
+package hello.model;
+
+import io.github.biezhi.anima.Model;
+import io.github.biezhi.anima.annotation.Table;
+
+@Table(name = "fortune")
+public class Fortune extends Model {
+
+    private Integer id;
+    private String  message;
+
+    public Fortune() {
+    }
+
+    public Fortune(Integer id, String message) {
+        this.id = id;
+        this.message = message;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}

+ 2 - 0
frameworks/Java/blade/src/main/java/hello/model/Message.java

@@ -1,6 +1,8 @@
 package hello.model;
 package hello.model;
 
 
 /**
 /**
+ * Message
+ * 
  * @author biezhi
  * @author biezhi
  * @date 2017/9/22
  * @date 2017/9/22
  */
  */

+ 23 - 5
frameworks/Java/blade/src/main/java/hello/model/World.java

@@ -1,18 +1,36 @@
 package hello.model;
 package hello.model;
 
 
-import com.blade.jdbc.annotation.Table;
-import com.blade.jdbc.core.ActiveRecord;
+import io.github.biezhi.anima.Model;
+import io.github.biezhi.anima.annotation.Column;
+import io.github.biezhi.anima.annotation.Table;
 
 
 /**
 /**
  * World model
  * World model
  *
  *
  * @author biezhi
  * @author biezhi
- * @date 2017/9/22
+ * @date 2018/10/17
  */
  */
-@Table("world")
-public class World extends ActiveRecord {
+@Table(name = "world")
+public class World extends Model {
 
 
     private Integer id;
     private Integer id;
+
+    @Column(name = "randomNumber")
     private Integer randomNumber;
     private Integer randomNumber;
 
 
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getRandomNumber() {
+        return randomNumber;
+    }
+
+    public void setRandomNumber(Integer randomNumber) {
+        this.randomNumber = randomNumber;
+    }
 }
 }

+ 0 - 1
frameworks/Java/blade/src/main/resources/app.properties

@@ -1 +0,0 @@
-com.blade.logger.defaultLogLevel=error

+ 3 - 0
frameworks/Java/blade/src/main/resources/application-dev.properties

@@ -0,0 +1,3 @@
+jdbc.url=jdbc:mysql://127.0.0.1:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true&useSSL=false
+jdbc.username=root
+jdbc.password=123456

+ 7 - 0
frameworks/Java/blade/src/main/resources/application.properties

@@ -0,0 +1,7 @@
+jdbc.url=jdbc:mysql://tfb-database:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true&useSSL=false
+jdbc.username=benchmarkdbuser
+jdbc.password=benchmarkdbpass
+
+datasource.cachePrepStmts=true
+datasource.prepStmtCacheSize=250
+datasource.prepStmtCacheSqlLimit=2048

+ 20 - 0
frameworks/Java/blade/src/main/resources/templates/fortunes.html

@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Fortunes</title>
+</head>
+<body>
+<table>
+    <tr>
+        <th>id</th>
+        <th>message</th>
+    </tr>
+    #for(fortune : fortunes)
+    <tr>
+        <td>${fortune.id}</td>
+        <td>${fortune.message.escapeXml()}</td>
+    </tr>
+    #end
+</table>
+</body>
+</html>