Skip to content

Instantly share code, notes, and snippets.

View hasithaa's full-sized avatar
🏠
Working from home

Hasitha Aravinda hasithaa

🏠
Working from home
View GitHub Profile
@hasithaa
hasithaa / record_visitor.bal
Last active April 24, 2023 10:57
Record Visitor Pattern
import ballerina/io;
// Type Nodes
type Node record {
string kind;
string value;
};
type NodeA record {
@hasithaa
hasithaa / visitor_pattern.bal
Created April 24, 2023 05:15
Ballerina Object Visitor Pattern
import ballerina/io;
public type Element object {
public function accept(Visitor visitor);
};
public class ConcreteElementA {
*Element;
public function accept(Visitor visitor) {
@hasithaa
hasithaa / README.md
Last active December 19, 2019 07:56
A script to test Ballerina installers on windows.

How to run

  1. Install Ballerina using windows installer.
  2. Open cmd or powershell.
  3. Clone this scripts. git clone https://gist.github.com/e606661be03d7045be973868b9e9ed67.git wintests.
  4. cd to wintests.
  5. run test command.
import ballerina.net.http;
public struct Initiator2pcClientConfig {
string coordinatorProtocolAt;
}
public struct Initiator2pcClientEP {
http:ClientEndpoint httpClient;
}
@hasithaa
hasithaa / service_late_bind.bal
Created March 12, 2018 02:04
Binding a service to endpoint programmatically.
import ballerina.net.http;
import ballerina.io;
import ballerina.runtime;
// This is the service endpoint
endpoint<http:Service> ep1 {
port:9090
}
// This service is not bound to an endpoint.
@hasithaa
hasithaa / main.bal
Created March 12, 2018 01:35
A function call, that calls a remote API
import ballerina.net.http;
import ballerina.io;
// This is the client endpoint.
endpoint<http:ClientEndpoint> clientEP {
serviceUri: "http://www.mocky.io"
}
function main(string[] args) {
http:Request req2 = {};
@hasithaa
hasithaa / passthrough.bal
Last active March 12, 2018 01:31
Ballerina Stateless service that call backend API.
import ballerina.net.http;
// This is the service endpoint
endpoint<http:Service> ep1 {
port:9090
}
// This is the client endpoint.
endpoint<http:ClientEndpoint> ep2 {
serviceUri: "http://www.mocky.io"
@hasithaa
hasithaa / hello_world.bal
Last active March 12, 2018 02:10
Ballerina Stateless service that returns hello world
import ballerina.net.http;
endpoint<http:service> helloServiceEP {
port : 8080
}
@http:serviceConfig {
endpoints : [helloServiceEP], // This service is bound to helloServiceEP
basePath : "/helloService"
}
package org.wso2.bpmn.helloworld.v2;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
/**
* Hello World Service Task - Version 2.
*/
public class HelloWorldServiceTaskV2 implements JavaDelegate {
package org.wso2.bpmn.helloworld.v1;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
/**
* Hello World Service Task- V1.
*/
public class HelloWorldServiceTaskV1 implements JavaDelegate {
@Override