Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2008

Interceptor builder

    XMLWordPrintable

    Details

      Description

      I was thinking that similarly to BeanBuilder we currently have, we could provide a builder for Interceptors. For the interceptor case it would be much simpler since much of the Bean metadata does not make sense for interceptors (e.g. scope, name, alternative, etc.). The usage could look something like this:

      .addInterceptor()
          .interceptingWith(InterceptionType.AROUND_INVOKE, (context) -> {
              System.out.println("entering " + context.getMethod());
              final Object result = context.proceed();
              System.out.println("leaving " + context.getMethod());
              return result;
          })
          .bindings(Debug.Literal.INSTANCE);
      

      We would probably need some support for state propagation - the sample above is completely stateless.

      This is still a very rough idea so any feedback is welcome.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tremes Tomas Remes
              Reporter:
              jharting Jozef Hartinger
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: