This documentation is for WSO2 Business Rules Server 2.1.0.View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

This sample demonstrates how to use the BRS for a simple greetings service.

Prerequisites

Before building the sample, the following needs to be done:

Sample Rule Definition

Rules

Rule 1 : If the time is between 12 and 18, say good afternoon.

Rule 2 : If the time is between 6 and 12, say good morning.

Rule 3 : If the time is between 18 and 24, say good night.

Facts

There is one fact named A user logged in into the system and a result named GreetingMessage.

package samples.greeting;
import java.util.Calendar;

/**
 * User
 */
public class User {
    private String name ;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int now(){
        Calendar cal = Calendar.getInstance();
        return cal.get(Calendar.HOUR_OF_DAY);
    }
}
    
package samples.greeting;
/**
 * greeting message
 */
public class GreetingMessage {
    private String message ;
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
}

 

Building the sample

 

Executing the sample

 

Analyzing the output

  • No labels