Browse Source

standardizations

master
Jaryl Chng 1 year ago
parent
commit
95eb002165
5 changed files with 8 additions and 31 deletions
  1. +0
    -23
      common-jersey/src/main/java/com/jarylchng/reactivemongoexample/common/CommonApplication.java
  2. +2
    -2
      common/src/main/java/com/jarylchng/reactivemongoexample/common/User.java
  3. +2
    -2
      grizzly-jersey/src/main/java/com/jarylchng/reactivemongoexample/grizzlyjersey/GrizzlyJersey.java
  4. +2
    -2
      netty-jersey/src/main/java/com/jarylchng/reactivemongoexample/nettyjersey/NettyJersey.java
  5. +2
    -2
      tomcat-jersey/src/main/java/com/jarylchng/reactivemongoexample/tomcatjersey/TomcatJersey.java

+ 0
- 23
common-jersey/src/main/java/com/jarylchng/reactivemongoexample/common/CommonApplication.java View File

@ -1,23 +0,0 @@
package com.jarylchng.reactivemongoexample.common;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@ApplicationPath("/")
public class CommonApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
return Collections.emptySet();
}
@Override
public Set<Object> getSingletons() {
HashSet<Object> classes = new HashSet<>();
classes.add(new ResourceReactive());
classes.add(new ResourceSynced());
return classes;
}
}

+ 2
- 2
common/src/main/java/com/jarylchng/reactivemongoexample/common/User.java View File

@ -91,11 +91,11 @@ public class User {
private static com.mongodb.client.MongoCollection<User> collection = database.getCollection("user", User.class)
.withCodecRegistry(pojoCodecRegistry);
public static User findByID(String id) {
public synchronized static User findByID(String id) {
return collection.find(eq("userID", id)).first();
}
public static void insert(User user) {
public synchronized static void insert(User user) {
collection.insertOne(user);
}

+ 2
- 2
grizzly-jersey/src/main/java/com/jarylchng/reactivemongoexample/grizzlyjersey/GrizzlyJersey.java View File

@ -11,8 +11,8 @@ import java.net.URI;
public class GrizzlyJersey {
private static void startServer() {
ResourceConfig rc = new ResourceConfig()
.register(ResourceReactive.class)
.register(ResourceSynced.class);
.register(new ResourceReactive())
.register(new ResourceSynced());
GrizzlyHttpServerFactory.createHttpServer(URI.create("http://localhost:8080/"), rc);
}

+ 2
- 2
netty-jersey/src/main/java/com/jarylchng/reactivemongoexample/nettyjersey/NettyJersey.java View File

@ -11,8 +11,8 @@ import java.net.URI;
public class NettyJersey {
private static void startServer() {
ResourceConfig rc = new ResourceConfig()
.register(ResourceReactive.class)
.register(ResourceSynced.class);
.register(new ResourceReactive())
.register(new ResourceSynced());
NettyHttpContainerProvider.createHttp2Server(
URI.create("http://localhost:8080/"),
rc, null);

+ 2
- 2
tomcat-jersey/src/main/java/com/jarylchng/reactivemongoexample/tomcatjersey/TomcatJersey.java View File

@ -25,8 +25,8 @@ public class TomcatJersey extends Application {
Context context = tomcat.addWebapp("", base.getAbsolutePath());
Tomcat.addServlet(context, "tomcat-jersey",
new ServletContainer(new ResourceConfig()
.register(ResourceReactive.class)
.register(ResourceSynced.class)))
.register(new ResourceReactive())
.register(new ResourceSynced())))
.setAsyncSupported(true);
context.addServletMappingDecoded("/*", "tomcat-jersey");

Loading…
Cancel
Save