public ContextMetaBuilder addService(final Class<?> serviceClass) { return addService(null, serviceClass); }
public VertxEventBusBridgeBuilder addBridgeAddress(String address, Class<?> classWithAnnotations) { if (addressesToBridge == null) { addressesToBridge = new HashSet<>(); } addressesToBridge.add(address); if (address == null) { contextMetaBuilder.setRootURI("/").addService(classWithAnnotations); } else { contextMetaBuilder.setRootURI("/").addService(address, classWithAnnotations); } return this; }
@Override public void addRestSupportFor(Class cls, String baseURI) { contextMetaBuilder.setRootURI(baseURI).addService(cls); }
@Override public void addRestSupportFor(String alias, Class<?> cls, String baseURI) { contextMetaBuilder.setRootURI(baseURI).addService(alias, cls); }
/** * Add an endpoint service * * @param endpointService endpoint service * @return this, fluent */ public ManagedServiceBuilder addEndpointService(final Object endpointService) { getContextMetaBuilder().addService(endpointService.getClass()); getEndpointServices().add(endpointService); return this; }
/** * Add endpoint service with alias * * @param alias alias * @param endpointService endpoint service * @return this, fluent */ public ManagedServiceBuilder addEndpointService(final String alias, final Object endpointService) { getContextMetaBuilder().addService(alias, endpointService.getClass()); getEndpointServiceMapWithAlias().put(alias, endpointService); return this; }
/** * Add an end point service with queue callback handlers * * @param endpointService endpoint Service * @param queueCallBackHandlers queue callback handlers * @return this, fluent */ public ManagedServiceBuilder addEndpointServiceWithQueueHandlerCallbacks(final Object endpointService, final QueueCallBackHandler... queueCallBackHandlers) { getContextMetaBuilder().addService(endpointService.getClass()); getManagedServiceDefinitionList().add(new ManagedServiceDefinition(null, endpointService, queueCallBackHandlers)); return this; }
/** * Add an end point service with queue callback handlers * * @param alias alias * @param endpointService endpoint Service * @param queueCallBackHandlers queue callback handlers * @return this, fluent */ public ManagedServiceBuilder addEndpointServiceWithAliasAndQueueHandlerCallbacks(final String alias, final Object endpointService, final QueueCallBackHandler... queueCallBackHandlers) { getContextMetaBuilder().addService(endpointService.getClass()); getManagedServiceDefinitionList().add(new ManagedServiceDefinition(alias, endpointService, queueCallBackHandlers)); return this; }
@Before public void setUp() throws Exception { contextMetaBuilder = ContextMetaBuilder.contextMetaBuilder(); contextMetaBuilder.addService(SampleService.class); provider = new StandardMetaDataProvider(contextMetaBuilder.build(), RequestMethod.GET); StandardMetaDataProvider postProvider = new StandardMetaDataProvider(contextMetaBuilder.build(), RequestMethod.POST); standardRequestTransformer = new StandardRequestTransformer( safeMap(RequestMethod.GET, provider, RequestMethod.POST, postProvider), Optional.empty() ); }
public ContextMetaBuilder addService(String alias, Class<?> serviceClass) { final ClassMeta<?> classMeta = ClassMeta.classMeta(serviceClass); String name = alias != null ? alias : getServiceName(classMeta); final List<String> requestPaths = getRequestPathsByAnnotated(classMeta, name); if (alias != null) { requestPaths.add(asPath(alias)); } final String description = getDescriptionFromRequestMapping(classMeta); final ServiceMetaBuilder serviceMetaBuilder = ServiceMetaBuilder.serviceMetaBuilder() .setRequestPaths(requestPaths).setName(name).setDescription(description) .setResponseHeaders(getResponseHeaders(classMeta)); serviceMetaBuilder.addMethods(this.getRootURI(), Lists.list(classMeta.methods())); addService(serviceMetaBuilder.build()); return this; }
@Before public void setUp() throws Exception { contextMetaBuilder = ContextMetaBuilder.contextMetaBuilder(); contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( SampleService.class); provider = new StandardMetaDataProvider(contextMetaBuilder.build(), RequestMethod.GET); }
contextMetaBuilder.addService(SampleService.class);
@Test public void testRequestHeaderWithParentHeaders() { ContextMetaBuilder contextMetaBuilder = ContextMetaBuilder.contextMetaBuilder(); contextMetaBuilder.addService(Foo1.class); final ServiceMeta serviceMeta = contextMetaBuilder.getServices().get(0); final Map<String, ServiceMethodMeta> serviceMethodMetaMap = Maps.toMap("name", serviceMeta.getMethods()); final ServiceMethodMeta serviceMethodMeta = serviceMethodMetaMap.get("methodWithHeaders"); final RequestMeta requestMeta = serviceMethodMeta.getRequestEndpoints().get(0); assertEquals("/headers", requestMeta.getRequestURI()); assertTrue(requestMeta.hasResponseHeaders()); MultiMap<String, String> headers = requestMeta.getResponseHeaders(); assertEquals(5, headers.size()); assertEquals("BAR", headers.getFirst("FOO")); assertEquals("1.BAR", headers.getFirst("1.FOO")); assertEquals("2.BAR2", headers.getFirst("2.FOO2")); final List<String> controls = (List<String>) headers.getAll(HttpHeaders.CACHE_CONTROL); assertEquals("max-age=0", controls.get(0)); assertEquals("no-cache, no-store", controls.get(1)); }
@Test public void testBuild() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService(service("myService", "/myservice", method( "hello", getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ) ) )); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
public ContextMetaBuilder getAdminContextBuilder() { if (adminContextBuilder == null) { adminContextBuilder = ContextMetaBuilder.contextMetaBuilder(); adminContextBuilder.setDescription("QBit Admin interface, used to administrate and query status of QBit services"); adminContextBuilder.setTitle("QBit Admin interface"); adminContextBuilder.setVersion("0.9"); adminContextBuilder.setLicenseURL("https://github.com/advantageous/qbit/blob/master/License"); adminContextBuilder.setContactURL("http://www.mammatustech.com/"); adminContextBuilder.setRootURI(this.getEndpointServerBuilder().getUri()); if (this.getEndpointServerBuilder().getHost() != null) { adminContextBuilder.setHostAddress(this.getEndpointServerBuilder().getHost() + ":" + this.getEndpointServerBuilder().getPort()); } else { adminContextBuilder.setHostAddress("localhost:" + this.getEndpointServerBuilder().getPort()); } adminContextBuilder.addService(Admin.class); } return adminContextBuilder; }
@Test public void testBuildNestedBuilder() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod(method("hello", getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ) )) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Test public void testBuildNestedBuilder2() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod( serviceMethodMetaBuilder().setName("hello") .addRequestEndpoint(getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) )).build() ) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Before public void setUp() throws Exception { contextMetaBuilder = ContextMetaBuilder.contextMetaBuilder(); contextMetaBuilder.setContactEmail("rick@rick.com"); contextMetaBuilder.setContactName("Rick Hightower"); contextMetaBuilder.setContactURL("https://github.com/advantageous/qbit"); contextMetaBuilder.setHostAddress("localhost:9090"); contextMetaBuilder.setDescription("Test set of services"); contextMetaBuilder.setLicenseName("APACHE 2"); contextMetaBuilder.setLicenseURL("https://github.com/advantageous/qbit/blob/master/License"); metaToSwagger = new MetaTransformerFromQbitMetaToSwagger(); contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService(SampleService.class); final ContextMeta context = contextMetaBuilder.build(); final ServiceEndpointInfo serviceEndpointInfo = metaToSwagger.serviceEndpointInfo(context); JsonSerializer jsonSerializer = new JsonSerializerFactory().setUseAnnotations(true).create(); System.out.println(jsonSerializer.serialize(serviceEndpointInfo)); }
@Test public void testBuildNestedBuilder3() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod( serviceMethodMetaBuilder().setName("hello") .addRequestEndpoint( requestMetaBuilder().setRequestURI("/callme/").addParameters( stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ).build() ).build() ) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
public ContextMetaBuilder addService(final Class<?> serviceClass) { final ClassMeta<?> classMeta = ClassMeta.classMeta(serviceClass); String name = getServiceName(classMeta); final List<String> requestPaths = getRequestPathsByAnnotated(classMeta, name); final String description = getDescriptionFromRequestMapping(classMeta); final ServiceMetaBuilder serviceMetaBuilder = ServiceMetaBuilder.serviceMetaBuilder() .setRequestPaths(requestPaths).setName(name).setDescription(description) .setResponseHeaders(getResponseHeaders(classMeta)); serviceMetaBuilder.addMethods(this.getRootURI(), Lists.list(classMeta.methods())); addService(serviceMetaBuilder.build()); return this; }