Re: JPA (Hibernate) with Apache Karaf 4.2

2018-05-29 Thread Kerry

Hi Alex,

I've created a simple project that shows how to use JPA in Karaf although it 
uses OpenJPA as the JPA provider:

https://github.com/jtkb/jpatest

Hopefully it will be straight forward enough for you to get to grips with JPA 
in an OSGi environment.

Kerry


On 29/05/18 19:54, alex09 wrote:

Hi there,

being new to OSGi, I have difficulties getting demos/examples/tutorials to
run (esp. with JPA) with Apache Karaf 4.2.

I tried all these resources:
* Apache Aries 2.7 JPA examples:
https://github.com/apache/aries-jpa/tree/master/examples (also user
documentation is not accurate for the current Karaf versions)
* Tutorials at http://karaf.apache.org/documentation.html#tutorials, which
don't work as liquid-reality.de has not been available for weeks now (I
found some of them here, but still they don't work:
https://github.com/cschneider/Karaf-Tutorial)
* Apache Aries 2.7: The Blog Example:
http://aries.apache.org/modules/samples/blog-sample.html
* Hibernate Demos:
https://github.com/hibernate/hibernate-demos/tree/master/hibernate-orm/osgi
(also reflecting the outdated user documentation)
* also the Entwicklerpress 143 book "OSGi Entwicklung" and Enterprise OSGi
in Action

All without success, the sample are really dated and there is a lot more to
do than just simple changes - this is difficult for someone coming new to
this topic.
I'd certainly volunteer for helping with this, but as there is no starting
point currently, this is complicated.

So my question is: are there any plans to create a new, sound
description/documentation/tutorial/example for JPA/Hibernate on Apache Karaf
4.x? Or isn't this supposed to work anymore as there are better practices
for persistence in OSGi?

Thanks & Best

Alex



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html





Re: JPA (Hibernate) with Apache Karaf 4.2

2018-05-29 Thread François Papon
Hi Alex,

We have already start example in a dev guide and planned to released it in the 
4.2.1 or Karaf.

You have a preview on the JB repo :

https://github.com/jbonofre/karaf/tree/DEV_GUIDE/examples

There is JPA example working with Hibernate.

Hope it can help and you are welcome to contribute :)

François

Le 29 mai 2018 10:54 PM, alex09  a écrit :
>
> Hi there, 
>
> being new to OSGi, I have difficulties getting demos/examples/tutorials to 
> run (esp. with JPA) with Apache Karaf 4.2. 
>
> I tried all these resources: 
> * Apache Aries 2.7 JPA examples: 
> https://github.com/apache/aries-jpa/tree/master/examples (also user 
> documentation is not accurate for the current Karaf versions) 
> * Tutorials at http://karaf.apache.org/documentation.html#tutorials, which 
> don't work as liquid-reality.de has not been available for weeks now (I 
> found some of them here, but still they don't work: 
> https://github.com/cschneider/Karaf-Tutorial) 
> * Apache Aries 2.7: The Blog Example: 
> http://aries.apache.org/modules/samples/blog-sample.html 
> * Hibernate Demos: 
> https://github.com/hibernate/hibernate-demos/tree/master/hibernate-orm/osgi 
> (also reflecting the outdated user documentation) 
> * also the Entwicklerpress 143 book "OSGi Entwicklung" and Enterprise OSGi 
> in Action 
>
> All without success, the sample are really dated and there is a lot more to 
> do than just simple changes - this is difficult for someone coming new to 
> this topic. 
> I'd certainly volunteer for helping with this, but as there is no starting 
> point currently, this is complicated. 
>
> So my question is: are there any plans to create a new, sound 
> description/documentation/tutorial/example for JPA/Hibernate on Apache Karaf 
> 4.x? Or isn't this supposed to work anymore as there are better practices 
> for persistence in OSGi? 
>
> Thanks & Best 
>
> Alex 
>
>
>
> -- 
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html 


JPA (Hibernate) with Apache Karaf 4.2

2018-05-29 Thread alex09
Hi there,

being new to OSGi, I have difficulties getting demos/examples/tutorials to
run (esp. with JPA) with Apache Karaf 4.2.

I tried all these resources:
* Apache Aries 2.7 JPA examples:
https://github.com/apache/aries-jpa/tree/master/examples (also user
documentation is not accurate for the current Karaf versions) 
* Tutorials at http://karaf.apache.org/documentation.html#tutorials, which
don't work as liquid-reality.de has not been available for weeks now (I
found some of them here, but still they don't work:
https://github.com/cschneider/Karaf-Tutorial)
* Apache Aries 2.7: The Blog Example:
http://aries.apache.org/modules/samples/blog-sample.html
* Hibernate Demos:
https://github.com/hibernate/hibernate-demos/tree/master/hibernate-orm/osgi
(also reflecting the outdated user documentation)
* also the Entwicklerpress 143 book "OSGi Entwicklung" and Enterprise OSGi
in Action

All without success, the sample are really dated and there is a lot more to
do than just simple changes - this is difficult for someone coming new to
this topic. 
I'd certainly volunteer for helping with this, but as there is no starting
point currently, this is complicated.

So my question is: are there any plans to create a new, sound
description/documentation/tutorial/example for JPA/Hibernate on Apache Karaf
4.x? Or isn't this supposed to work anymore as there are better practices
for persistence in OSGi?

Thanks & Best

Alex 



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: REST - Declarative Services

2018-05-29 Thread Scott Lewis

On 5/28/2018 10:40 AM, Guenther Schmidt wrote:

Hello All,

I’ve been developing services using Declarative Services for dependency 
injection and it was a breeze so far. Now I want to expose some of the 
functionality via a REST API and I’m stuck. So far I’ve deployed my bundles 
through bundle:install -s man: …. all very easy. But what should be simple, 
exposing this through REST is becoming difficult. There are tips out there 
suggesting to use Blueprint, which I don’t want, others seem to suggest that I 
need to create a “feature” package.

Then there’s also the requirements to “feature” install cxf. That’s OK btw, I 
only have to do that once. But is there really no simple way to create a simple 
REST service using merely DS?

Guenther



Hi Guenther,

Another option would be ECF Remote Services [1].   It's a full 
implementation of the OSGi Remote Services and Remote Service Admin 
(R7/latest) specifications [2].   These specifications standardize the 
remoting of OSGi services (meta-data and dynamics), so it works 
seemlessly with DS and other frameworks that use the OSGi service registry.


ECF has a provider architecture so allows the use of a variety of 
distribution providers [3], including CXF [4].


We have features defined for Karaf [5] and we also now have support for 
bndtools-based development [6] (workspace and project templates).


Caveat:   ECF is in the middle of 'release season' for the Eclipse 
simultaneous release (late June), so the transition to ECF 3.14.0 is not 
yet complete.  For example, the Karaf features don't yet point to 3.14.0 
at maven central only because we have to wait for the SR  process before 
deployment of the release to maven central.   However, I'm happy to 
provide needed support via [7].


Scott

[1] https://wiki.eclipse.org/Eclipse_Communication_Framework_Project

[2] 
https://osgi.org/specification/osgi.cmpn/7.0.0/service.remoteserviceadmin.html


[3] https://wiki.eclipse.org/Distribution_Providers

[4] https://github.com/ECF/JaxRSProviders

[5] https://wiki.eclipse.org/EIG:Install_into_Apache_Karaf

[6] 
https://wiki.eclipse.org/Bndtools_Support_for_Remote_Services_Development


[7] https://accounts.eclipse.org/mailing-list/ecf-dev

[8] http://eclipseecf.blogspot.com/



Re: REST - Declarative Services

2018-05-29 Thread Steinar Bang
> Guenther Schmidt :

> Then there’s also the requirements to “feature” install cxf. That’s OK
> btw, I only have to do that once. But is there really no simple way to
> create a simple REST service using merely DS?

Take a look at these two:

 https://github.com/steinarb/post-body-capture
   A super-simple REST service/debug tool that just writes the POSTed
   body to a file, and the file name to the injected OSGi log service (I
   used it to see what sonarcloud was sending to its webhooks)

 https://github.com/steinarb/sonar-collector
  A REST service intended to be used as a postbuild SonarCloud/SonarQube
  webhook.  The service will store key numbers from the build in a
  PostgreSQL database.
  Nifty things here are using liquibase to initialize the PostgreSQL
  database and injecting config in the @Activate method, allowing the
  JDBC connection info to be configured from the karaf console.

Build and install information can be found in the README files.



Re: REST - Declarative Services

2018-05-29 Thread Alex Weirig

BTW: these should be the features I installed in karaf ...

feature:repo-add cxf-dosgi
feature:install cxf-dosgi-provider-rs


Mat frëndleche Gréiss, Mit freundlichen Grüßen, Meilleures salutations, 
Kind regards,

Alex Weirig
Responsable Technique Ville de Luxembourg Service Enseignement Centre 
Technolink *Tel* +352 4796 - 6127  *Fax* +352 42 88 81 
*Email* alex.wei...@technolink.lu  
www.vdl.lu  // www.technolink.lu 
 Centre Technolink 2, rue Charles de Tornaco 
L-2623 LUXEMBOURG


On 29/05/2018 08:36, Alex Weirig wrote:


I'm using the approach Christian is referring to and I can confirm 
that it's really easy and convenient.


I'm creating DS services to expose selected backend services with a 
REST API


