cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cristiano Ghersi <cristiano.ghe...@abodata.com>
Subject Re: Cayenne under OSGi
Date Fri, 01 Mar 2013 08:53:12 GMT
Hi Andrus,

you perfectly caught the point: the difference is in the class loading.
The class loaders are populated from the application that uses Cayenne,
with the following example snippet:

ServerRuntime myRuntime = new ServerRuntime("myDomain.xml");
...
ClassRegistry.registerClass(MyPersistentClass1.class);
ClassRegistry.registerClass(MyPersistentClass2.class);
//call ClassRegistry.registerClass(Class) for each class created by
CayenneModeler

you can find ClassRegistry class in org.apache.cayenne.di.spi package; it
is the other brick added by ourselves in order to correctly run under OSGi

Let me know if you need any further information!

Thanks
Cristiano

2013/2/28 Andrus Adamchik <andrus@objectstyle.org>

> Hi Cristiano,
>
> So I guess our goal is to tweak the Cayenne build process (and code if
> needed) so that it builds OSGI-compatible jars.
>
> Let's start with the codeā€¦ I created a diff to better demonstrate the
> change in DefaultAdhocObjectFactory between Cayenne and your code:
>
> +import java.util.List;
> +
>  import org.apache.cayenne.CayenneRuntimeException;
>  import org.apache.cayenne.di.AdhocObjectFactory;
>  import org.apache.cayenne.di.Inject;
> @@ -102,6 +104,16 @@
>              return Class.forName(className, true, classLoader);
>          }
>          catch (ClassNotFoundException e) {
> +                       //try with the class loader registry
> +                       List<ClassLoader> registeredClassLoaders =
> ClassLoaderRegistry.registeredClassLoaders();
> +                       for (ClassLoader loader : registeredClassLoaders) {
> +                               try {
> +                                       return loader.loadClass(className);
> +                               }
> +                               catch (ClassNotFoundException cnfe) {
> +                               }
> +                       }
> +
>              if (!className.endsWith("[]")) {
>                  if ("byte".equals(className)) {
>                      return Byte.TYPE;
>
>
> I guess this is what you described in the previous message (only slightly
> different naming - ClassLoaderRegistry). I couldn't find who actually
> populates those extra class loaders inside ClassLoaderRegistry? Could you
> comment on this please?
>
> So other than that, I guess all we need is changing cayenne-server
> packaging from "jar" to "bundle" (and configuring the bundle plugin in the
> pom).
>
> Andrus
>
>
>
> On Feb 28, 2013, at 12:19 PM, Cristiano Ghersi <
> cristiano.ghersi@abodata.com> wrote:
> > Hi Andrus,
> >
> > I know you have been very busy with the new upcoming release of Cayenne.
> >
> > I'd like to know if and when we can resume the task of Cayenne
> > OSGi-fication.
> >
> > I'm at your disposal for every clarification.
> >
> > Thank you very much
> > Best
> > Cristiano
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message