本文整理汇总了Java中com.networknt.config.Config类的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Config类属于com.networknt.config包,在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, RefreshToken> tokens = CacheStartupHookProvider.hz.getMap("tokens");
Deque<String> userIdDeque = exchange.getQueryParameters().get("userId");
String userId = userIdDeque == null? "%" : userIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
if(logger.isDebugEnabled()) logger.debug("userId = " + userId + " page = " + page + " pageSize = " + pageSize);
LikePredicate likePredicate = new LikePredicate("userId", userId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new RefreshTokenComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<RefreshToken> values = tokens.values(pagingPredicate);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例2: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String refreshToken = exchange.getQueryParameters().get("refreshToken").getFirst();
if(logger.isDebugEnabled()) logger.debug("refreshToken = " + refreshToken);
IMap<String, RefreshToken> tokens = CacheStartupHookProvider.hz.getMap("tokens");
RefreshToken token = tokens.get(refreshToken);
if(token == null) {
Status status = new Status(REFRESH_TOKEN_NOT_FOUND, refreshToken);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(token));
}
示例3: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String userId = exchange.getQueryParameters().get("userId").getFirst();
IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
User user = users.get(userId);
if(user == null) {
Status status = new Status(USER_NOT_FOUND, userId);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
// remove password here
user.setPassword(null);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(user));
}
示例4: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
Deque<String> userIdDeque = exchange.getQueryParameters().get("userId");
String userId = userIdDeque == null? "%" : userIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("userId", userId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new UserComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<User> values = users.values(pagingPredicate);
for (User value : values) {
value.setPassword(null);
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例5: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, Service> services = CacheStartupHookProvider.hz.getMap("services");
Deque<String> serviceIdDeque = exchange.getQueryParameters().get("serviceId");
String serviceId = serviceIdDeque == null? "%" : serviceIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("serviceId", serviceId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new ServiceComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<Service> values = services.values(pagingPredicate);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例6: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String serviceId = exchange.getQueryParameters().get("serviceId").getFirst();
IMap<String, Service> services = CacheStartupHookProvider.hz.getMap("services");
Service service = services.get(serviceId);
if(service == null) {
Status status = new Status(SERVICE_NOT_FOUND, serviceId);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(service));
}
示例7: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String clientId = exchange.getQueryParameters().get("clientId").getFirst();
IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");
Client client = clients.get(clientId);
if(client == null) {
Status status = new Status(CLIENT_NOT_FOUND, clientId);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
Client c = Client.copyClient(client);
c.setClientSecret(null);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(c));
}
示例8: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");
Deque<String> clientNameDeque = exchange.getQueryParameters().get("clientName");
String clientName = clientNameDeque == null? "%" : clientNameDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("clientName", clientName);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new ClientComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<Client> values = clients.values(pagingPredicate);
List results = new ArrayList();
for (Client value : values) {
Client c = Client.copyClient(value);
c.setClientSecret(null);
results.add(c);
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(results));
}
示例9: handle
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public ByteBuffer handle(Object input) {
Map<String, String> map = (Map<String, String>)input;
String host = map.get("host");
String path = map.get("path");
String token = map.get("token");
String environment = map.get("environment");
try {
Map<String, Object> si = ServerInfoRetriever.retrieve(host, path, token);
List<Issue> list = ServerInfoProcessor.process(si);
return NioUtils.toByteBuffer(Config.getInstance().getMapper().writeValueAsString(list));
} catch (Exception e) {
String error = "";
try {
error = Config.getInstance().getMapper().writeValueAsString(e.getStackTrace());
} catch (Exception er) {
logger.error("Exception:", e);
}
return NioUtils.toByteBuffer(error);
}
}
示例10: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String id = exchange.getQueryParameters().get("id").getFirst();
ObjectMapper mapper = new ObjectMapper();
Map s = (Map)exchange.getAttachment(BodyHandler.REQUEST_BODY);
String json = mapper.writeValueAsString(s);
UserDto user = mapper.readValue(json, UserDto.class);
CompletableFuture<User> result = service.update(id, user).thenApply((e) -> {
User m = new User();
m.setId(e.getEntityId());
m.setHost(e.getAggregate().getUser().getHost());
m.setScreenName(e.getAggregate().getUser().getScreenName());
m.getContactData().setEmail(e.getAggregate().getUser().getContactData().getEmail());
return m;
});
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(result.get()));
}
示例11: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String name = exchange.getQueryParameters().get("name").getFirst();
Optional<User> user = service.findUser(name);
String result = null;
if (user.isPresent()) {
result = Config.getInstance().getMapper().writeValueAsString(service.toUserDto(user.get()));
} else {
result = "No user find for the screenName:" + name;
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(result);
}
示例12: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String email = exchange.getQueryParameters().get("email").getFirst();
Optional<User> user = service.findUser(email);
String result = null;
if (user.isPresent()) {
result = Config.getInstance().getMapper().writeValueAsString(service.toUserDto(user.get()));
} else {
result = NO_USER_USER_EMAIL;
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(result);
// exchange.endExchange();
}
示例13: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String id = exchange.getQueryParameters().get("id").getFirst();
Optional<User> user = service.findUser(id);
String result = null;
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
if (user.isPresent()) {
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(service.toUserDto(user.get())));
} else {
result = "No user find for the Id:" + id;
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(result));
}
// exchange.endExchange();
}
示例14: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String id = exchange.getQueryParameters().get("id").getFirst();
int rec = service.delete(id);
String result = null;
if (rec > 0) {
result = "Deleted user: " + id;
} else {
result = "No Such User:" + id;
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(result));
// exchange.endExchange();
}
示例15: handleRequest
import com.networknt.config.Config; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String id = exchange.getQueryParameters().get("id").getFirst();
String result = null;
try {
User user = service.confirmEmail(id);
if (user == null) {
result = "no user active by the token";
} else {
result = "user active: " + user.getScreenName();
}
} catch(NoSuchUserException e) {
result = "no Such User";
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(result));
// exchange.endExchange();
}