@Component(
        immediate = true
        , property = {
                "service.exported.interfaces=*",
                "service.exported.configs=org.apache.cxf.rs",
                "org.apache.cxf.rs.address=/room-service"
        }
        , service = GestionInfrastructuresREST.class
)
public class GestionInfrastructuresRESTImpl implements 
GestionInfrastructuresREST {


    @Reference private LogService logger;
    @Reference private GestionInfrastructuresService service;     // 
my backend service


    ...


    @Override
    public Response getAllRooms() {
        List allRooms = 
service.getAllRooms();    // call to the backend service


        ... // process the result from the backend service

   return Response.ok(json, 
MediaType.APPLICATION_JSON).build();    // if result is OK


        ...  // do some error processing and return some error  e.g.
        return Response.serverError().build();
    }

}

Mat frëndleche Gréiss, Mit freundlichen Grüßen, Meilleures 
salutations, Kind regards,

Alex Weirig
Responsable Technique Ville de Luxembourg Service Enseignement Centre 
Technolink *Tel* +352 4796 - 6127  *Fax* +352 42 88 
81 *Email* alex.wei...@technolink.lu 
 www.vdl.lu  // 
www.technolink.lu  Centre Technolink 2, rue 
Charles de Tornaco L-2623 LUXEMBOURG

On 28/05/2018 23:01, Christian Schneider wrote:
Aries JAX-RS should work. It is not yet released though. So currently 
there is only a snapshot. A release should follow soon.


Another option is to use CXF-DOSGi. You can find an example below. It 
is similar to Aries JAX-RS so a later switch should be easy.


https://github.com/apache/cxf-dosgi/tree/master/samples/rest

Christian

2018-05-28 19:40 GMT+02:00 Guenther Schmidt >:


Hello All,

I’ve been developing services using Declarative Services for
dependency injection and it was a breeze so far. Now I want to
expose some of the functionality via a REST API and I’m stuck. So
far I’ve deployed my bundles through bundle:install -s man: ….
all very easy. But what should be simple, exposing this through
REST is becoming difficult. There are tips out there suggesting
to use Blueprint, which I don’t want, others seem to suggest that
I need to create a “feature” package.

Then there’s also the requirements to “feature” install cxf.
That’s OK btw, I only have to do that once. But is there really
no simple way to create a simple REST service using merely DS?

Guenther





--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

--
This email was Anti Virus checked by SOPHOS UTM




<>

Re: REST - Declarative Services

2018-05-29 Thread Alex Weirig
I'm using the approach Christian is referring to and I can confirm that 
it's really easy and convenient.


I'm creating DS services to expose selected backend services with a REST API

@Component(
        immediate = true
        , property = {
                "service.exported.interfaces=*",
                "service.exported.configs=org.apache.cxf.rs",
                "org.apache.cxf.rs.address=/room-service"
        }
        , service = GestionInfrastructuresREST.class
)
public class GestionInfrastructuresRESTImpl implements 
GestionInfrastructuresREST {


    @Reference private LogService logger;
    @Reference private GestionInfrastructuresService service;     // my 
backend service


    ...


    @Override
    public Response getAllRooms() {
        List allRooms = 
service.getAllRooms();    // call to the backend service


        ... // process the result from the backend service

   return Response.ok(json, MediaType.APPLICATION_JSON).build();    
// if result is OK


        ...  // do some error processing and return some error  e.g.
        return Response.serverError().build();
    }

}

Mat frëndleche Gréiss, Mit freundlichen Grüßen, Meilleures salutations, 
Kind regards,

Alex Weirig
Responsable Technique Ville de Luxembourg Service Enseignement Centre 
Technolink *Tel* +352 4796 - 6127  *Fax* +352 42 88 81 
*Email* alex.wei...@technolink.lu  
www.vdl.lu  // www.technolink.lu 
 Centre Technolink 2, rue Charles de Tornaco 
L-2623 LUXEMBOURG


On 28/05/2018 23:01, Christian Schneider wrote:
Aries JAX-RS should work. It is not yet released though. So currently 
there is only a snapshot. A release should follow soon.


Another option is to use CXF-DOSGi. You can find an example below. It 
is similar to Aries JAX-RS so a later switch should be easy.


https://github.com/apache/cxf-dosgi/tree/master/samples/rest

Christian

2018-05-28 19:40 GMT+02:00 Guenther Schmidt >:


Hello All,

I’ve been developing services using Declarative Services for
dependency injection and it was a breeze so far. Now I want to
expose some of the functionality via a REST API and I’m stuck. So
far I’ve deployed my bundles through bundle:install -s man: …. all
very easy. But what should be simple, exposing this through REST
is becoming difficult. There are tips out there suggesting to use
Blueprint, which I don’t want, others seem to suggest that I need
to create a “feature” package.

Then there’s also the requirements to “feature” install cxf.
That’s OK btw, I only have to do that once. But is there really no
simple way to create a simple REST service using merely DS?

Guenther





--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

--
This email was Anti Virus checked by SOPHOS UTM


<>