Repository: tomee Updated Branches: refs/heads/master f1f49d792 -> 7210ebd3a
Restore previously deleted files from SafeGuard. Not sure integration is good though. To be checked and finished possibly Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0ce22cbe Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0ce22cbe Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0ce22cbe Branch: refs/heads/master Commit: 0ce22cbe96d1ce815bff9baa9733073f0dc359f3 Parents: 85d7dbb Author: Jean-Louis Monteiro <[email protected]> Authored: Fri Dec 28 22:36:56 2018 +0100 Committer: Jean-Louis Monteiro <[email protected]> Committed: Fri Dec 28 22:36:56 2018 +0100 ---------------------------------------------------------------------- ...ilsafeContainerExecutionManagerProvider.java | 33 ++++++++++ ...feContainerExecutionManagerProviderTest.java | 69 ++++++++++++++++++++ 2 files changed, 102 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/0ce22cbe/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java new file mode 100644 index 0000000..baef59a --- /dev/null +++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java @@ -0,0 +1,33 @@ +package org.apache.tomee.microprofile.faulttolerance; +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import org.apache.safeguard.impl.customizable.Safeguard; + +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedScheduledExecutorService; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; + +@ApplicationScoped +public class FailsafeContainerExecutionManagerProvider { + @Resource + @Produces + @Safeguard + private ManagedScheduledExecutorService executor; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/0ce22cbe/tomee/tomee-microprofile/mp-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-microprofile/mp-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java b/tomee/tomee-microprofile/mp-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java new file mode 100644 index 0000000..a7677bd --- /dev/null +++ b/tomee/tomee-microprofile/mp-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java @@ -0,0 +1,69 @@ +package org.apache.tomee.microprofile.faulttolerance; + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.openejb.jee.WebApp; +import org.apache.openejb.junit.ApplicationComposer; +import org.apache.openejb.testing.Classes; +import org.apache.openejb.testing.Module; +import org.eclipse.microprofile.faulttolerance.CircuitBreaker; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.ejb.Singleton; +import javax.inject.Inject; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@RunWith(ApplicationComposer.class) +public class FailsafeContainerExecutionManagerProviderTest { + + @Inject + private FailsafeContainerExecutionManagerProvider manager; + + @Inject + private FTClass ftClass; + + @Module + @Classes(value = {FailsafeContainerExecutionManagerProvider.class, + FTClass.class}, + cdi = true) + public WebApp app() { + return new WebApp(); + } + + @Test + public void testManagerInjection() throws Exception { + + assertEquals("called", ftClass.validateInjectedClass()); + + assertTrue("We must override the original FailsafeExecutionManagerProvider, was:" + manager.getClass(), + manager instanceof FailsafeContainerExecutionManagerProvider); + } + + @Singleton + public static class FTClass { + + @CircuitBreaker + public String validateInjectedClass() { + return "called"; + } + } + +} \ No newline at end of file
