This file contains 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 AsyncTest extends Controller | |
{ | |
public static void callback() | |
{ | |
F.Promise<WS.HttpResponse> remoteCall1 = WS.url("http://www.remote-service.com/data/1").getAsync(); | |
F.Promise<WS.HttpResponse> remoteCall2 = WS.url("http://www.remote-service.com/data/2").getAsync(); | |
F.Promise<WS.HttpResponse> remoteCall3 = WS.url("http://www.remote-service.com/data/3").getAsync(); | |
F.Promise<List<WS.HttpResponse>> promises = F.Promise.waitAll(remoteCall1, remoteCall2, remoteCall3); |
This file contains 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 AsyncTest extends Controller | |
{ | |
public static void gotchas() | |
{ | |
params.put("foo", "bar"); // Check if changes to params survive the request being suspended | |
renderArgs.put("foo", "bar"); // Check if changes to renderArgs survive the request being suspended | |
final String foo = "bar"; // Must be declared final to use in the callback | |
F.Promise<WS.HttpResponse> remoteCall1 = WS.url("http://www.remote-service.com/data/1").getAsync(); | |
F.Promise<WS.HttpResponse> remoteCall2 = WS.url("http://www.remote-service.com/data/2").getAsync(); |
This file contains 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
/** | |
* | |
* Sample Frontier Component. These are reusable blocks of functionality that can be used to fetch data from databases, | |
* external services, etc in parallel. This example just sets the lastModified date in the header and adds it to the | |
* derived data for the JSP. | |
* | |
*/ | |
@MinimumAuthenticationLevel(AuthenticationLevel.identified) | |
public class LastModifiedComponent extends FrontierComponent implements FrontierLifecycleAware |
This file contains 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
<!-- Add the following to the head of your webpage: --> | |
<script type="text/javascript" src="http://platform.linkedin.com/in.js"> | |
api_key: your_api_key_goes_here | |
</script> |
This file contains 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
<label>Phones:</label> | |
<input type="checkbox" name="phones" id="Android" value="Android"/><label for="Android">Android</label> | |
<input type="checkbox" name="phones" id="iPhone" value="iPhone" checked="checked"/><label for="iPhone">iPhone</label> | |
<input type="checkbox" name="phones" id="Blackberry" value="Blackberry" checked="checked"/><label for="Blackberry">Blackberry</label> |
This file contains 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
# For a given company id, update the company's location and website | |
post '/company' do | |
# ... process the request ... | |
"id = #{params[:companyId]}, location = #{params[:location]}, website = #{params[:website]}" # echo back the params | |
end |
This file contains 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
/** | |
* | |
* A simplified example of a Frontier Content Model that defines some basic data for a company | |
* | |
*/ | |
public interface CompanyContentModel extends ContentModelPrototype | |
{ | |
Integer getCompanyId(); | |
void setCompanyId(Integer companyId); |
This file contains 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
<!-- Sample Voldemort store for "share" data --> | |
<store> | |
<name>CompanyStore</name> | |
<persistence>bdb</persistence> | |
<routing>client</routing> | |
<replication-factor>3</replication-factor> | |
<required-reads>2</required-reads> | |
<required-writes>2</required-writes> | |
<key-serializer> | |
<type>json</type> |
This file contains 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
# ASAP example 1: fetch a list of users and then for each user, fetch their data in parallel | |
# For simplicity, the format of data returned by our "services" are just CSV strings | |
data = Asap do | |
get "http://url/to/user/list" do |users| | |
# this block of code does not execute until the above request is completed | |
list = users.split(", ") | |
list.each do |user| | |
# all of these will execute in parallel | |
get "http://url/to/#{user}/data" |
This file contains 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
// Jasmine example | |
it("expects value to be hello", function () { | |
var value = "hello"; | |
expect(value).toEqual("hello"); | |
expect(value).not.toEqual("good bye"); | |
}); |