I'd be ok with creating a module to include your class file. We'd probably
just want to keep an eye on it so it doesn't become a bucket of random
stuff - so I could see it becoming tomee-microprofile-fault-tolerance, or
something like that. Is it just one class file for the module?

Jon

On Sun, Nov 18, 2018 at 12:55 PM Bruno Baptista <bruno...@gmail.com> wrote:

> Hi All,
>
> I came up with a test that successfully overrides the original
> /FailsafeExecutionManagerProvider/ Safeguard class.
>
> It was a bit of a surprise but, in this case, beans.xml is useless
> because "The alternatives that you specify in the |beans.xml| file apply
> only to classes in the same archive." see:
> https://docs.oracle.com/javaee/7/tutorial/cdi-adv002.htm
>
> Because the beans are in different jar files, priority has to be used
> instead:
>
> @Priority(Interceptor.Priority.APPLICATION+10)
>
> The precise priority might need to be fine tuned because of the fault
> tolerance interceptor... Will have to test the final behavior.
>
> Also, we probably need to reorganize the tomee-microprofile-webapp
> project...
> This is needed because the code overriding the bean needs to be in a
> library and this project only creates a war file, which is in fact a
> container for the bundled libraries. The classes we place in there will
> not be in the final server.
>
> I'm thinking on something like:
>
> tomee
> |
> --- tomee-microprofile
>                                     |
>                                      --- tomee-microprofile-common (The
> JAR to be included in .../lib)
>                                     |
>                                      --- tomee-microprofile-webapp (The
> same as now with an additional dependency)
>
> Cheers.
>
> Bruno Baptista
> http://twitter.com/brunobat_
>
>
> On 16/11/18 16:26, Bruno Baptista wrote:
> >
> > Hi Romain,
> >
> > Yeah... @Resource would be the right thing to use in order to inject
> > the managed resource. Something like this:
> >
> > @Resource(name = "DefaultManagedScheduledExecutorService")
> > private ManagedScheduledExecutorService executor;
> >
> > Creating the test now.
> > Thanks for the help Romain.
> >
> > Bruno Baptista
> > http://twitter.com/brunobat_
> >
> >
> > On 16/11/18 16:07, Romain Manni-Bucau wrote:
> >> FYI this works:
> >>
> >>
> >> @ApplicationScoped
> >> public class CustomProvider extends FailsafeExecutionManagerProvider {
> >>      @Override
> >>      @Produces
> >>      @Specializes
> >>      @ApplicationScoped
> >>      public ExecutionManager createExecutionManager() {
> >>          return new FailsafeExecutionManager() {
> >>              @Override // hardcoded impl for testing purposes
> >>              public Object execute(final InvocationContext
> invocationContext) {
> >>                  return "replaced";
> >>              }
> >>          };
> >>      }
> >> }
> >>
> >>
> >> Side note: did you want to use @Resource for the executor injection?
> >>
> >> Romain Manni-Bucau
> >> @rmannibucau<https://twitter.com/rmannibucau>  |  Blog
> >> <https://rmannibucau.metawerx.net/>  | Old Blog
> >> <http://rmannibucau.wordpress.com>  | Github<
> https://github.com/rmannibucau>  |
> >> LinkedIn<https://www.linkedin.com/in/rmannibucau>  | Book
> >> <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >>
> >>
> >> Le ven. 16 nov. 2018 à 14:54, Romain Manni-Bucau<rmannibu...@gmail.com>
> a
> >> écrit :
> >>
> >>> Hi Bruno,
> >>>
> >>> I assume the alternative is activated in the beans.xml? (if not try
> adding
> >>> a @Priority maybe or just drop the annotation which should be useless)
> >>>
> >>> If it is i'd start by writing a small test (with application composer)
> to
> >>> check if it is a bug in tomee cause this is how it must work
> >>>
> >>> Romain Manni-Bucau
> >>> @rmannibucau<https://twitter.com/rmannibucau>  |  Blog
> >>> <https://rmannibucau.metawerx.net/>  | Old Blog
> >>> <http://rmannibucau.wordpress.com>  | Github
> >>> <https://github.com/rmannibucau>  | LinkedIn
> >>> <https://www.linkedin.com/in/rmannibucau>  | Book
> >>> <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >>>
> >>>
> >>> Le ven. 16 nov. 2018 à 12:44, Bruno Baptista<bruno...@gmail.com>  a
> >>> écrit :
> >>>
> >>>> Hi Roman,
> >>>>
> >>>> This is what I did and it doesn't work. The original bean is always
> >>>> picked up:
> >>>>
> >>>> @Specializes@Alternative@ApplicationScopedpublic class
> FailsafeContainerExecutionManagerProvider extends
> FailsafeExecutionManagerProvider {
> >>>>
> >>>>      @Inject    private ManagedScheduledExecutorService executor;
> >>>>
> >>>>      @Produces    @ApplicationScoped    @Override    public
> ExecutionManager createExecutionManager() throws Exception {
> >>>>
> >>>>
> >>>>          final MicroprofileAnnotationMapper mapper =
> MicroprofileAnnotationMapper.getInstance();
> >>>>          final DefaultExecutorServiceProvider executorServiceProvider
> = new DefaultExecutorServiceProvider(executor);
> >>>>          final BulkheadManagerImpl bulkheadManager = new
> BulkheadManagerImpl();
> >>>>          final FailsafeCircuitBreakerManager circuitBreakerManager =
> new FailsafeCircuitBreakerManager();
> >>>>          final FailsafeRetryManager retryManager = new
> FailsafeRetryManager();
> >>>>
> >>>>          return new FailsafeExecutionManager(
> >>>>                  mapper,
> >>>>                  bulkheadManager,
> >>>>                  circuitBreakerManager,
> >>>>                  retryManager,
> >>>>                  new ExecutionPlanFactory(circuitBreakerManager,
> retryManager, bulkheadManager, mapper,
> >>>>                          executorServiceProvider),
> >>>>                  executorServiceProvider);
> >>>>      }
> >>>> }
> >>>>
> >>>>
> >>>> I feel that this needs to be done in a different way... Would you be
> able
> >>>> to point me to a similar override currently being done?
> >>>>
> >>>> Cheers
> >>>> Bruno Baptista
> >>>> https://twitter.com/brunobat_
> >>>> http://tomitribe.com
> >>>> https://tribestream.io
> >>>> Bruno Baptista
> >>>> http://twitter.com/brunobat_
> >>>>
> >>>>
> >>>> On 16/11/18 10:28, Romain Manni-Bucau wrote:
> >>>>
> >>>> Hi Bruno,
> >>>>
> >>>> it is a palin bean so @Specializes works, did you put it on the
> method?
> >>>>
> >>>> Romain Manni-Bucau
> >>>> @rmannibucau<https://twitter.com/rmannibucau>  <
> https://twitter.com/rmannibucau>  |  Blog<
> https://rmannibucau.metawerx.net/>  <https://rmannibucau.metawerx.net/>
> | Old Blog<http://rmannibucau.wordpress.com>  <
> http://rmannibucau.wordpress.com>  | Github<https://github.com/rmannibucau>
> <https://github.com/rmannibucau>  |
> >>>> LinkedIn<https://www.linkedin.com/in/rmannibucau>  <
> https://www.linkedin.com/in/rmannibucau>  | Book<
> https://www.packtpub.com/application-development/java-ee-8-high-performance>
> <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >>>>
> >>>>
> >>>> Le ven. 16 nov. 2018 à 11:00, Bruno Baptista<bruno...@gmail.com>  <
> bruno...@gmail.com>  a écrit :
> >>>>
> >>>>
> >>>> Hi all,
> >>>>
> >>>> We have a problem with the integration of the Safeguard Fault
> Tolerance
> >>>> library on TomEE 8 and I need help to solve it. This is a follow up to
> >>>> the original email thread, from Oct 3, in the Geronimo mailing list,
> >>>> where we decided to do perform the override in the container side.
> >>>>
> >>>> I need to override the starting point for the library, originally
> here:
> >>>>
> >>>>
> https://github.com/apache/geronimo-safeguard/blob/master/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/FailsafeExecutionManagerProvider.java
> >>>>
> >>>> Because it's not using a managed executor service from TomEE... Like
> >>>> this one: "java:comp/DefaultManagedScheduledExecutorService"
> >>>>
> >>>> I Expect to do the wiring in here
> >>>> .../apache-tomee/tomee/tomee-microprofile-webapp/src
> >>>>
> >>>> Like using a @Specializes bean or something, but I think we cannot do
> >>>> that there. Could someone help me wire up this new bean?
> >>>>
> >>>> I had a PR to fix this the lib itself but it was decided not to move
> >>>> with it. For the curious, it's here:
> https://github.com/apache/geronimo-safeguard/pull/2
> >>>>
> >>>> Cheers
> >>>> --
> >>>> Bruno Baptistahttp://twitter.com/brunobat_
> >>>>
> >>>>
> >>>>
>

Reply via email to