forked from ballerina-attic/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1072 lines (974 loc) · 46.8 KB
/
index.html
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Ballerina - A flexible, powerful, beautiful programming language.</title>
<meta charset="UTF-8">
<meta property="og:url" content="https://ballerinalang.org" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Flexible. Powerful. Beautiful." />
<meta property="og:description" content="Ballerina is a general purpose, concurrent and strongly typed programming language with both textual and graphical syntaxes, optimized for integration." />
<meta property="og:image" content="http://ballerinalang.org/img/ballerina-fb.jpg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index"/>
<meta name="title" content="Ballerina - A flexible, powerful, beautiful programming language">
<meta name="description" content="Ballerina is a general purpose, concurrent and strongly typed programming language with both textual and graphical syntaxes, optimized for integration.">
<meta name="keywords" content="Programing language, Integration language, Sequence diagrams, Ballerinalang, WSO2 Ballerina, ballerina, language, Microservices Enterprise, Integration,">
<meta name="author" content="ballerinalang"/>
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
<link rel="icon" href="img/favicon.ico" type="image/x-icon">
<!--GA-->
<script async>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-92163714-1', 'auto');
ga('send', 'pageview');
</script>
<!-- Google Tag Manager -->
<script>(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({'gtm.start':
new Date().getTime(), event: 'gtm.js'});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-KW2LLTW');
</script>
<!-- End Google Tag Manager -->
<!-- Hotjar Tracking Code for http://ballerinalang.org/ -->
<script>
(function(h, o, t, j, a, r) {
h.hj = h.hj || function() {
(h.hj.q = h.hj.q || []).push(arguments)
};
h._hjSettings = {hjid: 442732, hjsv: 5};
a = o.getElementsByTagName('head')[0];
r = o.createElement('script');
r.async = 1;
r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
a.appendChild(r);
})(window, document, '//static.hotjar.com/c/hotjar-', '.js?sv=');
</script>
<!-- Hotjar Tracking Code for http://ballerinalang.org/ END -->
<style>
.hideSlide {
display: none;
}
.cBallerinaTweets {
background-color: rgba(255,255,255,0.8);
display: inline-block;
/* height: 200px;*/
padding: 10px;
position: fixed;
right: 0;
bottom: -50px;
border: 1px solid #c5c5c5;
border-radius: 10px 0 0 0;
width: 220px;
/* border-top: none;*/
}
.cTweetContainerButton {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #ffffff;
background-image: url("http://ballerinalang.org/img/down-arrow.svg");
background-position: center center;
background-repeat: no-repeat;
border:1px solid #c5c5c5;
border-image: none;
border-radius: 5px 5px 0 0;
display: inline-block;
float: right;
height: 40px;
margin-right: -11px;
margin-top: -49px;
padding: 0;
width: 40px;
border-bottom: none;
transition: all 0.2s ease-in-out 0s;
cursor: pointer;
}
.cTweetContainerButton:hover {
border-bottom: none;
}
.cBallerinaTweets.cHideTwitter {
bottom: -530px;
transition: all 0.2s ease-in-out 0s;
}
.cBallerinaTweets.cHideTwitter .cTweetContainerButton {
background-image: url("https://ballerinalang.org/img/up-arrow.svg") !important;
}
.row.cBallerna-banner {
background-color: #000000;
background-image: url("hackathon/hackathon-images/intro-bg-orange.jpg");
background-attachment: fixed;
background-size: 100%;
transition: all 0.5s ease-in-out 0s;
padding: 7em 0;
box-shadow: 0 0 44px rgba(0, 0, 0, 0.5) inset;
filter: grayscale(100%);
margin: 0;
position: absolute;
width: 100%;
top: 0;
}
.row.cBallerna-banner:hover {
filter: grayscale(0%);
transition: all 0.5s ease-in-out 0s;
}
.row.cBallerna-banner.cOpenBanner {
margin-bottom: 0;
margin-top: 0;
opacity: 0.9;
padding: 0.5em 0;
bottom: 0;
top: auto;
transition: all 0.5s ease-in-out 0s;
width: 100%;
z-index: 999999;
filter: grayscale(100%);
text-align: center;
position: fixed;
}
.row.cBallerna-banner.cOpenBanner:hover {
opacity: 1;
filter: grayscale(0%);
}
.row.cBallerna-banner img {
width:100%;
transition: all 0.5s ease-in-out 0s;
}
body.cBallerina {
margin-top: 420px;
margin-bottom: 78px;
}
body.cBallerina.cFixdspacer {
margin-top: 0x;
}
.row.cBallerna-banner.cOpenBanner img {
width: 350px;
transition: all 0.5s ease-in-out 0s;
}
.row.cBallerna-banner.cOpenBanner .cBallerna-banner-Container {
height: auto;
}
@media screen and (max-width:991px) {
.cTweetContainerButton , .cBallerinaTweets {
display: none;
}
.row.cBallerna-banner.cOpenBanner {
padding: 2em;
background-size:300%;
}
body.cBallerina {
margin-top: 10em;
}
.row.cBallerna-banner {
padding: 1em;
}
}
@media screen and (max-width:500px) {
body.cBallerina {
margin-top: 5em;
}
.row.cBallerna-banner.cOpenBanner img {
height: 77px;
}
.row.cBallerna-banner.cOpenBanner {
padding: 1.2em;
}
background-size: 600%;
}
</style>
</head>
<body class="cBallerina">
<a href="https://ballerinalang.org/hackathon/?utm_source=bnrhmpg&utm_medium=ballerina&utm_campaign=hpban_ballerinahack_jun17" target="_blank" id="cHomePageHackathonBanner"><div class="row cBallerna-banner">
<div class="container">
<div class="col-xs-12 col-sm-12 col-md-12">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/home-banner-hackathon.svg"/>
</div>
</div>
</div>
</a>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KW2LLTW"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div class="row cBallerinaNav" id="iBallerinaNavigation">
</div>
<div class="row cBallerinaIntro">
<div class="container">
<div class="col-sm-12 col-md-12">
<h1>Flexible. Powerful. Beautiful.</h1>
</div>
<div class="col-sm-12 col-md-8">
<h2><span>Ballerina</span> is a general purpose, concurrent and strongly typed programming language with both textual and graphical syntaxes, optimized for integration.</h2>
</div>
<div class="col-sm-12 col-md-4 cBallerinaDownload" style="text-align: center;">
<a class="cBallerinaButtons cBallerinaDownloadButtons fancybox" id="cBallerinaDownlaodHome" href="downloads">Download</a>
<a href="#subscribeUser" class="fancybox cGet-updates">Subscribe for updates</a>
</div>
</div>
</div>
<div class="row cBallerinaTry">
<div class="container">
<div class="col-sm-12 col-md-12 cFullscreenContainer">
<div class="cBallerinaTryNowContainer">
<a class="cFullscreen" id="Fullscreenview"></a>
<div class="sample_1 cSampleBox ">
<div class="">
<h3>helloWorld.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode1">
<textarea id="txtSample1">
import ballerina.lang.system;
function main(string[] args) {
system:println("Hello, World!" );
}
</textarea>
<input type="text" id="arguments1" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram1">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sample-screen/hello-world.png"/>
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow1 cResults">
</div>
<a class="cTryitButton cTrySample1" id="helloWorldTry"></a>
</div>
<div class="sample_2 cSampleBox ">
<div class="">
<h3>echoService.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode2">
<textarea id="txtSample2" >
//This sample will echo the request message
import ballerina.net.http;
@http:BasePath {value:"/echo"}
service echo {
@http:POST{}
resource echo (message m) {
http:convertToResponse(m);
reply m;
}
}
</textarea>
<input type="text" id="arguments2" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram2">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sample-screen/echo-service.png"/>
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow2 cResults">
</div>
<a class="cTryitButton cTrySample2" id="echoServiceTry"></a>
</div>
<div class="sample_3 cSampleBox ">
<div class="">
<h3>passthroughService.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode3">
<textarea id="txtSample3" >
//This sample will passthrough the message to the backend and response to the client
//This publish the 'passthroughService' and 'nyseStockQuoteService' services
//Here the 'nyseStockQuoteService' will act as a backend.
import ballerina.net.http;
@http:BasePath {value:"/passthrough"}
service passthrough {
@http:GET{}
resource passthrough (message m) {
http:ClientConnector nyseEP = create http:ClientConnector("http://localhost:9090");
message response = http:ClientConnector.get(nyseEP, "/nyseStock", m);
reply response;
}
}
import ballerina.lang.messages;
import ballerina.net.http;
@http:BasePath {value:"/nyseStock"}
service nyseStockQuote {
@http:GET{}
resource stocks (message m) {
json payload = {"exchange":"nyse", "name":"IBM", "value":"127.50"};
message response = {};
messages:setJsonPayload(response, payload);
reply response;
}
} </textarea>
<input type="text" id="arguments3" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram3">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sample-screen/passthrough.png"/>
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow3 cResults">
</div>
<a class="cTryitButton cTrySample3" id="passthroughServiceTry"></a>
</div>
<div class="sample_4 cSampleBox ">
<div class="">
<h3>routingServices.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode4">
<textarea id="txtSample4" >
//This sample has two services which will route the message to two different backend. The first service will route based on the message content and the second one will route based on the header value.
import ballerina.net.http;
import ballerina.lang.jsons;
import ballerina.lang.messages;
@http:BasePath {value:"/cbr"}
service contentBasedRouting {
@http:POST{}
resource cbrResource (message m) {
http:ClientConnector nasdaqEP = create http:ClientConnector("http://localhost:9090/nasdaqStocks");
http:ClientConnector nyseEP = create http:ClientConnector("http://localhost:9090/nyseStocks");
string nyseString = "nyse";
json jsonMsg = messages:getJsonPayload(m);
string nameString = jsons:getString(jsonMsg, "$.name");
message response = {};
if (nameString == nyseString) {
response = http:ClientConnector.post(nyseEP, "/", m);
}
else {
response = http:ClientConnector.post(nasdaqEP, "/", m);
}
reply response;
}
}
import ballerina.net.http;
import ballerina.lang.messages;
@http:BasePath {value:"/hbr"}
service headerBasedRouting {
@http:GET{}
resource cbrResource (message m) {
http:ClientConnector nasdaqEP = create http:ClientConnector("http://localhost:9090/nasdaqStocks");
http:ClientConnector nyseEP = create http:ClientConnector("http://localhost:9090/nyseStocks");
string nyseString = "nyse";
string nameString = messages:getHeader(m, "name");
message response = {};
if (nameString == nyseString) {
response = http:ClientConnector.post(nyseEP, "/", m);
}
else {
response = http:ClientConnector.post(nasdaqEP, "/", m);
}
reply response;
}
}
import ballerina.lang.messages;
import ballerina.net.http;
@http:BasePath {value:"/nyseStocks"}
service nyseStockQuote {
@http:POST{}
resource stocks (message m) {
message response = {};
json payload = {"exchange":"nyse", "name":"IBM", "value":"127.50"};
messages:setJsonPayload(response, payload);
reply response;
}
}
import ballerina.lang.messages;
import ballerina.net.http;
@http:BasePath {value:"/nasdaqStocks"}
service nasdaqStocksQuote {
@http:POST{}
resource stocks (message m) {
message response = {};
json payload = {"exchange":"nasdaq", "name":"IBM", "value":"127.50"};
messages:setJsonPayload(response, payload);
reply response;
}
}
</textarea>
<input type="text" id="arguments4" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram4">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sample-screen/routing-services.png"/>
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow4 cResults">
</div>
<a class="cTryitButton cTrySample4" id="iroutingeServiceTry"></a>
</div>
<div class="sample_5 cSampleBox ">
<div class="">
<h3>ecommerceService.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode5">
<textarea id="txtSample5">
import ballerina.net.http;
@http:BasePath {value:"/ecommerceservice"}
service Ecommerce {
http:ClientConnector productsService = create http:ClientConnector("http://localhost:9090");
@http:GET{}
@http:Path {value:"/products/{productId}"}
resource productsInfo(message m,
@http:PathParam{value:"productId"} string prodId) {
string reqPath = "/productsservice/" + prodId;
message response = http:ClientConnector.get(productsService, reqPath, m);
reply response;
}
@http:POST{}
@http:Path {value:"/products"}
resource productMgt (message m) {
message response = http:ClientConnector.post(productsService, "/productsservice", m);
reply response;
}
@http:GET{}
@http:Path {value:"/orders"}
resource ordersInfo (message m) {
http:ClientConnector productsService = create http:ClientConnector("http://localhost:9090");
message response = http:ClientConnector.get(productsService, "/orderservice", m);
reply response;
}
@http:POST{}
@http:Path {value:"/orders"}
resource ordersMgt (message m) {
http:ClientConnector productsService = create http:ClientConnector("http://localhost:9090");
message response = http:ClientConnector.post(productsService, "/orderservice", m);
reply response;
}
@http:GET{}
@http:Path {value:"/customers"}
resource customersInfo (message m) {
http:ClientConnector productsService = create http:ClientConnector("http://localhost:9090");
message response = http:ClientConnector.get(productsService, "/customerservice", m);
reply response;
}
@http:POST{}
@http:Path {value:"/customers"}
resource customerMgt (message m) {
http:ClientConnector productsService = create http:ClientConnector("http://localhost:9090");
message response = http:ClientConnector.post(productsService, "/customerservice", m);
reply response;
}
}
import ballerina.lang.messages;
import ballerina.lang.system;
import ballerina.lang.jsons;
import ballerina.net.http;
@http:BasePath{value:"/productsservice"}
service productmgt {
map productsMap = populateSampleProducts();
@http:GET{}
@http:Path {value:"/{id}"}
resource product(message m,
@http:PathParam{value:"id"} string prodId) {
json payload = (json) productsMap[prodId];
message response = {};
messages:setJsonPayload(response, payload);
reply response;
}
@http:POST{}
@http:Path {value:"/"}
resource product (message m) {
json jsonReq = messages:getJsonPayload(m);
string productId = jsons:getString(jsonReq, "$.Product.ID");
productsMap[productId] = jsonReq;
json payload = {"Status":"Product is successfully added."};
message response = {};
messages:setJsonPayload(response, payload);
reply response;
}
}
function populateSampleProducts()(map productsMap) {
productsMap = {};
json prod_1 = {"Product": {"ID": "123000", "Name": "ABC_1","Description": "Sample product."}};
json prod_2 = {"Product": {"ID": "123001", "Name": "ABC_2","Description": "Sample product."}};
json prod_3 = {"Product": {"ID": "123002", "Name": "ABC_3","Description": "Sample product."}};
productsMap["123000"] = prod_1;
productsMap["123001"] = prod_2;
productsMap["123002"] = prod_3;
system:println("Sample products are added.");
return productsMap;
}
import ballerina.lang.messages;
import ballerina.lang.strings;
import ballerina.net.http;
@http:BasePath{value:"/orderservice"}
service OrderMgtService {
@http:GET{}
@http:POST{}
resource orders (message m) {
json payload = {};
string httpMethod = http:getMethod(m);
if (strings:equalsIgnoreCase(httpMethod, "GET")) {
payload = {"Order": {"ID": "111999", "Name": "ABC123","Description": "Sample order."}};
}
else {
payload = {"Status":"Order is successfully added."};
}
message response = {};
messages:setJsonPayload(response, payload);
reply response;
}
}
import ballerina.lang.messages;
import ballerina.lang.strings;
import ballerina.net.http;
@http:BasePath{value:"/customerservice"}
service CustomerMgtService {
@http:GET{}
@http:POST{}
resource customers (message m) {
json payload = {};
string httpMethod = http:getMethod(m);
if (strings:equalsIgnoreCase(httpMethod, "GET")) {
payload = {"Customer": {"ID": "987654", "Name": "ABC PQR","Description": "Sample Customer."}};
}
else {
payload = {"Status":"Customer is successfully added."};
}
message response = {};
messages:setJsonPayload(response, payload);
reply response;
}
}
</textarea>
<input type="text" id="arguments5" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram5">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sample-screen/ecommerce.png"/>
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow5 cResults">
</div>
<a class="cTryitButton cTrySample5" id="iRestfulServiceTry"></a>
</div>
<div class="sample_6 cSampleBox ">
<div class="">
<h3>ATMLocatorService.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode6">
<textarea id="txtSample6">
//This sample will illustrate a composite service : ATMLocatorService, which calls the following services to find the nearest ATM of ABC Bank using the zip code.
// - Zip-code based Branch locator service : http://localhost:9090/branchlocator
// - Bank information provider : http://localhost:9090/bankinfo
import ballerina.lang.messages;
import ballerina.net.http;
import ballerina.lang.system;
import ballerina.lang.jsons;
@http:BasePath {value:"/ABCBank"}
service ATMLocator {
@http:POST{}
@http:Path {value:"/locator"}
resource locator (message m) {
http:ClientConnector bankInfoService = create http:ClientConnector("http://localhost:9090/bankinfo");
http:ClientConnector branchLocatorService = create http:ClientConnector("http://localhost:9090/branchlocator");
message backendServiceReq = {};
json jsonLocatorReq = messages:getJsonPayload(m);
string zipCode = jsons:getString(jsonLocatorReq, "$.ATMLocator.ZipCode");
system:println("Zip Code " + zipCode);
json branchLocatorReq = {"BranchLocator": {"ZipCode":""}};
jsons:set(branchLocatorReq, "$.BranchLocator.ZipCode", zipCode);
messages:setJsonPayload(backendServiceReq, branchLocatorReq);
message response = http:ClientConnector.post(branchLocatorService, "", backendServiceReq);
json branchLocatorRes = messages:getJsonPayload(response);
string branchCode = jsons:getString(branchLocatorRes, "$.ABCBank.BranchCode");
system:println("Branch Code " + branchCode);
json bankInfoReq = {"BranchInfo": {"BranchCode":""}};
jsons:set(bankInfoReq, "$.BranchInfo.BranchCode", branchCode);
messages:setJsonPayload(backendServiceReq, bankInfoReq);
response = http:ClientConnector.post(bankInfoService, "", backendServiceReq);
reply response;
}
}
import ballerina.lang.messages;
import ballerina.lang.jsons;
import ballerina.net.http;
@http:BasePath {value:"/branchlocator"}
service Banklocator {
@http:POST{}
resource product (message m) {
message response = {};
json jsonRequest = messages:getJsonPayload(m);
string zipCode = jsons:getString(jsonRequest, "$.BranchLocator.ZipCode");
json payload = {};
if (zipCode == "95999") {
payload = {"ABCBank": {"BranchCode":"123"}};
}
else {
payload = {"ABCBank": {"BranchCode":"-1"}};
}
messages:setJsonPayload(response, payload);
reply response;
}
}
import ballerina.lang.messages;
import ballerina.lang.jsons;
import ballerina.net.http;
@http:BasePath {value:"/bankinfo"}
service Bankinfo {
@http:POST{}
resource product (message m) {
message response = {};
json jsonRequest = messages:getJsonPayload(m);
string branchCode = jsons:getString(jsonRequest, "$.BranchInfo.BranchCode");
json payload = {};
if (branchCode == "123") {
payload = {"ABC Bank": {"Address": "111 River Oaks Pkwy, San Jose, CA 95999"}};
}
else {
payload = {"ABC Bank": {"error": "No branches found."}};
}
messages:setJsonPayload(response, payload);
reply response;
}
}
</textarea>
<input type="text" id="arguments6" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram6">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sample-screen/atm-locator.png"/>
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow6 cResults">
</div>
<a class="cTryitButton cTrySample6" id="ServiceChainingTry"></a>
</div>
<div class="sample_7 cSampleBox ">
<div class="">
<h3>helloWorldService.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode7">
<textarea id="txtSample7">
//This sample runs a service that replies to a request with a greeting message.
import ballerina.lang.messages;
import ballerina.net.http;
@http:BasePath {value:"/hello"}
service helloWorld {
@http:GET{}
resource sayHello (message m) {
message response = {};
messages:setStringPayload(response, "Hello, World!");
reply response;
}
}
</textarea>
<input type="text" id="arguments7" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram7">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sample-screen/hello-world-service.png"/>
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow7 cResults">
</div>
<a class="cTryitButton cTrySample7" id="ihelloWorldService"></a>
</div>
<div class="sample_8 cSampleBox ">
<div class="">
<h3>twitterConnector.bal</h3>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol">
<div class="cBallerinaCode cBallerinaCode8">
<textarea id="txtSample8">
import ballerina.lang.jsons;
import ballerina.lang.messages;
import ballerina.lang.strings;
import ballerina.lang.system;
import ballerina.net.http;
import ballerina.net.uri;
import ballerina.utils;
connector Twitter(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret) {
http:ClientConnector tweeterEP = create http:ClientConnector("https://api.twitter.com");
action tweet(Twitter t, string msg)(message ) {
message request = {};
string oauthHeader = constructOAuthHeader(consumerKey, consumerSecret, accessToken, accessTokenSecret, msg);
string tweetPath = "/1.1/statuses/update.json?status=" + uri:encode(msg);
messages:setHeader(request, "Authorization", oauthHeader);
message response = http:ClientConnector.post(tweeterEP, tweetPath, request);
return response;
}
}
function constructOAuthHeader(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret, string tweetMessage)(string ) {
string timeStamp = strings:valueOf(system:epochTime());
string nonceString = utils:getRandomString();
string paramStr = "oauth_consumer_key=" + consumerKey + "&oauth_nonce=" + nonceString + "&oauth_signature_method=HMAC-SHA1&oauth_timestamp=" + timeStamp + "&oauth_token=" + accessToken + "&oauth_version=1.0&status=" + uri:encode(tweetMessage);
string baseString = "POST&" + uri:encode("https://api.twitter.com/1.1/statuses/update.json") + "&" + uri:encode(paramStr);
string keyStr = uri:encode(consumerSecret) + "&" + uri:encode(accessTokenSecret);
string signature = utils:getHmac(baseString, keyStr, "SHA1");
string oauthHeader = "OAuth oauth_consumer_key=\"" + consumerKey + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_timestamp=\"" + timeStamp + "\",oauth_nonce=\"" + nonceString + "\",oauth_version=\"1.0\",oauth_signature=\"" + uri:encode(signature) + "\",oauth_token=\"" + uri:encode(accessToken) + "\"";
return strings:unescape(oauthHeader);
}
function main(string[] args) {
Twitter twitterConnector = create Twitter(args[0], args[1], args[2], args[3]);
message tweetResponse = Twitter.tweet(twitterConnector, args[4]);
json tweetJSONResponse = messages:getJsonPayload(tweetResponse);
system:println(jsons:toString(tweetJSONResponse));
}
</textarea>
<input type="text" id="arguments8" placeholder="arguments. e.g. val1;val2" style="width: 100%;"/>
</div>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTryNowCol ">
<div class="cBallerinaDaiagram cBallerinaDaiagram8">
<!-- <img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/TwitterConnector.svg"/>-->
</div>
</div>
<div class="col-sm-12 col-md-12 cOutputWindow8 cResults">
</div>
<a class="cTryitButton cTrySample8" id="TwitterConnectorTry"></a>
</div>
<div class="col-sm-12 col-md-6 cBallerinaTools">
<h4>Samples</h4>
<select>
<!-- <option>Choose Color</option>-->
<option value="sample_1">HelloWorld</option>
<option value="sample_2">Echo Service</option>
<option value="sample_3">Passthrough Service</option>
<option value="sample_4">Routing Services</option>
<option value="sample_5">Ecommerce Service</option>
<option value="sample_6">Service Chaining</option>
<option value="sample_7">Hello Services</option>
<!-- <option value="sample_8">Twitter Connector</option>-->
</select>
</div>
</div>
</div>
</div>
</div>
<div class="row cBallerinaContentRow cGrayRow" id="Getting-Started">
<div class="container">
<div class="">
<div style="display: inline-block; margin-bottom: 4em;">
<div class="col-sm-12 col-md-6">
<p class="Intro">Ballerina was built from the ground up to make it easier to design, describe and develop programs. Here’s how and why. </p>
</div>
<div class="col-sm-12 col-md-6">
<div class="VideoR-one" id="videoClick_1" onclick="this.nextElementSibling.style.display = 'block';
this.style.display = 'none'">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/sanjiva-ballerina.jpg" alt="play button" style="cursor:pointer">
</div>
<div style="display:none">
<div class="embed-container" id="video_1"></div>
</div>
</div>
</div>
<div>
<div class="col-sm-12 col-md-6">
<div class="Slides-One" >
<img class="cSlideImage" src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/slideshare.jpg" alt="play button" style="cursor:pointer">
<div id="slideClick"></div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6">
<div>
<p class="Intro" style="margin-top: 4em;">Ballerina’s visual approach allows you to create programs and integrate services and apps via sequence diagrams.</p>
</div>
</div>
<div class="cNewtoBallerina" style="margin-top: 2em;">
<div class="">
<h2>New to Ballerina?</h2>
<div class="col-sm-12 col-md-6 ">
<div class="cNewtoBallerinaCol">
<h3>Start with the Ballerina </br><a id="NewtoBallerina-documentation" class="cSmallButtons" href="http://ballerinalang.org/docs/"/>documentation</a></h3>
</div>
</div>
<div class="col-sm-12 col-md-6">
<div class="cNewtoBallerinaCol">
<h3>
Ask questions on #Ballerinalang on </br><a id="NewtoBallerina-Stackoverflow" class="cSmallButtons" href="http://stackoverflow.com/questions/tagged/ballerinalang"/>Stackoverflow</a>
</h3>
</div>
</div>
<div class="col-sm-12 col-md-12">
<p>By building around a visual programming model, Ballerina allows you to connect apps and services and create any program via a sequence diagram. It’s a unique approach that we believe will make all of us faster and more effective at designing integration logic. </p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row cBallerinaContentRow">
<div class="container">
<div class="col-sm-12 col-md-2"></div>
<div class="col-sm-12 col-md-8">
<a class="twitter-timeline" href="https://twitter.com/ballerinalang" data-tweet-limit="3">Tweets by ballerinalang</a> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
<div class="col-sm-12 col-md-2"></div>
</div>
</div>
<div class="row cBallerinaContentRow cGrayRow">
<div class="container">
<div class="cBallerinaContentColContainer" style="background-image: none;">
<div class="col-sm-12 col-md-12">
<div class="" id="Get-involved">
<h2>Get involved</h2>
<h3>Ballerina is an open source project. We want you to use it, abuse it and show us how to improve it.</h3>
<div class="cNewtoBallerina" style="width: 100%; padding-top: 4em;">
<div class="">
<div class="col-sm-12 col-md-4 ">
<div class="cNewtoBallerinaCol">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/docs.svg"/>
<h4>Read the architecture <a id="Getinvolved-documentation" class="cSmallButtons" href="https://docs.google.com/document/d/1aWX-Wkrp6ZXPG3Ei83OJd645Ss2b1rLdGvZ7-_f4J08/edit#"/>documentation</a></h4>
</div>
</div>
<div class="col-sm-12 col-md-4">
<div class="cNewtoBallerinaCol cMiddle">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/fork.svg"/>
<h4>Fork Ballerina on <a id="Getinvolved-Github" class="cSmallButtons" href="https://github.com/ballerinalang"/>Github</a></h4>
</div>
</div>
<div class="col-sm-12 col-md-4">
<div class="cNewtoBallerinaCol">
<img src="//wso2.cachefly.net/wso2/sites/all/ballerina/img/dev.svg"/>
<h4>
Join the <a id="Getinvolved-BallerinaDevGroup" href="https://groups.google.com/forum/#!forum/ballerina-dev">Ballerina Dev Group</a>.
</h4>
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6">
<div class="cSlackContainer">
<div class="col-sm 12 col-md-12" style="text-align:center;">
<h2>Subscribe for updates</h2>
</div>
<div class="col-sm 12 col-md-12">
<a class="cBallerinaButtons fancybox cSubscribe" id="Getinvolved-slack" href="#subscribeUser">Subscribe</a>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6">
<div class="cSlackContainer">
<div class="col-sm 12 col-md-12" style="text-align:center;">
<h2>We’re on Slack! Let’s talk.</h2>
</div>
<div class="col-sm 12 col-md-12">
<a class="cBallerinaButtons fancybox cSubscribe" id="Getinvolved-slack" href="#subscribe">Request an Invite</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row cBallerinaContentRow" style="padding: 1em 0;">
<div class="container">
<div class="cSocialMedia">
<a href="https://www.facebook.com/BallerinaLang/" id="iFB" target="_blank">
<svg version="1.1" class="cSVGMenuIcons" id="iFooterSVGTracking_fb" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 216 216" enable-background="new 0 0 216 216" xml:space="preserve">
<path d="M80.318,215.866h43.272V107.453h30.206L157,71.199h-33.41c0,0,0-13.555,0-20.701 c0-8.522,1.73-11.936,10.005-11.936c6.653,0,23.405,0,23.405,0V0.917c0,0-24.67,0-29.942,0c-32.222,0-46.74,14.17-46.74,41.336 c0,23.635,0,28.946,0,28.946H57.784v36.725h22.534V215.866z"/>
</svg>
</a>
<a href="https://twitter.com/ballerinalang" target="_blank" id="iTwitter">
<svg class="cSVGMenuIcons" version="1.1" id="iFooterSVGTracking_twitter" xmlns="http://wwwa.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 217.796 177.016" enable-background="new 0 0 217.796 177.016" xml:space="preserve">
<path d="M0,156.928c19.764,12.661,43.248,20.091,68.477,20.091c82.971,0,129.816-70.094,127.012-132.928 c8.729-6.308,16.308-14.167,22.307-23.156c-8.027,3.589-16.634,5.972-25.661,7.055c9.196-5.513,16.288-14.259,19.615-24.735 c-8.653,5.13-18.204,8.849-28.352,10.877c-8.167-8.709-19.773-14.129-32.632-14.129c-28.856,0-50.022,26.903-43.542,54.881 C70.117,53.015,37.168,35.25,15.147,8.142C3.467,28.28,9.097,54.557,28.987,67.845c-7.326-0.271-14.241-2.261-20.259-5.579 c-0.477,20.688,14.385,40.051,35.841,44.341c-6.274,1.737-13.171,2.102-20.156,0.803c5.653,17.756,22.184,30.632,41.719,31.015 C47.363,153.161,23.722,159.75,0,156.928z"/>
</svg>
</a>
<a href="https://www.linkedin.com/groups/10333249" target="_blank" id="iLinkedin">
<svg version="1.1" id="iFooterSVGTracking_linkedin" class="cSVGMenuIcons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 216 216" enable-background="new 0 0 216 216" xml:space="preserve">
<rect x="4.267" y="71.146" width="44.034" height="142.273"/>
<path d="M26.033,52.494c14.434,0,26.115-11.773,26.115-26.252C52.148,11.744,40.467,0,26.033,0 C11.686,0,0,11.744,0,26.242C0,40.721,11.686,52.494,26.033,52.494z"/>
<path d="M118.703,138.751c0-20.015,9.193-31.963,26.846-31.963c16.17,0,23.984,11.442,23.984,31.963 c0,20.491,0,74.669,0,74.669h43.832c0,0,0-51.979,0-90.062c0-38.131-21.619-56.57-51.783-56.57 c-30.182,0-42.879,23.517-42.879,23.517V71.146H76.444V213.42h42.259C118.703,213.42,118.703,160.645,118.703,138.751z"/>
</svg>
</a>
</div>
</div>
</div>
<div class="row cBallerinaFooter" id="iBallerinaFooter">
</div>
<div class="cBallerinaDownloadForm" id="subscribe">
<form>