This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Observable<String> obs = new HelloWorldCommand().observe(); | |
| obs.subscribe((v) -> { | |
| System.out.println("onNext: " + v); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HelloWorldCommand extends HystrixCommand<String> { | |
| public HelloWorldCommand() { | |
| super(HystrixCommandGroupKey.Factory.asKey("HelloWorld")); | |
| } | |
| @Override | |
| protected String getFallback() { | |
| return "Good Bye"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HelloWorldCommand extends HystrixCommand<String> { | |
| public HelloWorldCommand() { | |
| super(HystrixCommandGroupKey.Factory.asKey("HelloWorld")); | |
| } | |
| @Override | |
| protected String getFallback() { | |
| return "Good Bye"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void should_execute_fallback_method_when_circuit_is_open() { | |
| //Initialize HystrixRequestContext to be able to get some metrics | |
| HystrixRequestContext context = HystrixRequestContext.initializeContext(); | |
| HystrixCommandMetrics creditCardMetrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey(HelloWorldRestCommand.class.getSimpleName())); | |
| //We use Archaius to set the circuit as closed. | |
| ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.circuitBreaker.forceOpen", false); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Instead of | |
| archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class) | |
| .importDirectory(WEBAPP_SRC).as(GenericArchive.class), | |
| "/", Filters.include(".*\\.js$")) | |
| archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class) | |
| .importDirectory(WEBAPP_SRC).as(GenericArchive.class), | |
| "/", Filters.include(".*\\.css$")) | |
| archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class) | |
| .importDirectory(WEBAPP_SRC).as(GenericArchive.class), | |
| "/", Filters.include(".*\\.xhtml")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<WebElement> elements = session.findElements(xpath("//table/tbody/tr/td/span[@class='title']")); | |
| return elements.stream().map(WebElement::getText).collect(Collectors.toList()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Controller | |
| @EnableAutoConfiguration | |
| public class SampleController { | |
| @RequestMapping("/") | |
| @ResponseBody | |
| String home() { | |
| return "Hello World!"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <dependencies> | |
| <dependency> | |
| <groupId>org.apache.openejb</groupId> | |
| <artifactId>tomee-embedded</artifactId> | |
| <version>1.7.1</version> | |
| </dependency> | |
| <dependency> | |
| <groupId>org.apache.openejb</groupId> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.ejb.Stateless; | |
| import javax.ws.rs.GET; | |
| import javax.ws.rs.Path; | |
| import javax.ws.rs.Produces; | |
| @Stateless | |
| @Path("/sample") | |
| public class SampleController { | |
| @GET |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TomEEApplication { | |
| private static void startAndDeploy(Archive<?> archive) { | |
| Container container; | |
| try { | |
| Configuration configuration = new Configuration(); | |
| String tomeeDir = Files.createTempDirectory("apache-tomee").toFile().getAbsolutePath(); | |
| configuration.setDir(tomeeDir); |