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
object AuthznIntent { | |
// AuthorizationRequest is a template for a Rule in the system (basically, a rule with no actions on the Rule result) | |
// By default the example is referencing variables as per entities that exist in the JAAS model, namely having the 'Principal' variable act as the identity of the caller and a number of subjects, aka user credentials, which would be associated with the Princicpal. | |
// The requestor id is also acting as the users token for service innvocation (aka a session scoped token), and the account Id represents the entity on which we | |
// are perfroming the action | |
case class AuthorizationRequest(requestorId: String, operationName: String, principal: String, subjects: Set[String], accountId: String) | |
// The expected response from the operation. Rules could be enacted before calling the action (preventative rules) or after (filtering rules) | |
case class PayloadResponse(var attribA : String = "a", var attribB : String = "b", var attribC : String = "c") |
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
import javax.jws.WebService | |
import javax.jws.soap.SOAPBinding | |
import javax.jws.soap.SOAPBinding.Style | |
import javax.xml.ws.Endpoint | |
@WebService(targetNamespace="org.scalabound.test", name="org.scalabound.test", portName="test", serviceName="WSTest") | |
private class MinimalSoapServer { | |
@SOAPBinding(style = Style.RPC) | |
def test(value : String) = "Hi " + value |
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
val FOO = 1 | |
val BAR = 2 | |
val x = 2 | |
x match { | |
case FOO => "matched a FOO !" | |
case BAR => "matched a BAR !" | |
case _ => "matched NOTHING !" | |
} |
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
val x = "someVariable" | |
x match { | |
case xVarBound => "matched your variable.. it's value is: " + xVarBound | |
} |
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
case class Person(firstname: String, surname: String) | |
val p = Person("K", "D"); | |
p match { | |
case Person("A", _) => "Person A" | |
case Person("K", _) => "Person K" | |
case _ => "missing person" | |
} |
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
val oneToFour = List(1, 2, 3, 4) | |
def sumElements(listOfInts: List[Int]) : Int = listOfInts match { | |
case List() => 0 // If it is an empty list, just return zero | |
case head :: rest => head + sumElements(rest) // Otherwise, recurse and sum elements | |
} | |
sumElements(oneToFour) |
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
val doubleA1 = ("A", 1) | |
val doubleA2 = ("A", 2) | |
val doubleB1 = ("B", 3) | |
def tupleMatcher(tuple: Tuple2[String, Int]) = tuple match { | |
case (_,1) => "matched A1 !" | |
case (_,2) => "matched A2 !" | |
case (a,b) if(a == "B") => "matched and using a guard for B !" | |
} |
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
val oneToFour = List(1, 2, 3, 4) | |
val odds = List(1, 3, 5, 7) | |
def findWhereSecondElemIsAThree(listOfInts: List[Int]) = listOfInts match { | |
case List(_, 3, _*) => "Found a list where second element == 3" | |
case List(_*) => "List with 0 or more elements" | |
} | |
findWhereSecondElemIsAThree(oneToFour) | |
findWhereSecondElemIsAThree(odds) |
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
import java.io.{FileReader,FileNotFoundException,IOException} | |
try { | |
val file = new FileReader("noSuchFile") | |
} catch { | |
case e: FileNotFoundException => println("File not found !") | |
// Handle missing file | |
case e: IOException => println("IO Exception !") | |
// Handle other I/O error | |
case e => e.printStackTrace() |
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
val doubleA1 = ("A", 1) | |
val doubleA2 = ("A", 2) | |
for((a,b) <- List(doubleA1, doubleA2)) { | |
println(a + " : " + b) | |
} |
OlderNewer