JaxrsConfigEndpoint { @GET @Produces({ APPLICATION_JSON }) @Path("getSingleton/{className}") public JaxrsObject getSingleton(@PathParam("className") String className) throws AbortRuntimeException { try { Optional<?> optional = admin.get(Class.forName(className, true, ClassLoaderHolder.getClassLoader())); if (optional.isPresent()) { return new JaxrsObject(optional.get()); } throw new WebApplicationException(Status.NOT_FOUND); } catch (ClassNotFoundException e) { throw Events.CFG101_SCHEMA_NOT_EXIST(className); } } @Inject  JaxrsConfigEndpoint(AdminContext admin); @GET @Produces({ APPLICATION_JSON }) @Path("getBean/{schemaName}/{id}") JaxrsBean getBean(@PathParam("schemaName") String schemaName,
                        @PathParam("id") String id); @GET @Produces({ APPLICATION_JSON }) @Path("getSingleton/{className}") JaxrsObject getSingleton(@PathParam("className") String className); @GET @Produces({ APPLICATION_JSON }) @Path("getObject/{className}/{id}") JaxrsObject getObject(@PathParam("className") String className,
                            @PathParam("id") String id); @GET @Produces({ APPLICATION_JSON }) @Path("listBean/{schemaName}") JaxrsBeans listBean(@PathParam("schemaName") String schemaName); @GET @Produces({ APPLICATION_JSON }) @Path("listObjects/{className}") JaxrsObjects listObjects(@PathParam("className") String className); @GET @Produces({ APPLICATION_JSON }) @Path("listBeans/{schemaName}") JaxrsBeans listBeans(@PathParam("schemaName") String schemaName,
                                @QueryParam("id") final List<String> ids); @POST @Consumes({ APPLICATION_JSON }) @Path("createBean") void createBean(JaxrsBean jaxrsBean); @POST @Consumes({ APPLICATION_JSON }) @Path("createObject") void createObject(JaxrsObject jaxrsObject); @POST @Consumes({ APPLICATION_JSON }) @Path("createBeans") void createBeans(JaxrsBeans jaxrsBeans); @POST @Consumes({ APPLICATION_JSON }) @Path("createObjects") void createObjects(JaxrsObjects jaxrsObjects); @POST @Consumes({ APPLICATION_JSON }) @Path("setBean") void setBean(JaxrsBean jaxrsBean); @POST @Consumes({ APPLICATION_JSON }) @Path("setObject") void setObject(JaxrsObject jaxrsObject); @POST @Consumes({ APPLICATION_JSON }) @Path("setBeans") void setBeans(JaxrsBeans jaxrsBeans); @POST @Consumes({ APPLICATION_JSON }) @Path("setObjects") void setObjects(JaxrsObjects jaxrsObjects); @POST @Consumes({ APPLICATION_JSON }) @Path("mergeBean") void mergeBean(JaxrsBean jaxrsBean); @POST @Consumes({ APPLICATION_JSON }) @Path("mergeObject") void mergeObject(JaxrsObject jaxrsObject); @POST @Consumes({ APPLICATION_JSON }) @Path("mergeBeans") void mergeBeans(JaxrsBeans jaxrsBeans); @POST @Consumes({ APPLICATION_JSON }) @Path("mergeObjects") void mergeObjects(JaxrsObjects jaxrsObjects); @DELETE @Consumes({ "*/*" }) @Path("deleteBean/{schemaName}/{id}") void deleteBean(@PathParam("schemaName") String schemaName,
                           @PathParam("id") String id); @DELETE @Consumes({ "*/*" }) @Path("deleteBeans/{schemaName}") void deleteBeans(@PathParam("schemaName") String schemaName,
                            @QueryParam("id") final List<String> ids); @GET @Produces({ APPLICATION_JSON }) @Path("getSchemas") JaxrsSchemas getSchemas(); @GET @Produces({ APPLICATION_JSON }) @Path("getSchema/{schemaName}") JaxrsSchema getSchema(@PathParam("schemaName") String schemaName); @GET @Produces({ APPLICATION_JSON }) @Path("query/{schemaName}") JaxrsBeans query(@PathParam("schemaName") String schemaName, @QueryParam("q") String query,
                            @QueryParam("first") String first, @QueryParam("max") int max); static final String PATH; }
@Test public void testGetSingleton() { Optional<Singleton> optional = admin.get(Singleton.class); assertFalse(optional.isPresent()); Singleton s = new Singleton(); Bean bs = toBean(s); admin.create(bs); Optional<Bean> bean = admin.get(s.getBeanId()); assertTrue(bean.isPresent()); assertReflectionEquals(bs, bean.get(), LENIENT_ORDER); }