Hi Daniel,
there's a tutorial for setting up Aries + OpenJPA + JNDI + Datasource I
wrote last autumn:
http://hwellmann.blogspot.com/2010/09/openjpa-and-osgi.html
The version numbers are out of date by now, but if you know the basics
about JPA in classic web containers like Tomcat, this post may help you
to understand some of the differences when using JPA with OSGi and Aries.
Am 28.06.2011 16:40, schrieb Daniel Plappert:
I am new to OSGI and currently trying to understand its mechanism. I
want to create a service (bundle), which creates a JDNI datasource
and provides this datasource to other services. What I've read so far
is, OSGI "itself" (felix/equinox) can't use JNDI, but aries can.
That's why I am asking.
OSGi Core doesn't know about JNDI. The OSGi Enterprise Spec defines an
OSGi JNDI service, and Aries provides an implementation.
What I am trying to do is to provide a flexible service, let's say a
JDNIDatasourceService. This service creates a JNDI datasource, which
connection parameters can be configured "from the outside".
JNDI datasource? You mean a JDBC datasource registered in a JNDI naming
context...
> I don't
what to deploy the bundle with a persistence.xml, in which the
username, password and so on are hard coded. What I want is the same
possible mechanism like i.e. a tomcat server provides. It is possible
to declare a JNDI datasource with tomcat so that all my webapps can
access this datasource.
Forget about Tomcat for a moment - Tomcat is not an OSGi web container.
You can write a tiny bundle that creates a datasource (in plain old Java
code) and then registers this datasource as an OSGi service.
Aries JNDI assigns a JNDI name to all OSGi services, so your persistence
bundle can simply access the datasource by a JNDI name like
osgi:service/javax.sql.DataSource, without depending on any driver and
connection details.
Some more pointers:
Simple sample with OSGi + Derby + OpenJPA + Aries JNDI + Aries JPA:
http://code.google.com/p/osgi-enterprise/source/browse/#hg%2Fjpa
Aries Blog Sample
http://aries.apache.org/modules/samples/blog-sample.html
Aries JNDI:
http://aries.apache.org/modules/jndiproject.html
Hope that helps,
Harald