Skip to content

Instantly share code, notes, and snippets.

View vastdevblog's full-sized avatar

Vast Development Blog vastdevblog

  • Vast
View GitHub Profile
@vastdevblog
vastdevblog / ConfigBinder.scala
Created June 18, 2012 00:57
Create @nAmed bindings for properties in a typesafe Config.
/**
* Copyright (c) 2012, Vast
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
@vastdevblog
vastdevblog / TransactionSupport.scala
Created March 16, 2012 22:05
Scala trait to add transactional support to a class.
package com.vast.example
import org.springframework.transaction.{TransactionStatus, PlatformTransactionManager}
import org.springframework.transaction.annotation.{Isolation, Propagation}
import org.springframework.transaction.support.{TransactionTemplate, DefaultTransactionDefinition, TransactionCallback}
/**
* Add a method to execute a block of code in a transaction. Typical use
*
* {{{
@vastdevblog
vastdevblog / SimpleModel.java
Created March 12, 2012 14:36
A very simple model for use by the ExampleServer
package com.vast.exmaple;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
// Fix the order that properties are emitted when using
// jackson to serialize this to json.
@JsonPropertyOrder(alphabetic = true)
public class SimpleModel {
private String id;
@vastdevblog
vastdevblog / ExampleServer.scala
Created March 12, 2012 14:30
Example of a Finagle server
package com.vast.example
import java.net.InetSocketAddress
import java.util.UUID
import java.util.concurrent.{Executors, TimeUnit}
import com.google.common.base.Splitter
import com.twitter.finagle.http.Http
import com.twitter.finagle.builder.{Server, ServerBuilder}
import com.twitter.finagle.service.TimeoutFilter
import com.twitter.finagle.{Service, SimpleFilter, GlobalRequestTimeoutException}