当前位置: 首页>>代码示例>>Java>>正文


Java Inflector类代码示例

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


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


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