Skip to content

Instantly share code, notes, and snippets.

View lordofthejars's full-sized avatar
🏠
Working from home

Alex Soto lordofthejars

🏠
Working from home
View GitHub Profile
public class Color {
@ObjectId
private String _id;
private String name;
private int r;
private int g;
private int b;
@Singleton
@Lock(LockType.READ)
public abstract class ColorService implements InvocationHandler {
@JongoCollection("color")
@Inject
MongoCollection colorMongoCollection;
@Insert
public abstract Color createColor(Color c);
@ApplicationScoped
public class MongoCollectionProducer {
@Inject
DB mongoDb;
Jongo jongo;
@PostConstruct
public void initialize() throws UnknownHostException {
@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
<resources>
<Resource id="mongoUri" class-name="com.mongodb.MongoClientURI" constructor="uri">
uri mongodb://localhost/test
</Resource>
</resources>
@ApplicationScoped
public class MongoDBProducer {
@Resource(name = "mongoUri")
private MongoClientURI mongoClientURI;
private DB db;
@PostConstruct
public void init() throws UnknownHostException {
############### Block Processor
line1 = "( X) Answer";
line11 = "( ) Answer2";
line2 = "[ ] Answer";
line3 = "Question";
line4 = "";
input = [line3, line4, line1, line11, line3, line1]
//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()
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;
}
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;
}