Uploaded image for project: 'Solder'
  1. Solder
  2. SOLDER-51

Decouple service handler annotation from implementation class

    Details

    • Type: Feature Request
    • Status: Open (View Workflow)
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Affects:
      Documentation (Ref Guide, User Guide, etc.)
    • Estimated Difficulty:
      Medium

      Description

      The current design of the service handler configuration prevents modules from being able to deliver a service annotation in the api since it requires a direct reference to the implementation class.

      @ServiceHandler(MyServiceHandler.class)

      Switch to either a string or adopt the annotation binding concept from CDI (like interceptors)

      Also, support the use of the service handler annotation on stereotypes.

        Gliffy Diagrams

          Activity

          Hide
          dan.j.allen Dan Allen added a comment -

          I really like the idea of using the binding annotations for service handlers...that makes them just like interceptor bindings, so that should be easier for people to understand in the long run.

          Show
          dan.j.allen Dan Allen added a comment - I really like the idea of using the binding annotations for service handlers...that makes them just like interceptor bindings, so that should be easier for people to understand in the long run.
          Hide
          swd847 Stuart Douglas added a comment -

          If we used the binding approach it would also open up the possibility of a chain of servicehandlers. Not sure how ordering would work though.

          Show
          swd847 Stuart Douglas added a comment - If we used the binding approach it would also open up the possibility of a chain of servicehandlers. Not sure how ordering would work though.
          Hide
          dan.j.allen Dan Allen added a comment -

          For ordering, I'd use the same approach as with interceptors, you order them in XML (via Seam Config). Unlike interceptors, though, I like the idea of enabling them by default and only if you order them, do you control them enabled or not (empty element disables all).

          <service-handlers>
          <class>...</class>
          </service-handlers>

          Show
          dan.j.allen Dan Allen added a comment - For ordering, I'd use the same approach as with interceptors, you order them in XML (via Seam Config). Unlike interceptors, though, I like the idea of enabling them by default and only if you order them, do you control them enabled or not (empty element disables all). <service-handlers> <class>...</class> </service-handlers>
          Hide
          pmuir Pete Muir added a comment -

          I would suggest we just do what interceptors do here. I know that the interceptors enabling/ordering problem is a major one, however given that we intend to fix this in CDI 1.1, anything we do here will likely have to be aligned to that later on. IOW consistency is most important here.

          Show
          pmuir Pete Muir added a comment - I would suggest we just do what interceptors do here. I know that the interceptors enabling/ordering problem is a major one, however given that we intend to fix this in CDI 1.1, anything we do here will likely have to be aligned to that later on. IOW consistency is most important here.
          Hide
          dan.j.allen Dan Allen added a comment -

          Got it, makes sense.

          What's interesting is that CDI made a point about introducing a new type of interceptor, a decorator. We'll, thanks to you guys, we've got a second type that was previously missing

          Show
          dan.j.allen Dan Allen added a comment - Got it, makes sense. What's interesting is that CDI made a point about introducing a new type of interceptor, a decorator. We'll, thanks to you guys, we've got a second type that was previously missing
          Hide
          dan.j.allen Dan Allen added a comment -

          The service handler should get "bound" to the type using the same strategy as is used for interceptor binding.

          Binding type:

          @Target({ METHOD, TYPE })
          @Retention(RetentionPolicy.RUNTIME)
          @ServiceHandlerBindingType
          public @interface EchoService {}
          

          Invocation handler:

          @ServiceHandlerBindingType
          @EchoService
          public class EchoServiceHandler {
              @AroundInvoke
              public Object invoke(InvocationContext ctx) {
                  return ctx.getMethod().getName().toString();
              }
          }
          

          Usage:

          @EchoService
          public interface HelloWorld {
             String helloWorld();
          }
          

          Show
          dan.j.allen Dan Allen added a comment - The service handler should get "bound" to the type using the same strategy as is used for interceptor binding. Binding type: @Target ({ METHOD, TYPE }) @Retention (RetentionPolicy.RUNTIME) @ServiceHandlerBindingType public @interface EchoService {} Invocation handler: @ServiceHandlerBindingType @EchoService public class EchoServiceHandler { @AroundInvoke public Object invoke(InvocationContext ctx) { return ctx.getMethod().getName().toString(); } } Usage: @EchoService public interface HelloWorld { String helloWorld(); }

            People

            • Assignee:
              Unassigned
              Reporter:
              dan.j.allen Dan Allen
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:

                Development