Swan Lake Beta2 is here.
import ballerina/http;

// Listener declarations are allowed at the module level. 
// They are similar to variable declarations, but register the newly created Listener object with the module.
// If `new` returns an error, then module initialization fails.
listener http:Listener h = new (8080);

Providing Services

Providing services involves the interaction of three main things

1) Service objects are the counterpart of client objects. Service objects also have remote methods and they are remotely accessible to clients. Remote method of a client object typically calls the remote method of a service object.

2) Listener is the entity that receives the network input and then it makes calls to remote methods of attached service objects. Listeners are registered with the module as illustrated in the following example.

3) Modules have a lifecycle and they are initialized on program startup. Modules start up the registered listeners after the initialization and shut them down during the program shutdown.

import ballerina/http;
listener http:Listener h = new (8080);

Listener declarations are allowed at the module level. They are similar to variable declarations, but register the newly created Listener object with the module. If new returns an error, then module initialization fails.

bal run providing_services.bal
[ballerina/http] started HTTP/WS listener 0.0.0.0:8080
import ballerina/http;

// Listener declarations are allowed at the module level. 
// They are similar to variable declarations, but register the newly created Listener object with the module.
// If `new` returns an error, then module initialization fails.
listener http:Listener h = new (8080);

Providing Services

Providing services involves the interaction of three main things

1) Service objects are the counterpart of client objects. Service objects also have remote methods and they are remotely accessible to clients. Remote method of a client object typically calls the remote method of a service object.

2) Listener is the entity that receives the network input and then it makes calls to remote methods of attached service objects. Listeners are registered with the module as illustrated in the following example.

3) Modules have a lifecycle and they are initialized on program startup. Modules start up the registered listeners after the initialization and shut them down during the program shutdown.

import ballerina/http;
listener http:Listener h = new (8080);

Listener declarations are allowed at the module level. They are similar to variable declarations, but register the newly created Listener object with the module. If new returns an error, then module initialization fails.

bal run providing_services.bal
[ballerina/http] started HTTP/WS listener 0.0.0.0:8080

In the creation of Ballerina, we were inspired by so many technologies. Thank you to all that have come before us (and forgive us if we missed one): Java, Go, C, C++, D, Rust, Haskell, Kotlin, Dart, TypeScript, JavaScript, Python, Perl, Flow, Swift, Elm, RelaxNG, NPM, Crates, Maven, Gradle, Kubernetes, Docker, Envoy, Markdown, GitHub and WSO2.

Cookie Policy

This website uses cookies so that we can provide you with the best user experience. Read our Cookie Policy to find out more.

If you wish to disable cookies you can do so from your browser.

I Understand