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 <[email protected]> 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 <[email protected]> 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 <[email protected]>
>> <[email protected]> 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_
>>
>>
>>