ideaplugins / micronaut-ktx

Micronaut kotlin extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Micronaut kotlin extensions

Build Status Bintray Download Coverage Status Apache 2.0

Usage

Maven

Add the repository

<repository>
    <url>https://dl.bintray.com/agomez/maven</url>
</repository>

Add the dependency

<dependency>
  <groupId>ar.com.agomez</groupId>
  <artifactId>micronaut-ktx</artifactId>
  <version>x.y.z</version>
</dependency>

Gradle (groovy version)

Add the repository

maven {
    url = 'https://dl.bintray.com/agomez/maven'
}

Add the dependency

implementation 'ar.com.agomez:micronaut-ktx:x.y.z'

Gradle (kotlin version)

Add the repository

maven("https://dl.bintray.com/agomez/maven")

Add the dependency

implementation("ar.com.agomez:micronaut-ktx:x.y.z")

Example

ApplicationContext extensions

run<FooApplication>()
run<FooApplication>("env1", "env2")
run<FooApplication>(props, "env1", "env2")
run<FooApplication>(propertySource, "env1", "env2")
buildAndStart<FooApplication>()
buildAndStart<FooApplication>("env1", "env2")
buildAndStart<FooApplication>(propSrc1, propSrc2)
buildAndStart<FooApplication>(props, "env1", "env2")
buildAndStart<FooApplication>(propSrc, "env1", "env2")

BeanContext extensions

val foo = context.createBean<Foo>()
val foo: Foo = context.createBean()
val foo = context.createBean<Foo>(args)
val foo: Foo = context.createBean(args)
val foo = context.createBean<Foo>(argsMap)
val foo: Foo = context.createBean(argsMap)
val foo = context.createStereotypedBean<Foo, Prototype>()
val foo = context.createStereotypedBean<Foo, Prototype>(args)
val foo = context.createStereotypedBean<Foo, Prototype>(argsMap)
val foo = context.destroyBean<Foo>()
val foo: Foo = context.destroyBean()

BeanDefinitionRegistry extensions

val foo = registry.getStereotypedBeanDefinition<Foo, Prototype>()
registry.containsBean<Foo>()
Foo::class in registry
registry.containsStereotypedBean<Foo, Prototype>()
(Foo::class to Prototype::class) in registry
val fooDefinition = registry.findStereotypedBeanDefinition<Foo, Prototype>()
val fooDefinitions = registry.getBeanDefinitions<Foo>()
val fooDefinitions: Collections<BeanDefinition<Foo>> = registry.getBeanDefinitions()
val prototypeDefinitions = registry.getStereotypedBeanDefinitions<Prototype>()
val prototypeRegistrations = registry.getStereotypedBeanRegistrations<Prototype>()
val fooRegistrations = registry.getBeanRegistrations<Foo>()
val fooRegistrations: Collection<BeanRegistration<Foo>> = registry.getBeanRegistrations()
val fooDefinition = registry.findProxiedBeanDefinition<Foo, Prototype>()
val fooDefinition = registry.getProxiedBeanDefinition<Foo, Prototype>()
val fooDefinition = registry.getBeanDefinition<Foo>()
val fooDefinition: BeanDefinition<Foo> = registry.getBeanDefinition()
val fooDefinition = registry.findBeanDefinition<Foo>()
val fooDefinition: BeanDefinition<Foo>? = registry.findBeanDefinition()
registry.registerStereotypedSingleton<Foo, Prototype>(foo, true)
registry.registerStereotypedSingleton<Foo, Prototype>(foo)
registry.registerNotStereotypedSingleton<Foo>(foo)

BeanLocator extensions

val foo = locator.getBean<Foo>()
val foo: Foo = locator.getBean()
val foo = locator.getStereotypedBean<Foo, Prototype>()
val foo = locator.findBean<Foo>()
val foo: Foo? = locator.findBean()
val foo = locator.findStereotypedBean<Foo, Prototype>()
val foos = locator.getBeansOfType<Foo>()
val foos: Collection<Foo> = locator.getBeansOfType()
val prototypeFoos = locator.getStereotypedBeansOfType<Foo, Prototype>()
val foosStream = locator.streamOfType<Foo>()
val foosStream: Stream<Foo> = locator.streamOfType()
val foosSequence = locator.sequenceOfType<Foo>()
val foosSequence: Sequence<Foo> = locator.sequenceOfType()
val prototypeFoosStream = locator.streamOfStereotypedType<Foo, Prototype>()
val prototypeFoosSequence = locator.sequenceOfStereotypedType<Foo, Prototype>()
val foo = locator.getProxyTargetBean<Foo, Prototype>()
val foo = locator.findOrInstantiateBean<Foo>()
val foo: Foo = locator.findOrInstantiateBean()

Micronaut extensions

mnRun<FooApplication>(args)

Qualifier extensions

qualifier.reduce(candidates)
qualifier.qualify(candidates)

Qualifiers extensions

qualifierByAnnotation<Foo, Bar>(metadata)
qualifierByStereotype<Foo, Prototype>()

TaskScheduler extensions

scheduler.scheduleCallable("0 0 12 * * ?") {
    doWork()
}
scheduler.scheduleCallable(Duration.ofSeconds(5)) {
    doMoreWork()
}

For more examples check the API documentation and the tests.

License

Micronaut kotlin extensions is released under the Apache 2.0 license.

Copyright 2018-present by the authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at following link.

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Micronaut kotlin extensions

License:Apache License 2.0


Languages

Language:Kotlin 100.0%