BeanComponentImplementationModel beanModel = new V1BeanComponentImplementationModel(beanNamespace.uri());
beanModel.setClazz(serviceClass.getName());
componentModel.setImplementation(beanModel);
Service service = serviceClass.getAnnotation(Service.class);
if (service != null) {
Class<?> iface = service.value();
if (iface == Service.class) {
Class<?>[] interfaces = serviceClass.getInterfaces();
if (interfaces.length == 1) {
iface = interfaces[0];
} else {
throw BeanMessages.MESSAGES.unexpectedExceptionTheServiceAnnotationHasNoValueItCannotBeOmmittedUnlessTheBeanImplementsExactlyOneInterface();
}
}
InterfaceModel csiModel = new V1InterfaceModel(InterfaceModel.JAVA);
if (service.name().equals(Service.EMPTY)) {
name = iface.getSimpleName();
} else {
name = service.name();
}
serviceModel.setName(name);
serviceModel.setInterface(csiModel);
csiModel.setInterface(iface.getName());