cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cristiano Ghersi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAY-1882) Porting to OSGi environment
Date Thu, 14 Nov 2013 14:59:21 GMT

    [ https://issues.apache.org/jira/browse/CAY-1882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13822492#comment-13822492
] 

Cristiano Ghersi commented on CAY-1882:
---------------------------------------

1) Code to change:
1.a) A new class ClassRegistry has to be added in the org.apache.cayenne.di.spi package. Find
attached the class code.
1.b) A Cayenne class (org.apache.cayenne.di.spi.DefaultAdhocObjectFactory) has also to be
modified to be able to search in the ClassRegistry for classes. Find attached the class code.

2) Maven generation for OSGi: Maven can generate an OSGi Bundle adding automatically all the
dependencies, based on the maven project dependencies and source analysis. To generate an
OSGi bundle some changes are needed in the pom.xml (or files if you are working on multiple
projects) file. First of all it is necessary to change the packaging type of the project from
jar to bundle as it is show in this snippet:
<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.cayenne</groupId>
                <artifactId>cayenne-parent</artifactId>
                <version>3.1B2-SNAPSHOT</version>
                <relativePath>../../pom.xml</relativePath>
        </parent>
        <groupId>org.apache.cayenne.osgi</groupId>
        <artifactId>cayenne-osgi</artifactId>
        <name>Cayenne OSGified</name>
     <packaging>bundle</packaging>
  <url>http://maven.apache.org</url>



Then it is necessary to add a plugin to the build section:
<plugins>
        ...
        <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.7</version>
                <extensions>true</extensions>
                <configuration>
                        <instructions>
                                <Export-Package>org.apache.cayenne, org.apache.cayenne.*</Export-Package>
                                <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        </instructions>
                </configuration>
        </plugin>
        ...
</plugins>
Finally you can generate the bundle jar
$ cd cayenne-osgi # or navigate to the root directory of the cayenne osgi project
$ mvn org.apache.felix:maven-bundle-plugin:bundle
The bundle jar can be found in cayenne-osgi/target/cayenne-osgi.jar
Feel free to change this procedure according to your experience!

3) Use in production environment.
To use Cayenne under OSGi environment, the user needs to place the following snippet at the
initialization of Cayenne stuff: http://www.snip2code.com/Snippet/12313/Apache-Cayenne--correctly-load-classes-u


> Porting to OSGi environment
> ---------------------------
>
>                 Key: CAY-1882
>                 URL: https://issues.apache.org/jira/browse/CAY-1882
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Core Library
>    Affects Versions: 3.1B1, 3.1B2, 3.2M1
>         Environment: OSGi
>            Reporter: Cristiano Ghersi
>              Labels: class_loader, osgi
>             Fix For: 3.2M2
>
>
> Cayenne framework doesn't run under OSGi environments as class-loading problems arise
in the dynamic loading of autogenerated classes by Cayenne Modeler.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message