• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Inflector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.glassfish.jersey.process.Inflector的典型用法代码示例。如果您正苦于以下问题:Java Inflector类的具体用法?Java Inflector怎么用?Java Inflector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Inflector类属于org.glassfish.jersey.process包,在下文中一共展示了Inflector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: removeConstrHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> removeConstrHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String type = pathParam(Config._TYPE, ctx);
			String field = pathParam("field", ctx);
			String cname = pathParam("cname", ctx);
			if (app != null) {
				if (app.removeValidationConstraint(type, field, cname)) {
					app.update();
				}
				return Response.ok(app.getAllValidationConstraints(type)).build();
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:22,代码来源:Api1.java


示例2: getResourceMethod

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
private ResourceMethod getResourceMethod() {

        org.glassfish.jersey.server.model.Resource.Builder resourceBuilder = org.glassfish.jersey.server.model.Resource.builder();
        resourceBuilder.path("/helloworld/{id}");
        org.glassfish.jersey.server.model.ResourceMethod resourceMethod =
                resourceBuilder
                        .addMethod("GET")
                        .consumes(MediaType.APPLICATION_JSON_TYPE)
                        .produces(MediaType.APPLICATION_JSON_TYPE)
                        .handledBy(new Inflector<ContainerRequestContext, Object>() {
                            @Override
                            public Object apply(ContainerRequestContext containerRequestContext) {
                                return "HELLO";
                            }
                        })
                        .build();


        Resource resource = new Resource(resourceBuilder.build());

        return resource.getResourceMethods().get(0);
    }
 
开发者ID:lambadaframework,项目名称:lambadaframework,代码行数:23,代码来源:RouterTypeTest.java


示例3: typeCrudHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
private Inflector<ContainerRequestContext, Response> typeCrudHandler() {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			String typePlural = pathParam(Config._TYPE, ctx);
			App app = getPrincipalApp();
			if (app != null && !StringUtils.isBlank(typePlural)) {
				String type = ParaObjectUtils.getAllTypes(app).get(typePlural);
				if (type == null) {
					type = typePlural;
				}
				return crudHandler(app, type).apply(ctx);
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:17,代码来源:Api1.java


示例4: meHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> meHandler() {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			if (GET.equals(ctx.getMethod())) {
				User user = SecurityUtils.getAuthenticatedUser();
				App app = SecurityUtils.getAuthenticatedApp();
				if (user != null) {
					return Response.ok(user).build();
				} else if (app != null) {
					return Response.ok(app).build();
				}
			}
			return Response.status(Response.Status.UNAUTHORIZED).build();
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:20,代码来源:Api1.java


示例5: getConstrHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> getConstrHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String type = pathParam(Config._TYPE, ctx);
			if (app != null) {
				if (type != null) {
					return Response.ok(app.getAllValidationConstraints(type)).build();
				} else {
					return Response.ok(app.getAllValidationConstraints()).build();
				}
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:21,代码来源:Api1.java


示例6: addConstrHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
@SuppressWarnings("unchecked")
public static Inflector<ContainerRequestContext, Response> addConstrHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String type = pathParam(Config._TYPE, ctx);
			String field = pathParam("field", ctx);
			String cname = pathParam("cname", ctx);
			if (app != null) {
				Response payloadRes = getEntity(ctx.getEntityStream(), Map.class);
				if (payloadRes.getStatusInfo() == Response.Status.OK) {
					Map<String, Object> payload = (Map<String, Object>) payloadRes.getEntity();
					if (app.addValidationConstraint(type, field, Constraint.build(cname, payload))) {
						app.update();
					}
				}
				return Response.ok(app.getAllValidationConstraints(type)).build();
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:27,代码来源:Api1.java


示例7: getPermitHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> getPermitHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String subjectid = pathParam("subjectid", ctx);
			if (app != null) {
				if (subjectid != null) {
					return Response.ok(app.getAllResourcePermissions(subjectid)).build();
				} else {
					return Response.ok(app.getAllResourcePermissions()).build();
				}
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:21,代码来源:Api1.java


示例8: checkPermitHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> checkPermitHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String subjectid = pathParam("subjectid", ctx);
			String resourcePath = pathParam(Config._TYPE, ctx);
			String httpMethod = pathParam("method", ctx);
			if (app != null) {
				return Response.ok(app.isAllowedTo(subjectid, resourcePath, httpMethod),
						MediaType.TEXT_PLAIN_TYPE).build();
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:20,代码来源:Api1.java


示例9: revokePermitHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> revokePermitHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String subjectid = pathParam("subjectid", ctx);
			String type = pathParam(Config._TYPE, ctx);
			if (app != null) {
				boolean revoked;
				if (type != null) {
					revoked = app.revokeResourcePermission(subjectid, type);
				} else {
					revoked = app.revokeAllResourcePermissions(subjectid);
				}
				if (revoked) {
					app.update();
				}
				return Response.ok(app.getAllResourcePermissions(subjectid)).build();
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:27,代码来源:Api1.java


示例10: setupHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
private Inflector<ContainerRequestContext, Response> setupHandler() {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			String appid = pathParam(Config._APPID, ctx);
			if (!StringUtils.isBlank(appid)) {
				App app = SecurityUtils.getAuthenticatedApp();
				if (app != null && app.isRootApp()) {
					boolean sharedIndex = "true".equals(queryParam("sharedIndex", ctx));
					boolean sharedTable = "true".equals(queryParam("sharedTable", ctx));
					return Response.ok(newApp(appid, queryParam("name", ctx), sharedIndex, sharedTable)).build();
				} else {
					return getStatusResponse(Response.Status.FORBIDDEN,
							"Only root app can create and initialize other apps.");
				}
			}
			return Response.ok(setup()).build();
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:20,代码来源:Api1.java


示例11: batchUpdateHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
@SuppressWarnings("unchecked")
public static Inflector<ContainerRequestContext, Response> batchUpdateHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			Response entityRes = getEntity(ctx.getEntityStream(), List.class);
			if (entityRes.getStatusInfo() == Response.Status.OK) {
				List<Map<String, Object>> newProps = (List<Map<String, Object>>) entityRes.getEntity();
				ArrayList<String> ids = new ArrayList<>(newProps.size());
				for (Map<String, Object> props : newProps) {
					ids.add((String) props.get(Config._ID));
				}
				return getBatchUpdateResponse(app, getDAO().readAll(app.getAppIdentifier(), ids, true), newProps);
			} else {
				return entityRes;
			}
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:24,代码来源:Api1.java


示例12: getJAXRSParser

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
protected JAXRSParser getJAXRSParser() {

        List<Resource> resourceList = new LinkedList<>();
        org.glassfish.jersey.server.model.Resource.Builder resourceBuilder = org.glassfish.jersey.server.model.Resource.builder();
        resourceBuilder.path("/{id}");
        ResourceMethod resourceMethod = resourceBuilder
                .addMethod("GET")
                .handledBy(new Inflector<ContainerRequestContext, Object>() {
                    @Override
                    public Object apply(ContainerRequestContext containerRequestContext) {
                        return "HELLO";
                    }
                })
                .build();

        resourceList.add(new Resource(resourceBuilder.build()));
        JAXRSParser mockJaxRSParser = PowerMock.createMock(JAXRSParser.class);
        expect(mockJaxRSParser.scan())
                .andReturn(resourceList)
                .anyTimes();

        expect(mockJaxRSParser.withPackageName(anyString(),
                anyObject(Class.class)))
                .andReturn(mockJaxRSParser)
                .anyTimes();

        PowerMock.replayAll();
        return mockJaxRSParser;
    }
 
开发者ID:lambadaframework,项目名称:lambadaframework,代码行数:30,代码来源:RouterTest.java


示例13: registerCrudApi

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
private void registerCrudApi(String path, Inflector<ContainerRequestContext, Response> handler,
		Inflector<ContainerRequestContext, Response> linksHandler) {
	Resource.Builder core = Resource.builder(path);
	// list endpoints (both do the same thing)
	core.addMethod(GET).produces(JSON).handledBy(handler);
	core.addChildResource("search/{querytype}").addMethod(GET).produces(JSON).handledBy(handler);
	core.addChildResource("search").addMethod(GET).produces(JSON).handledBy(handler);
	// CRUD endpoints (non-batch)
	core.addMethod(POST).produces(JSON).consumes(JSON).handledBy(handler);
	core.addChildResource("{id}").addMethod(GET).produces(JSON).handledBy(handler);
	core.addChildResource("{id}").addMethod(PUT).produces(JSON).consumes(JSON).handledBy(handler);
	core.addChildResource("{id}").addMethod(PATCH).produces(JSON).consumes(JSON).handledBy(handler);
	core.addChildResource("{id}").addMethod(DELETE).produces(JSON).handledBy(handler);
	// links CRUD endpoints
	core.addChildResource("{id}/links/{type2}/{id2}").addMethod(GET).produces(JSON).handledBy(linksHandler);
	core.addChildResource("{id}/links/{type2}").addMethod(GET).produces(JSON).handledBy(linksHandler);
	core.addChildResource("{id}/links/{id2}").addMethod(POST).produces(JSON).handledBy(linksHandler);
	core.addChildResource("{id}/links/{id2}").addMethod(PUT).produces(JSON).handledBy(linksHandler);
	core.addChildResource("{id}/links/{type2}/{id2}").addMethod(DELETE).produces(JSON).handledBy(linksHandler);
	core.addChildResource("{id}/links").addMethod(DELETE).produces(JSON).handledBy(linksHandler);
	// CRUD endpoints (batch)
	Resource.Builder batch = Resource.builder("_batch");
	batch.addMethod(POST).produces(JSON).consumes(JSON).handledBy(batchCreateHandler(null));
	batch.addMethod(GET).produces(JSON).handledBy(batchReadHandler(null));
	batch.addMethod(PUT).produces(JSON).consumes(JSON).handledBy(batchCreateHandler(null));
	batch.addMethod(PATCH).produces(JSON).consumes(JSON).handledBy(batchUpdateHandler(null));
	batch.addMethod(DELETE).produces(JSON).handledBy(batchDeleteHandler(null));

	registerResources(core.build());
	registerResources(batch.build());
}
 
开发者ID:Erudika,项目名称:para,代码行数:32,代码来源:Api1.java


示例14: introHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
private Inflector<ContainerRequestContext, Response> introHandler() {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			Map<String, String> info = new TreeMap<>();
			info.put("info", "Para - the backend for busy developers.");
			if (Config.getConfigBoolean("print_version", true)) {
				info.put("version", StringUtils.replace(getVersion(), "-SNAPSHOT", ""));
			}
			return Response.ok(info).build();
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:13,代码来源:Api1.java


示例15: crudHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param app {@link App}
 * @param type a type
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> crudHandler(final App app, final String type) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			String id = pathParam(Config._ID, ctx);
			if (StringUtils.isBlank(id)) {
				if (GET.equals(ctx.getMethod())) {
					return searchHandler(app, type).apply(ctx);
				} else if (POST.equals(ctx.getMethod())) {
					return createHandler(app, type).apply(ctx);
				} else if (ctx.getUriInfo().getPath().contains("search")) {
					return searchHandler(app, type).apply(ctx);
				}
			} else {
				if (GET.equals(ctx.getMethod())) {
					return readHandler(app, type).apply(ctx);
				} else if (PUT.equals(ctx.getMethod())) {
					return overwriteHandler(app, type).apply(ctx);
				} else if (PATCH.equals(ctx.getMethod())) {
					return updateHandler(app, type).apply(ctx);
				} else if (DELETE.equals(ctx.getMethod())) {
					return deleteHandler(app, type).apply(ctx);
				}
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "Type '" + type + "' not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:33,代码来源:Api1.java


示例16: readIdHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @return response
 */
public static Inflector<ContainerRequestContext, Response> readIdHandler() {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = getPrincipalApp();
			String id = pathParam(Config._ID, ctx);
			if (app != null) {
				return getReadResponse(app, getDAO().read(app.getAppIdentifier(), id));
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:16,代码来源:Api1.java


示例17: grantPermitHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
@SuppressWarnings("unchecked")
public static Inflector<ContainerRequestContext, Response> grantPermitHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String subjectid = pathParam("subjectid", ctx);
			String resourcePath = pathParam(Config._TYPE, ctx);
			if (app != null) {
				Response resp = getEntity(ctx.getEntityStream(), List.class);
				if (resp.getStatusInfo() == Response.Status.OK) {
					List<String> permission = (List<String>) resp.getEntity();
					Set<App.AllowedMethods> set = new HashSet<>(permission.size());
					for (String perm : permission) {
						if (!StringUtils.isBlank(perm)) {
							App.AllowedMethods method = App.AllowedMethods.fromString(perm);
							if (method != null) {
								set.add(method);
							}
						}
					}
					if (!set.isEmpty()) {
						if (app.grantResourcePermission(subjectid, resourcePath, EnumSet.copyOf(set))) {
							app.update();
						}
						return Response.ok(app.getAllResourcePermissions(subjectid)).build();
					} else {
						return getStatusResponse(Response.Status.BAD_REQUEST, "No allowed methods specified.");
					}
				} else {
					return resp;
				}
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:41,代码来源:Api1.java


示例18: appSettingsHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
/**
 * @param a {@link App}
 * @return response
 */
@SuppressWarnings("unchecked")
public static Inflector<ContainerRequestContext, Response> appSettingsHandler(final App a) {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = (a != null) ? a : getPrincipalApp();
			String key = pathParam("key", ctx);
			if (app != null) {
				if (PUT.equals(ctx.getMethod())) {
					Response resp = getEntity(ctx.getEntityStream(), Map.class);
					if (resp.getStatusInfo() == Response.Status.OK) {
						Map<String, Object> setting = (Map<String, Object>) resp.getEntity();
						if (!StringUtils.isBlank(key) && setting.containsKey("value")) {
							app.addSetting(key, setting.get("value"));
						} else {
							app.clearSettings().addAllSettings(setting);
						}
						app.update();
						return Response.ok().build();
					} else {
						return getStatusResponse(Response.Status.BAD_REQUEST);
					}
				} else if (DELETE.equals(ctx.getMethod())) {
					app.removeSetting(key);
					app.update();
					return Response.ok().build();
				} else {
					if (StringUtils.isBlank(key)) {
						return Response.ok(app.getSettings()).build();
					} else {
						return Response.ok(Collections.singletonMap("value", app.getSetting(key))).build();
					}
				}
			}
			return getStatusResponse(Response.Status.FORBIDDEN, "Not allowed.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:42,代码来源:Api1.java


示例19: healthCheckHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
private static Inflector<ContainerRequestContext, Response> healthCheckHandler() {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			if (HealthUtils.getInstance().isHealthy()) {
				return Response.ok(Collections.singletonMap("message", "healthy")).build();
			} else {
				return getStatusResponse(Response.Status.INTERNAL_SERVER_ERROR, "unhealthy");
			}
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:12,代码来源:Api1.java


示例20: listTypesHandler

import org.glassfish.jersey.process.Inflector; //导入依赖的package包/类
private Inflector<ContainerRequestContext, Response> listTypesHandler() {
	return new Inflector<ContainerRequestContext, Response>() {
		public Response apply(ContainerRequestContext ctx) {
			App app = getPrincipalApp();
			if (app != null) {
				return Response.ok(ParaObjectUtils.getAllTypes(app)).build();
			}
			return getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
		}
	};
}
 
开发者ID:Erudika,项目名称:para,代码行数:12,代码来源:Api1.java



注:本文中的org.glassfish.jersey.process.Inflector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HLogRecordReader类代码示例发布时间:2022-05-22
下一篇:
Java GetDiagnosticsResponseProtoOrBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap