Skip to content

Instantly share code, notes, and snippets.

@stephen-masters
Created February 6, 2015 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephen-masters/cff5e162df0f465d3a6c to your computer and use it in GitHub Desktop.
Save stephen-masters/cff5e162df0f465d3a6c to your computer and use it in GitHub Desktop.
@Service
public class BusPassService {
private final KieContainer kieContainer;
@Autowired
public BusPassService(KieContainer kieContainer) {
log.info("Initialising a new bus pass session.");
this.kieContainer = kieContainer;
}
/**
* Create a new session, insert a person's details and fire rules to
* determine what kind of bus pass is to be issued.
*/
public BusPass getBusPass(Person person) {
KieSession kieSession = kieContainer.newKieSession("BusPassSession");
kieSession.insert(person);
kieSession.fireAllRules();
BusPass busPass = findBusPass(kieSession);
kieSession.dispose();
return busPass;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment