Hash :
dfc19413
Author :
Date :
2016-11-09T01:57:46
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
<h1>Jolie</h1>
<p>To use this language, use the class "language-jolie".</p>
<h2>Comments</h2>
<pre><code>// Single line comment
/* Multi-line
comment */</code></pre>
<h2>Strings</h2>
<pre><code>"foo \"bar\" baz";
'foo \'bar\' baz'</code></pre>
<h2>Numbers</h2>
<pre><code>42
42L
1.2e3
0.1E-4
0.2e+1
</code></pre>
<h2>Full example</h2>
<pre><code>include "console.iol"
type HubType: void {
.sid: undefined
.nodes[1,*] : NodeType
}
type NodeType: void {
.sid: string
.node: string
.load?: int
}
type NetType: HubType | NodeType
interface NetInterface {
OneWay: start( string ), addElement( NetType ), removeElement( NetType ), quit( void )
RequestResponse: showElements( void )( NetType ) throws SomeFault
}
type LogType: void {
.message: string
}
interface LoggerInterface {
RequestResponse: log( LogType )( void )
}
outputPort LoggerService {
Interfaces: LoggerInterface
}
embedded {
Jolie: "logger.ol" in LoggerService
}
type AuthenticationData: void {
.key:string
}
interface extender AuthInterfaceExtender {
OneWay: *(AuthenticationData)
}
service SubService
{
Interfaces: NetInterface
main
{
println@Console( "I do nothing" )()
}
}
inputPort ExtLogger {
Location: "socket://localhost:9000"
Protocol: sodep
Interfaces: LoggerInterface
Aggregates: LoggerService with AuthInterfaceExtender
}
courier ExtLogger {
[interface LoggerInterface( request )] {
if ( key == "secret" ){
forward ( request )
}
}
}
inputPort In {
Location: "socket://localhost:8000"
Protocol: http {
.debug = true;
.debug.showContent = true
}
Interfaces: NetInterface
Aggregates: SubService,
LoggerService
Redirects: A => SubService,
B => SubService
}
cset {
sid: HubType.sid NodeType.sid
}
execution{ concurrent }
define netmodule {
if( request.load == 0 || request.load < 1 &&
request.load <= 2 || request.load >= 3 &&
request.load > 4 || request.load%4 == 2
) {
scope( scopeName ) {
// inline comment
install( MyFault => println@Console( "Something \"Went\" Wrong" + ' but it\'s ok' )() );
/*
* Multi-line
* Comment
*/
install( this => cH; println@Console( "Something went wrong: " + ^load )() );
install( default => comp( scopeName ); println@Console( "Something went wrong" )() );
load -> request.( "load" );
{ ++load | load++ | --load | load-- };
throw( MyFault )
}
} else {
foreach ( node -> request.nodes ) {
with( node ){
while( .load != 100 ) {
.load++
}
}
}
}
}
main
{
start( sid );
synchronized( unneededSync ){
csets.sid = sid;
undef( sid )
};
provide
[ addElement( request ) ]{
if( request instanceof NodeType ) {
netmodule
}
}
[ removeElement() ]
[ showElements()( response ){
/*
* assemble response
*/
nullProcess
}]{
// log the request
log@LoggerService( new )();
log @ LoggerService( new )()
}
until
[ quit() ]{ exit }
}</code></pre>