Skip to content

Instantly share code, notes, and snippets.

View whaley's full-sized avatar

Jason Whaley whaley

  • Asheville, NC
View GitHub Profile
@whaley
whaley / Player.java
Created September 25, 2011 14:37
JAXB annotated Player class for JAXRS Example
package com.jasonwhaley.rest;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
@XmlRootElement(name = "player")
public class Player {
@XmlElement(name = "nickname")
@whaley
whaley / PlayerService.java
Created September 25, 2011 14:38
PlayerService class for JAXRS example
package com.jasonwhaley.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
public class PlayerService {
@whaley
whaley / gist:1240658
Created September 25, 2011 14:39
JAXRS Multiple Content Types Output
[whaley@sunspot ~]
> curl -H"Accept:application/json" 'http://localhost:8080/rest-sample/service/player/whaley?playerClass=Soldier'
{"player":{"nickname":"whaley","playerClass":"Soldier"}}
[whaley@sunspot ~]
> curl -H"Accept:application/xml" 'http://localhost:8080/rest-sample/service/player/whaley?playerClass=Soldier'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><player><nickname>whaley</nickname><playerClass>Soldier</playerClass></player>
@whaley
whaley / pom.xml
Created September 25, 2011 14:40
CXF JAXRS Bundle Maven Dependency
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<version>2.3.1</version>
</dependency>
@whaley
whaley / template.wsdl
Created September 25, 2011 14:43
WSDL Template
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.example.com/webservice"
xmlns:tns="http://www.example.com/webservice"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
[whaley@sunspot ~/opt/ec2/credentials]
> ls -lh
total 16
lrwxr-xr-x 1 whaley staff 46B Oct 22 06:44 current -> /Users/whaley/opt/ec2/credentials//jasonwhaley
drwxr-xr-x 2 whaley staff 374B Apr 29 2010 client1
drwxr-xr-x 2 whaley staff 374B Jan 18 2010 client2
drwxr-xr-x 2 whaley staff 374B Jan 18 2010 jasonwhaley
-rwxr--r-- 1 whaley staff 978B Jul 20 07:24 switch_ec2_creds.sh
[whaley@sunspot ~/opt/ec2/credentials]
@whaley
whaley / gist:1240665
Created September 25, 2011 14:46
exports
export EC2_CREDENTIAL_LOCATION=$HOME/opt/ec2/credentials/current/
export EC2_PRIVATE_KEY=$EC2_CREDENTIAL_LOCATION/pk
export EC2_CERT=$EC2_CREDENTIAL_LOCATION/cert
export EC2_KEYPAIR_KEY=$EC2_CREDENTIAL_LOCATION/keypair_pk
#!/bin/bash
BASE_DIRECTORY=$HOME/opt/ec2/credentials/
function outputChoices {
local count=0
for directory in ${directories[@]}
do
echo -e "$count:\t$(basename $directory)"
((count++))
@whaley
whaley / gist:1240670
Created September 25, 2011 14:47
output
[whaley@sunspot ~/opt/ec2/credentials]
> switch_ec2_creds
0: jasonwhaley
1: client1
2: client2
Select one of [0-2] - any other input leaves creds unchanged: 2
Credentials set to /Users/whaley/opt/ec2/credentials//client2
[whaley@sunspot ~/opt/ec2/credentials]
@whaley
whaley / gist:1240816
Created September 25, 2011 16:44
TicTacToe Sealed Classes
package com.jasonwhaley.tictactoe
sealed abstract class TicTacToeSpace {
val representation : String
override def toString() : String = {
return representation
}
}
case class X extends TicTacToeSpace {