Hi Christian,

maybe you missed some topics in my previous e-mail:

1/ I don't want to do injection: I want to create a new injection framework, I just want to provide the plumbing for this framework (in my case, I just create blueprint XML using the annotation at build time, not runtime). Even if you use DS/SCR, blueprint, etc, you have a bunch of resources to write (valid pom.xml, blueprint.xml, component xml, etc). The purpose is to simplify this, and even hide this to final developers.

2/ The karaf-boot-starter purpose is exactly to create a startable artifact with all config.

We already have maven archetype, but again, you have to write some plumbing. My goal is to allow developers to focus on their core business code, and delegate all plumbing to karaf-boot.

Regards
JB

On 09/10/2015 09:05 AM, Christian Schneider wrote:
Hi JB,

I support the idea of providing a simple startable artifact of karaf +
fetures + config.

The injection annotations I do not like at all. A plugin like above
should do one thing well. Doing injection well is difficult. There are
already projects that provide support for this like pax-cdi, blueprint
mave plugin, DS. We should only leverage existing injection frameworks and
not try to replace them.

What we could provide in from of annotations is the description of the
assembly. Like features, configs, other customizations.

Spring boot also provides a way to create a complete container out of
one single project. So it also embeds the java source and provides
injections. I considers this to be rather a gimmic and demo feature not
a thing that is really needed. A real OSGi application will always
consist of
more than one bundle / maven project. So I think it is enough to just
provide a way to package such exising bundles into a nice runnable
artifact.

If you think the demoing aspect is very important then we could try to
have sample code using DS annotations and the container config code in
the same project. This is rarely a real life example but could show that
we can be as small as spring boot.

To still have a nice starting point for people I propose we crerate a
maven archetype that creates a project structure like this:
- main
  - service : A project defining and publishing a DS service
  - assembly or boot : A project defining the assembly config that
creates the runnable artifact

Christian

Am 09.09.2015 um 16:32 schrieb Jean-Baptiste Onofré:
Hi all,

I worked on a prototype about Karaf Boot.

Let me give you some backgrounds and discuss about that all together.

 Why Karaf Boot ?
 ----------------
When you develop artifacts (bundles) to be deployed in Karaf, you can
see that the actual time that you spend on your business code is
finally largely less important that all the plumbing effort that you
have to do (writing OSGi Activator, or blueprint/scr descriptor, etc).

It means that your "go to market" is longer, and we should provide
something that allows you to focus on your code.

Even if SCR annotations is a very good step forward, some use cases
are not so easy to do (JPA, JTA for instance).

And anyway, you have to prepare your pom.xml with different plugin and
dependency.

Moreover, when you have your artifacts, you have to prepare Karaf
container, and deploy those artifacts there. Even if it's "container"
approach is the most important for me, we can give even more
flexibility by providing a way to embed and prepare Karaf in a ready
to execute jar/artifact.

 What is Karaf Boot ?
 --------------------
Karaf Boot provides four components:
* karaf-boot-parent is the Maven parent pom that your project just
inherit: that's all ! All plugins, dependencies, etc are described in
this parent, you even don't have to define packaging as bundle,
standard jar is fine.
* karaf-boot (coming with karaf-boot-parent) provides annotations that
you use directly in your business code (like @Bean, @Service,
@Reference, @Inject, etc): again, your focus on your code, karaf-boot
deals with the plumbing.
* karaf-boot-maven-plugin (coming with karaf-boot-parent) scan the
classes and generate a blueprint XML. For now, I'm using blueprint
generation (because we can cover lot of use cases, for instance, I
plan to provide @rest annotation that will generate blueprint XML with
cxf jaxrs server, etc).
* karaf-boot-starter is the module providing a convenient way to
embed, configure and bootstrap Karaf.

Just to illustrate this, let's take a look on the
karaf-boot-sample-simple.

The pom.xml is really simple:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";>

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.karaf.boot</groupId>
        <artifactId>karaf-boot-parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>karaf-boot-sample-simple</artifactId>
    <version>1.0.0-SNAPSHOT</version>

</project>

You can see, the only thing that the developer has to do: define
karaf-boot-parent as parent pom. That's all.

Now, in the code, you have just one bean that we want to run:

package org.apache.karaf.boot.sample.simple;

import org.apache.karaf.boot.Bean;
import org.apache.karaf.boot.Init;

@Bean(id = "simple-bean")
public class SimpleBean {

    @Init
    public void simple() {
        System.out.println("Hello world");
    }

}

You can see the @Bean and @Init karaf-boot annotations. The
karaf-boot-maven-plugin will generate the blueprint descriptor using
this.


 Current Status
 --------------
I pushed Karaf Boot structure there:

https://github.com/jbonofre/karaf-boot

It's a mix of rewrapping of existing code (from aries, pax-exam, etc)
and additions.

I created the annotations, I'm now working on the
karaf-boot-maven-plugin based on Christian's work in aries (I'm
actually scanning the boot annotations now, and generating the XML).

I will push new changes later today and tomorrow.

 Open Questions
 ---------------
* For now, I would prefer to be 'artifacts' and 'resources' generator:
I think it's better than to depend to a feature running in Karaf, but
it's open to discussion.
* I'm now generating blueprint. Probably native OSGi or scr generation
can make sense.
* I'm generating bundles: thanks to the Karaf4 features resolver, as
the bundles provide requirements/capabilities metadata, I think it's a
good start. However, maybe it's worth to be able to create features,
kar, profile.

Thoughts ?

Thanks,
Regards
JB


--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to