aesteve / nubes

Annotation layer on top of Vert.x 3
Apache License 2.0
121 stars 35 forks source link

@ServiceProxy(String) & @Proxify(String) #41

Closed aesteve closed 9 years ago

aesteve commented 9 years ago

Service proxies are a great feature of Vert.x 3

  1. When an interface is marked as @ProxyGen, a class is generated by the compiler to communicate through the event bus. But still, we have to create the code to mount it to a specific eventBus address.
  2. Another interface is generated to access the service on a specific address remotely.

Examples :

  1. https://github.com/aesteve/vertx-markdown-service/blob/master/src/main/java/io/vertx/markdown/MarkdownServiceVerticle.java#L17
  2. https://github.com/aesteve/vertx-markdown-service/blob/master/src/test/java/io/vertx/markdown/eventbus/GenerateThroughEventBusTest.java#L36

It would be very convenient to add two annotations to cover these use cases :

  1. The interface could be annotated with @Proxify("some.address") which would automatically look for the generated class, instanciate it and mount it like here
  2. Instead of @Service for dependency injection, we could just add @ServiceProxy("some.address") which would inject the proxified service into some class