You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Marek Šabo <ms...@buk.cvut.cz> on 2011/09/13 01:47:51 UTC

3.1 example app

Hi,

I would like to know whether there is an example app featuring most of 
new (DI) features in 3.1. I didn't have problem with configuration but I 
didn't find any injection examples or neat tricks in tutorial or on website.

Regards,

Marek

Re: 3.1 example app & extended types

Posted by Marek Šabo <ms...@buk.cvut.cz>.
On 09/13/2011 08:38 PM, Andrus Adamchik wrote:
> On Sep 13, 2011, at 8:53 PM, Marek Šabo wrote:
>
>> Tomcat uses HashMap to store filters so order of initialization is not guaranteed
> Wow. That would be a major bug in Tomcat. IIRC the servlet spec is quite explicit about the order of filters being the same as their declarations in web.xml.
>
> Andrus
>
I thought so. It's just to order of filter chaining is guaranteed to be 
the same as the order of mapping declarations in web.xml. But filter 
init where the stuff I needed occurred is apparently not. I find it 
disturbing to say the least.

Marek

Re: 3.1 example app & extended types

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Sep 13, 2011, at 8:53 PM, Marek Šabo wrote:

> Tomcat uses HashMap to store filters so order of initialization is not guaranteed 

Wow. That would be a major bug in Tomcat. IIRC the servlet spec is quite explicit about the order of filters being the same as their declarations in web.xml. 

Andrus


Re: 3.1 example app & extended types

Posted by Marek Šabo <ms...@buk.cvut.cz>.
> yes it should. Make sure your filter is initialized before you call the code above and the filter name in web.xml is the same as your Cayenne XML file name.
>
> Andrus
I managed to hack this. Tomcat uses HashMap to store filters so order of 
initialization is not guaranteed (which of course happened to me). So I 
renamed wicket filter so it's hashcode is "greater than" that of 
cayenne's in the terms of HashMap.

Sometimes... :sigh:

Marek

Re: 3.1 example app & extended types

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Sep 13, 2011, at 4:39 PM, Marek Šabo wrote:

> Oj I see, so I'm probably not gonna use @Inject anywhere?

Except in your own Cayenne extensions that you'll load in Cayenne container.

> I managed to upgrade configure from 3.0 to 3.1 but I don't know how to add extended types. I used to do it in wicket init method (wicket filter is second in web.xml, both are mapped to /*) but now I got nullpointer when I do this:
> 
>        ServerRuntime sr = (ServerRuntime) WebUtil.getCayenneRuntime(getServletContext());
>        DataDomain domain = sr.getDataDomain(); <-- NPE
>        DataNode node = domain.getNode("mainNode");
>        node.getAdapter().getExtendedTypes().registerType(new Inet4AddressType());
> 
> Any ideas where I should finish my configuration? I thought WebUtil will provide instace of CayenneRuntime after CayenneFilter was handled.

yes it should. Make sure your filter is initialized before you call the code above and the filter name in web.xml is the same as your Cayenne XML file name.

Andrus

Re: 3.1 example app & extended types

Posted by Marek Šabo <ms...@buk.cvut.cz>.
Oj I see, so I'm probably not gonna use @Inject anywhere?

I managed to upgrade configure from 3.0 to 3.1 but I don't know how to 
add extended types. I used to do it in wicket init method (wicket filter 
is second in web.xml, both are mapped to /*) but now I got nullpointer 
when I do this:

         ServerRuntime sr = (ServerRuntime) 
WebUtil.getCayenneRuntime(getServletContext());
         DataDomain domain = sr.getDataDomain(); <-- NPE
         DataNode node = domain.getNode("mainNode");
         node.getAdapter().getExtendedTypes().registerType(new 
Inet4AddressType());

Any ideas where I should finish my configuration? I thought WebUtil will 
provide instace of CayenneRuntime after CayenneFilter was handled.

Thanks,

Marek

Re: 3.1 example app

Posted by Andrus Adamchik <an...@objectstyle.org>.
It is very new, so all the neat tricks are still to be developed based on configuration guidelines :-). Also keep in mind that the injection mechanism was designed for Cayenne, not for end user apps, so it is intentionally unassuming in most cases.

Andrus


On Sep 13, 2011, at 2:47 AM, Marek Šabo wrote:
> Hi,
> 
> I would like to know whether there is an example app featuring most of new (DI) features in 3.1. I didn't have problem with configuration but I didn't find any injection examples or neat tricks in tutorial or on website.
> 
> Regards,
> 
> Marek