Skip to content

Instantly share code, notes, and snippets.

View stephen-masters's full-sized avatar

Stephen Masters stephen-masters

View GitHub Profile
@stephen-masters
stephen-masters / kie-workbench-rest-api-create-org.sh
Last active February 9, 2019 03:22
Example script to create an organisation, repository and project in KIE Workbench, via the REST API.
#!/bin/bash
# --------------------------------------------------------------------------------
#
# Script to demonstrate using the KIE (Drools) Workbench REST API to:
#
# create an organistion.
# create a repository associated with the organisation.
# create a project in the repository.
#
package com.sctrcd.multidsdemo;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
spring:
datasource:
url: jdbc:mysql://localhost/foo_schema
username: root
password: d4t4b4s3sForLif3
driverClassName: com.mysql.jdbc.Driver
test-on-borrow: true
test-while-idle: true
validation-query: select 1;
maxActive: 1
package com.sctrcd.multidsdemo;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
@RestController
public class BusPassController {
private static Logger log = LoggerFactory.getLogger(BusPassController.class);
private final BusPassService busPassService;
@Autowired
public BusPassController(BusPassService busPassService) {
this.busPassService = busPassService;
@Service
public class BusPassService {
private final KieContainer kieContainer;
@Autowired
public BusPassService(KieContainer kieContainer) {
log.info("Initialising a new bus pass session.");
this.kieContainer = kieContainer;
}
@SpringBootApplication
public class BusPassApp {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(BusPassApp.class, args);
}
@Bean
public KieContainer kieContainer() {
return KieServices.Factory.get().getKieClasspathContainer();
@stephen-masters
stephen-masters / gist:e246df0650984490e7be
Created February 6, 2015 13:01
Get a KieContainer and create a KieSession
KieContainer kieContainer = KieServices.Factory.get().getKieClasspathContainer();
KieSession kieSession = kieContainer.newKieSession("BusPassSession");
@stephen-masters
stephen-masters / kmodule.xml
Created February 6, 2015 12:55
Example kmodule.xml
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<kbase name="BusPassKbase" packages="com.sctrcd.buspassws.rules">
<ksession name="BusPassSession" />
</kbase>
</kmodule>
@stephen-masters
stephen-masters / spring-platform-bom.xml
Last active August 29, 2015 14:14
Spring IO Platform BOM
<!-- Transitively bring in the Spring IO Platform Bill-of-Materials `pom.xml` -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>1.1.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>