Skip to content

Instantly share code, notes, and snippets.

View daneshk's full-sized avatar

Danesh Kuruppu daneshk

View GitHub Profile
package org.wso2.carbon.transport.http.netty.config;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
String resourcePath = "/esb/abc.xml";
boolean resourceExists = configRegistry.resourceExists(resourcePath);
if (resourceExists) {
Resource registryResource = configRegistry.get(resourcePath);
try {
OMElement contentElement = AXIOMUtil.stringToOM(
new String((byte[]) registryResource.getContent()));
contentElement.addChild(garElement); //edit content
registryResource.setContent(contentElement.toString());
configRegistry.put(resourcePath, registryResource);
service<grpc> helloWorld {
function sayHello (HelloRequest req) (HelloResponse res) {
HelloResponse response = {message:"Hello" + request.getName()};
return response;
}
}
package org.ballerinalang.net.grpc.stockquote;
import ballerina.net.grpc;
service<grpc> StockQuoteService {
resource getQuote (StockRequest req, StockQuote res) {
println("Getting stock details for symbol: " + req.name);
res.symbol = "IBM";
res.name = "International Business Machines";
res.last = 149.52;
syntax = "proto3";
package org.ballerinalang.net.grpc.stockquote;
service StockQuoteService {
rpc getQuotes(org.ballerinalang.net.grpc.stockquote.Void) returns (org.ballerinalang.net.grpc.stockquote.StockQuotes);
rpc addStock(org.ballerinalang.net.grpc.stockquote.StockQuote) returns (org.ballerinalang.net.grpc.stockquote.Void);
rpc getQuote(org.ballerinalang.net.grpc.stockquote.StockRequest) returns (org.ballerinalang.net.grpc.stockquote.StockQuote);
rpc getNames(org.ballerinalang.net.grpc.stockquote.Void) returns (org.ballerinalang.net.grpc.stockquote.StockNames);
}
message Void {
}
package org.ballerinalang.net.grpc.helloworld;
import ballerina.net.grpc;
service<grpc> helloWorld {
resource hello (HelloRequest req, HelloResponse res) {
println(req.name);
res.message = "First Hurray " + req.name;
}
}
syntax = "proto3";
package org.ballerinalang.net.grpc.helloworld;
import "google/protobuf/wrappers.proto";
service helloWorld {
rpc hello(google.protobuf.StringValue) returns (google.protobuf.StringValue);
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.ballerinalang.orbit.com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0.v1</version>
import ballerina.log;
import ballerina.io;
import ballerina.net.http;
// This service is a participant in the distributed transaction. It will get infected when it receives a transaction
// context from the participant. The transaction context, in the HTTP case, will be passed in as custom HTTP headers.
@http:configuration {
basePath:"/flight",
host:"localhost",
port:8889
import ballerina.math;
import ballerina.net.http;
import ballerina.log;
import ballerina.io;
// This is the initiator of the distributed transaction
@http:configuration {
basePath:"/",
host:"localhost",
port:8000