Skip to content

Instantly share code, notes, and snippets.

View danielpassos's full-sized avatar

Daniel Passos danielpassos

View GitHub Profile
@danbev
danbev / gist:4066691
Created November 13, 2012 16:14
CDI vs web.xml configuration

CDI vs web.xml configuration

To help decide which approach is best for our users this gist will show how configuring CORS in AeroGear Controller would be like using CDI and via web.xml

CDI

For a CDI version and the specific case of CORS users will probably need to provide their own configuration settings. The proposed solution for this is for a user to provide a CDI Producer, for example:

public class CorsConfigProducer {
    public @Produces CorsConfiguration getConfiguration() {
        return CorsConfig.create()
 .enableCorsSupport(true)
@mstruk
mstruk / gist:4074544
Created November 14, 2012 20:24
PipeConfig Ergonomics

Currently, when creating a new PipeConfig we use a constructor and specify a rootUrl:

    URL rootUrl = new URL("http://todo-aerogear.rhcloud.com/todo-server");

    Pipeline pipeline = new Pipeline(rootUrl);
    PipeConfig config = new PipeConfig(rootUrl, Project.class);

    Pipe<Project> projects = pipeline.pipe(Project.class, config);
@secondsun
secondsun / gist:4078711
Created November 15, 2012 13:40 — forked from mstruk/gist:4074544
PipeConfig Ergonomics

Currently, when creating a new PipeConfig we use a constructor and specify a rootUrl:

    URL rootUrl = new URL("http://todo-aerogear.rhcloud.com/todo-server");

    Pipeline pipeline = new Pipeline(rootUrl);
    PipeConfig config = new PipeConfig(rootUrl, Project.class);

    Pipe<Project> projects = pipeline.pipe(Project.class, config);
@danbev
danbev / gist:4147473
Created November 26, 2012 10:02
Paging/Querying in AeroGear Controller

Paging/Querying in AeroGear Controller

This document is intended to discuss a solution for AEROGEAR-645 "Add Query/Paging support on RESTful endpoints".
This dev-aerogear mail list thread was used as a starting point to gather requirements and ideas.

Background

Lets just clarify the two concepts that we are dealing with here, Paging and Query.

Paging

Paging deals with limiting the number of results returned from a single request. One "page" can contain a certain number of items as the result of invoking a request, sometimes referred to the size of a page. Let say you want to limit you the number of result returned to 10 items, this could look something like this:

@fnando
fnando / gist:4356057
Created December 21, 2012 21:49
Open screen session and connect to given ssh domain. Usage: $ ./prod example.org
#!/usr/bin/env bash
domain=$1
filename="/tmp/$(echo -n "$domain" | md5)"
read -r -d '' screenrc <<SCREENRC
startup_message off
shell /usr/local/bin/bash
autodetach on
defscrollback 10000
class apt-get::update {
exec { "apt-get update":
command => "apt-get update"
}
}
@matzew
matzew / gist:4451467
Created January 4, 2013 10:11
Nice key/value init for the NSDictionary class...
NSDictionary *map = @{ @"key1": @"blah", @"key2": @"foo"};
@alexrios
alexrios / EasyOrderBy.md
Last active December 11, 2015 02:18
Java "order by" made easy
//Smart use of enums
public enum DeviceComparator implements Comparator<Device> {
 
    ID {
        public int compare(Device o1, Device o2) {
            return Integer.valueOf(o1.getId()).compareTo(o2.getId());
        }},
    NAME {
        public int compare(Device o1, Device o2) {

Client Paging

This document describes the client side interfaces which a developer can use to Query and Page through data obtained from remote rest services. This document describes both how to interact with the Aerogear-Controller based paging as well how to extend the libraries and APIs to support most other restful services. It is currently Java centric, but this should be fixed up in the future.

At a high level, Paging and Querying is supported though the Pipe.readWithFilter(ReadFilter, Callback) method. A ReadFilter object will set the current page, number of results perPage, and a where property. The Pipe implementation will be responsible for processing a request along with any paging data and sending the appropriate headers, data, and query parameters to the server. Once the response has been received, the Pipe implementation will provide a List of objects to the supplied callback. If this call used paging, the List will be an instance of PagedList.

PagedList will be a List of results f

public interface PagedResult<T> {
PagedResult<T> next();
PagedResult<T> prev();
PagedResult<T> withOffset(int offset);
PagedResult<T> withLimit(int limit);