I was trying to implement an OSGi application , application has servlet(implemented using jetty), jaxb(using eclipselink moxy), and Jpa part(the problem part). I was trying to use eclipselink inside apache felix container for jpa functionality, I tried various approach but couldn't implement it. I just need some working example or tutorial link.
The easiest way to use jpa in felix is to use Apache Karaf as it has pre packaged features for eclipselink as well as Aries JPA which makes it easier to use any jpa provider in OSGi.
See example with declarative services, or with blueprint.
For plain felix I recommend to use bndtools to get the list of bundles and also to be able to directly run felix.
I started a tutorial to package and run the tasklist-ds example using bndtools
Related
I have one Eclipse RCP3 project.Now I need to call a rest api|(java) and Post some information using that API. Need Help.
Being a Java application, an Eclipse RCP app can use most existing Java REST client libraries. My opinion is that the easiest way is to use the ECF JAX-RS Jersey Client. I recently wrote an article about how to incorporate this into an Eclipse RCP application:
https://www.modumind.com/2020/05/19/eclipse-rcp-and-rest-an-introduction/
In short, the JAX-RS Jersey Client is an OSGi Remote Services client created as part of the Eclipse Communications Framework (ECF) project. It embeds a Jersey/Jackson JAX-RS implementation that allows you to create REST clients as annotated interfaces that are made available as OSGi services locally. Jackson is used to data bind the REST responses to Java POJOs which require little or no annotation.
This solution allows you to skip most of the scaffolding code that usually has to be written to make REST calls in a Java application. But of course, you can also use Jersey and Jackson directly, those plugins are made available via Eclipse Orbit project.
http://www.eclipse.org/orbit
The GitHub repository for the ECF JAX-RS Jersey Client can be found here:
https://github.com/ECF/JaxRSProviders
I want to create a user library which includes all jars that are required to support Spring AOP apart from standard spring jars.
Don't do it, but use regular dependency management, e.g. via Maven or Gradle. Don't create your own uber JARs, it is just ugly and intransparent.
Which JARs you need is described in the Spring AOP manual. I am not a Spring user myself, only an AspectJ user, but AFAIK for simple Spring AOP you do not need anything but spring-aop.jar. I could be mistaken, but maybe you just try. CGLIB support is already contained in spring-core.jar.
You only need more JARs if you wish to upgrade to full AspectJ support. Then you would need spring-aspects.jar and, depending on how you start your application, maybe aspectjweaver.jar.
Another idea: If you want to make life easier for yourself, maybe you want to use Spring Boot?
How can I use OpenJpa ,with using Persistence.xml configuration same we use in jpa, I dont want to use Enhance.xml.
If you rely on some non-IDE tool to build your app, you can enhance automatically during buildtime. For Maven, for example, see this
If you are running in a JavaEE container you will get enhancement for free. The other option when running in a JSE environment is to configure the -javaagent.
Take a look at the section titled 'Explicit javaagent support'. As for JavaEE stuff, I'd suggest getting ahold of the Pro JPA 2 book. It is very good at describing usage of JPA in an EE environment.
Had anybody attempted to use MyBatis as their persistence library for a JBoss 7.1 /Java EE6 application?
I'm wondering what are the best approaches to handling connections, transations, rollbacks etc?
How about CDI support? Looking around online it seems at this time MyBatis only supports two Dependency Injection (JSR-330) frameworks, Google Guice and Spring. I did run into CDI Extensions which may be something look into.
My idea would be to have the container handle all of the above however it may be difficult getting to that point.
Any tips, hints, experiences?
There is a new mybatis-cdi module. It is not released yet, but you can try the snapshot, it is at github: https://github.com/mybatis/cdi
There is no CDI support at all but as you said, if you want DI go Spring or Guice.
With JBoss you have mainly two chances:
- EJB 3
- Spring
If using EJB 3 transactions are handled automatically by them. MyBatis just ignores transactions and lets the container commit/rollback.
When using Spring, MyBatis ties to Spring transactions using the integration module MyBatis-Spring.
I would create my own CDI bean - use #Produces for a factory, and #Inject to get the session.
Here is old iBatis Spring factory, that might be the producer, after some changes:
SqlMapClientFactoryBean
I am a newbie to OSGi, started using felix. I am at present well versed with the concept of bundles, service etc. I have a requirement where I can embed Felix into Tomcat, I tried googling the same but was unable to find a relevant solution for my purpose.
What I exactly need is..
Till now I used to deploy my web app bundles into embedded http jetty service/PAX web.. installed inside Felix, but now I want to put Felix into Apache Tomcat/any other application server, so that whenever my tomcat starts up I need my felix instance up and running, and at the same time should be able to deploy/install/start my bundles through felix.
Any kind of help would be greatly appreciated.
You might want to consider the Apache Sling Launchpad subproject. This creates a WAR file which can be deployed into any servlet container and which launches the Apache Felix framework as the OSGi framework.
See also the Sling Launchpad and Embedding Sling for more information.