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 Color { | |
| @ObjectId | |
| private String _id; | |
| private String name; | |
| private int r; | |
| private int g; | |
| private int b; | |
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
| @Singleton | |
| @Lock(LockType.READ) | |
| public abstract class ColorService implements InvocationHandler { | |
| @JongoCollection("color") | |
| @Inject | |
| MongoCollection colorMongoCollection; | |
| @Insert | |
| public abstract Color createColor(Color c); |
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
| @ApplicationScoped | |
| public class MongoCollectionProducer { | |
| @Inject | |
| DB mongoDb; | |
| Jongo jongo; | |
| @PostConstruct | |
| public void initialize() throws UnknownHostException { |
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
| @RunWith(Arquillian.class) | |
| public class ColorTest { | |
| private static final String MONGODB_RESOURCE = "<resources>\n" + | |
| " <Resource id=\"mongoUri\" class-name=\"com.mongodb.MongoClientURI\" constructor=\"uri\">\n" + | |
| " uri mongodb://localhost/test\n" + | |
| " </Resource>\n" + | |
| "</resources>"; | |
| @Deployment |
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
| <resources> | |
| <Resource id="mongoUri" class-name="com.mongodb.MongoClientURI" constructor="uri"> | |
| uri mongodb://localhost/test | |
| </Resource> | |
| </resources> |
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
| @ApplicationScoped | |
| public class MongoDBProducer { | |
| @Resource(name = "mongoUri") | |
| private MongoClientURI mongoClientURI; | |
| private DB db; | |
| @PostConstruct | |
| public void init() throws UnknownHostException { |
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
| ############### Block Processor | |
| line1 = "( X) Answer"; | |
| line11 = "( ) Answer2"; | |
| line2 = "[ ] Answer"; | |
| line3 = "Question"; | |
| line4 = ""; | |
| input = [line3, line4, line1, line11, line3, line1] |
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
| //I am running this example (which is the one provided in website), but I have modified the sample-client.properties so one of the server | |
| //is invalid (unknown host). Then I run the code, but circuit to that server is never tripped (printing stats shows that no tripped //happened ever) and also debugging the code I can see that the server host is eligible. I would like to know if it is the expected behavior. | |
| ConfigurationManager.loadPropertiesFromResources("sample-client.properties"); System.out.println(ConfigurationManager.getConfigInstance().getProperty("sample-client.ribbon.listOfServers")); | |
| RestClient client = (RestClient) ClientFactory.getNamedClient("sample-client"); | |
| HttpRequest request = HttpRequest.newBuilder().uri(new URI("/")).build(); | |
| for (int i = 0; i < 20; i++) { | |
| HttpResponse response = client.executeWithLoadBalancer(request); | |
| System.out.println("Status code for " + response.getRequestedURI() |
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
| private static JavaArchive mergeHibernate(JavaArchive javaArchive) { | |
| JavaArchive[] javaArchives = Maven.resolver().resolve("org.hibernate:hibernate-entitymanager:4.2.15.Final").withTransitivity().as(JavaArchive.class); | |
| for(JavaArchive hibernateDep: javaArchives) { | |
| javaArchive.merge(hibernateDep); | |
| } | |
| return javaArchive; | |
| } |
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
| private static JavaArchive mergeHibernate(JavaArchive javaArchive) { | |
| JavaArchive[] javaArchives = Maven.resolver().resolve("org.hibernate:hibernate-entitymanager:4.2.15.Final").withTransitivity().as(JavaArchive.class); | |
| Arrays.stream(javaArchives).forEach(javaArchive::merge); | |
| return javaArchive; | |
| } |