Search in sources :

Example 1 with CommandLineRunner

use of org.springframework.boot.CommandLineRunner in project Activiti by Activiti.

the class Application method seedUsersAndGroups.

@Bean
CommandLineRunner seedUsersAndGroups(final IdentityService identityService) {
    return new CommandLineRunner() {

        @Override
        public void run(String... strings) throws Exception {
            // install groups & users
            Group group = identityService.newGroup("user");
            group.setName("users");
            group.setType("security-role");
            identityService.saveGroup(group);
            User joram = identityService.newUser("jbarrez");
            joram.setFirstName("Joram");
            joram.setLastName("Barrez");
            joram.setPassword("password");
            identityService.saveUser(joram);
            User josh = identityService.newUser("jlong");
            josh.setFirstName("Josh");
            josh.setLastName("Long");
            josh.setPassword("password");
            identityService.saveUser(josh);
            identityService.createMembership("jbarrez", "user");
            identityService.createMembership("jlong", "user");
        }
    };
}
Also used : Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User) CommandLineRunner(org.springframework.boot.CommandLineRunner) Bean(org.springframework.context.annotation.Bean)

Example 2 with CommandLineRunner

use of org.springframework.boot.CommandLineRunner in project spring-cloud-function by spring-cloud.

the class TaskConfiguration method commandLineRunner.

@Bean
public CommandLineRunner commandLineRunner(FunctionCatalog registry) {
    final Supplier<Flux<Object>> supplier = registry.lookup(Supplier.class, properties.getSupplier());
    final Function<Flux<Object>, Flux<Object>> function = registry.lookup(Function.class, properties.getFunction());
    final Consumer<Flux<Object>> consumer = consumer(registry);
    CommandLineRunner runner = new CommandLineRunner() {

        @Override
        public void run(String... args) throws Exception {
            consumer.accept(function.apply(supplier.get()));
        }
    };
    return runner;
}
Also used : Flux(reactor.core.publisher.Flux) CommandLineRunner(org.springframework.boot.CommandLineRunner) Bean(org.springframework.context.annotation.Bean)

Aggregations

CommandLineRunner (org.springframework.boot.CommandLineRunner)2 Bean (org.springframework.context.annotation.Bean)2 Group (org.activiti.engine.identity.Group)1 User (org.activiti.engine.identity.User)1 Flux (reactor.core.publisher.Flux)1