private String serviceAddress(Class<?> type) { Service service = type.getAnnotation(Service.class); if (service != null && ! service.value().isEmpty()) { return service.value(); } for (Annotation ann : type.getAnnotations()) { service = ann.annotationType().getAnnotation(Service.class); if (service != null && ! service.value().isEmpty()) { return service.value(); } } return ""; }
private String tableName(Class<T> type, Asset table, Service serviceTable) { String tableName; if (serviceTable != null && ! serviceTable.value().isEmpty()) { tableName = serviceTable.value(); tableName = tableName.substring(1); tableName = tableName.replace('/', '_'); } else if (table != null && !table.value().isEmpty()) { tableName = table.value(); } else { tableName = type.getSimpleName(); } return tableName; }
public String address() { Service service = getService(); if (service == null) return null; String address = service.value(); if (address == null) { String name = getType().getSimpleName(); if (name.endsWith("Impl")) name = name.substring(0, name.length() - 4); address = "/" + name; } return address; } }
private <T> void introspectService(WebBuilder builder, Method method, Supplier<Object> beanFactory) { Service service = method.getAnnotation(Service.class); Api api = method.getAnnotation(Api.class); String address = service.value(); /* if (address.isEmpty()) { address = "/" + apiClass.getSimpleName(); } */ Class<T> type = (Class<T>) method.getReturnType(); Supplier<T> supplier = ()->(T) newInstance(beanFactory,method); ServiceBuilder serviceBuilder = builder.service(type, supplier); if (api != null) { serviceBuilder.api(api.value()); } if (! address.isEmpty()) { serviceBuilder.address(address); } Workers workers = method.getAnnotation(Workers.class); if (workers != null) { serviceBuilder.workers(workers.value()); } }
private void addAssetConverter(Class<?> api) { TypeRef resourceRef = TypeRef.of(api).to(Vault.class); Class<?> idType = resourceRef.param(0).rawClass(); Class<?> itemType = resourceRef.param(1).rawClass(); Service service = api.getAnnotation(Service.class); String address = ""; if (service != null) { address = service.value(); } if (address.isEmpty()) { address = "/" + itemType.getSimpleName(); } TypeRef convertRef = TypeRef.of(Convert.class, String.class, itemType); Convert<String,?> convert = new ConvertAsset(address, itemType); bean(convert).to(Key.of(convertRef.type())); }
String address = service.value();
@Override public <T> Provider<T> provider(Injector manager, InjectionPoint<T> ip) { Service service = ip.annotation(Service.class); Class<T> rawClass = ip.key().rawClass(); if (service == null) { service = metaService(ip.key()); } if (service == null) { service = rawClass.getAnnotation(Service.class); } if (service == null) { return null; } String address = getManager().address(rawClass, service.value()); if (address != null && ! address.isEmpty()) { T proxy = getManager().service(address).as(rawClass); return ()->proxy; } else { return null; } }
if (_address == null && service.value().length() > 0) { addressAuto(serviceClass);