Inject Dao ( with JPA impl) into Wicket without Spring ?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Inject Dao ( with JPA impl) into Wicket without Spring ?

smallufo
Hi
Is there any way to inject a DAO into Wicket without Spring ?
ex :

public interface PersonDao { some methods... }

public class PersonDaoImpl implements PersonDao , Serializable {
  @PersistenceContext(unitName = "data", type =
PersistenceContextType.TRANSACTION)
  EntityManager entityManager;

  .. other method implementations ...
}

public class CurrentPage extends WebPage {
  @javax.inject.Inject PersonDao personDao;
}

It's not working , anybody know how to achieve this ?

server :
Resin 4.0.4
Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

Igor Vaynberg-2
something has to do the injection, if not spring you can try
salve.googlecode.com or aspectj, etc

-igor

On Tue, Mar 23, 2010 at 8:20 AM, smallufo <[hidden email]> wrote:

> Hi
> Is there any way to inject a DAO into Wicket without Spring ?
> ex :
>
> public interface PersonDao { some methods... }
>
> public class PersonDaoImpl implements PersonDao , Serializable {
>  @PersistenceContext(unitName = "data", type =
> PersistenceContextType.TRANSACTION)
>  EntityManager entityManager;
>
>  .. other method implementations ...
> }
>
> public class CurrentPage extends WebPage {
>  @javax.inject.Inject PersonDao personDao;
> }
>
> It's not working , anybody know how to achieve this ?
>
> server :
> Resin 4.0.4
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

smallufo
Is it possible to 'not' introduce any 3rd library / annotation to enable
this feature ?
Will a custom IComponentInstantiationListener be able to do this ?


2010/3/23 Igor Vaynberg <[hidden email]>

> something has to do the injection, if not spring you can try
> salve.googlecode.com or aspectj, etc
>
> -igor
>
> On Tue, Mar 23, 2010 at 8:20 AM, smallufo <[hidden email]> wrote:
> > Hi
> > Is there any way to inject a DAO into Wicket without Spring ?
> > ex :
> >
> > public interface PersonDao { some methods... }
> >
> > public class PersonDaoImpl implements PersonDao , Serializable {
> >  @PersistenceContext(unitName = "data", type =
> > PersistenceContextType.TRANSACTION)
> >  EntityManager entityManager;
> >
> >  .. other method implementations ...
> > }
> >
> > public class CurrentPage extends WebPage {
> >  @javax.inject.Inject PersonDao personDao;
> > }
> >
> > It's not working , anybody know how to achieve this ?
> >
> > server :
> > Resin 4.0.4
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

Igor Vaynberg-2
sure, see wicket-ioc, you can write whatever lookup code you need yourself then.

-igor

On Tue, Mar 23, 2010 at 8:52 AM, smallufo <[hidden email]> wrote:

> Is it possible to 'not' introduce any 3rd library / annotation to enable
> this feature ?
> Will a custom IComponentInstantiationListener be able to do this ?
>
>
> 2010/3/23 Igor Vaynberg <[hidden email]>
>
>> something has to do the injection, if not spring you can try
>> salve.googlecode.com or aspectj, etc
>>
>> -igor
>>
>> On Tue, Mar 23, 2010 at 8:20 AM, smallufo <[hidden email]> wrote:
>> > Hi
>> > Is there any way to inject a DAO into Wicket without Spring ?
>> > ex :
>> >
>> > public interface PersonDao { some methods... }
>> >
>> > public class PersonDaoImpl implements PersonDao , Serializable {
>> >  @PersistenceContext(unitName = "data", type =
>> > PersistenceContextType.TRANSACTION)
>> >  EntityManager entityManager;
>> >
>> >  .. other method implementations ...
>> > }
>> >
>> > public class CurrentPage extends WebPage {
>> >  @javax.inject.Inject PersonDao personDao;
>> > }
>> >
>> > It's not working , anybody know how to achieve this ?
>> >
>> > server :
>> > Resin 4.0.4
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

Major Péter
In reply to this post by smallufo
I think yes, Wicket is already depending on cglib, so you could create
something like this:
http://fisheye6.atlassian.com/browse/wicket/branches/wicket-1.4.x/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java?r=HEAD
or for non-spring code check out the wicketstuff javaee-inject project.

Best Regards,
Peter

2010-03-23 16:52 keltezéssel, smallufo írta:

> Is it possible to 'not' introduce any 3rd library / annotation to enable
> this feature ?
> Will a custom IComponentInstantiationListener be able to do this ?
>
>
> 2010/3/23 Igor Vaynberg <[hidden email]>
>
>> something has to do the injection, if not spring you can try
>> salve.googlecode.com or aspectj, etc
>>
>> -igor
>>
>> On Tue, Mar 23, 2010 at 8:20 AM, smallufo <[hidden email]> wrote:
>>> Hi
>>> Is there any way to inject a DAO into Wicket without Spring ?
>>> ex :
>>>
>>> public interface PersonDao { some methods... }
>>>
>>> public class PersonDaoImpl implements PersonDao , Serializable {
>>>  @PersistenceContext(unitName = "data", type =
>>> PersistenceContextType.TRANSACTION)
>>>  EntityManager entityManager;
>>>
>>>  .. other method implementations ...
>>> }
>>>
>>> public class CurrentPage extends WebPage {
>>>  @javax.inject.Inject PersonDao personDao;
>>> }
>>>
>>> It's not working , anybody know how to achieve this ?
>>>
>>> server :
>>> Resin 4.0.4

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

smallufo
I am just curious :
I am trying  Resin 4.0.4 , which natively supports JSR 330's
@javax.inject.Inject .
And I am able to inject the Dao to one Servlet without any problem :

public class HelloServlet extends HttpServlet {
  @Inject
  private PersonDao personDao; // it will automatically create PersonDaoImpl
(and inject PersistenceContext ) and inject to here.
...
}

Since WicketServlet is essentially a HttpServlet , there should be a way to
intercept the injection when in a JSR-330-enabled container (like Resin 4 ,
JBoss , Glassfish v3)  ... But I don't know how ...
I think it will greatly reduce the webapp size (and memory footprint ,
probably) without spring.



2010/3/23 Major Péter <[hidden email]>

> I think yes, Wicket is already depending on cglib, so you could create
> something like this:
>
> http://fisheye6.atlassian.com/browse/wicket/branches/wicket-1.4.x/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java?r=HEAD
> or for non-spring code check out the wicketstuff javaee-inject project.
>
> Best Regards,
> Peter
>
> 2010-03-23 16:52 keltezéssel, smallufo írta:
> > Is it possible to 'not' introduce any 3rd library / annotation to enable
> > this feature ?
> > Will a custom IComponentInstantiationListener be able to do this ?
> >
> >
> > 2010/3/23 Igor Vaynberg <[hidden email]>
> >
> >> something has to do the injection, if not spring you can try
> >> salve.googlecode.com or aspectj, etc
> >>
> >> -igor
> >>
> >> On Tue, Mar 23, 2010 at 8:20 AM, smallufo <[hidden email]> wrote:
> >>> Hi
> >>> Is there any way to inject a DAO into Wicket without Spring ?
> >>> ex :
> >>>
> >>> public interface PersonDao { some methods... }
> >>>
> >>> public class PersonDaoImpl implements PersonDao , Serializable {
> >>>  @PersistenceContext(unitName = "data", type =
> >>> PersistenceContextType.TRANSACTION)
> >>>  EntityManager entityManager;
> >>>
> >>>  .. other method implementations ...
> >>> }
> >>>
> >>> public class CurrentPage extends WebPage {
> >>>  @javax.inject.Inject PersonDao personDao;
> >>> }
> >>>
> >>> It's not working , anybody know how to achieve this ?
> >>>
> >>> server :
> >>> Resin 4.0.4
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

Major Péter
You don't need Spring for that, create your own ComponentInjector which
will do the lookups for you and inject the field.
Just like here:
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-core/javaee-inject-parent/javaee-inject/src/main/java/org/wicketstuff/javaee/JavaEEBeanLocator.java

Regards,
Peter

2010-03-23 17:08 keltezéssel, smallufo írta:

> I am just curious :
> I am trying  Resin 4.0.4 , which natively supports JSR 330's
> @javax.inject.Inject .
> And I am able to inject the Dao to one Servlet without any problem :
>
> public class HelloServlet extends HttpServlet {
>   @Inject
>   private PersonDao personDao; // it will automatically create PersonDaoImpl
> (and inject PersistenceContext ) and inject to here.
> ...
> }
>
> Since WicketServlet is essentially a HttpServlet , there should be a way to
> intercept the injection when in a JSR-330-enabled container (like Resin 4 ,
> JBoss , Glassfish v3)  ... But I don't know how ...
> I think it will greatly reduce the webapp size (and memory footprint ,
> probably) without spring.
>
>
>
> 2010/3/23 Major Péter <[hidden email]>
>
>> I think yes, Wicket is already depending on cglib, so you could create
>> something like this:
>>
>> http://fisheye6.atlassian.com/browse/wicket/branches/wicket-1.4.x/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java?r=HEAD
>> or for non-spring code check out the wicketstuff javaee-inject project.
>>
>> Best Regards,
>> Peter
>>
>> 2010-03-23 16:52 keltezéssel, smallufo írta:
>>> Is it possible to 'not' introduce any 3rd library / annotation to enable
>>> this feature ?
>>> Will a custom IComponentInstantiationListener be able to do this ?
>>>
>>>
>>> 2010/3/23 Igor Vaynberg <[hidden email]>
>>>
>>>> something has to do the injection, if not spring you can try
>>>> salve.googlecode.com or aspectj, etc
>>>>
>>>> -igor
>>>>
>>>> On Tue, Mar 23, 2010 at 8:20 AM, smallufo <[hidden email]> wrote:
>>>>> Hi
>>>>> Is there any way to inject a DAO into Wicket without Spring ?
>>>>> ex :
>>>>>
>>>>> public interface PersonDao { some methods... }
>>>>>
>>>>> public class PersonDaoImpl implements PersonDao , Serializable {
>>>>>  @PersistenceContext(unitName = "data", type =
>>>>> PersistenceContextType.TRANSACTION)
>>>>>  EntityManager entityManager;
>>>>>
>>>>>  .. other method implementations ...
>>>>> }
>>>>>
>>>>> public class CurrentPage extends WebPage {
>>>>>  @javax.inject.Inject PersonDao personDao;
>>>>> }
>>>>>
>>>>> It's not working , anybody know how to achieve this ?
>>>>>
>>>>> server :
>>>>> Resin 4.0.4
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

Igor Vaynberg-2
In reply to this post by smallufo
jsr 330 only defines the @inject annot

the spect that defines injection, servlet 3.0? only supports injection
of j2ee artifacts such as servlets and filters

-igor

On Tue, Mar 23, 2010 at 9:08 AM, smallufo <[hidden email]> wrote:

> I am just curious :
> I am trying  Resin 4.0.4 , which natively supports JSR 330's
> @javax.inject.Inject .
> And I am able to inject the Dao to one Servlet without any problem :
>
> public class HelloServlet extends HttpServlet {
>  @Inject
>  private PersonDao personDao; // it will automatically create PersonDaoImpl
> (and inject PersistenceContext ) and inject to here.
> ...
> }
>
> Since WicketServlet is essentially a HttpServlet , there should be a way to
> intercept the injection when in a JSR-330-enabled container (like Resin 4 ,
> JBoss , Glassfish v3)  ... But I don't know how ...
> I think it will greatly reduce the webapp size (and memory footprint ,
> probably) without spring.
>
>
>
> 2010/3/23 Major Péter <[hidden email]>
>
>> I think yes, Wicket is already depending on cglib, so you could create
>> something like this:
>>
>> http://fisheye6.atlassian.com/browse/wicket/branches/wicket-1.4.x/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java?r=HEAD
>> or for non-spring code check out the wicketstuff javaee-inject project.
>>
>> Best Regards,
>> Peter
>>
>> 2010-03-23 16:52 keltezéssel, smallufo írta:
>> > Is it possible to 'not' introduce any 3rd library / annotation to enable
>> > this feature ?
>> > Will a custom IComponentInstantiationListener be able to do this ?
>> >
>> >
>> > 2010/3/23 Igor Vaynberg <[hidden email]>
>> >
>> >> something has to do the injection, if not spring you can try
>> >> salve.googlecode.com or aspectj, etc
>> >>
>> >> -igor
>> >>
>> >> On Tue, Mar 23, 2010 at 8:20 AM, smallufo <[hidden email]> wrote:
>> >>> Hi
>> >>> Is there any way to inject a DAO into Wicket without Spring ?
>> >>> ex :
>> >>>
>> >>> public interface PersonDao { some methods... }
>> >>>
>> >>> public class PersonDaoImpl implements PersonDao , Serializable {
>> >>>  @PersistenceContext(unitName = "data", type =
>> >>> PersistenceContextType.TRANSACTION)
>> >>>  EntityManager entityManager;
>> >>>
>> >>>  .. other method implementations ...
>> >>> }
>> >>>
>> >>> public class CurrentPage extends WebPage {
>> >>>  @javax.inject.Inject PersonDao personDao;
>> >>> }
>> >>>
>> >>> It's not working , anybody know how to achieve this ?
>> >>>
>> >>> server :
>> >>> Resin 4.0.4
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

smallufo
In reply to this post by Major Péter
Thank you , I tried it , and it can successfully inject EntityManagerFactory
into a WebPage ,
But it seems unable to inject EntityManager , is it because of some
thread-safe limitation here ?

2010/3/23 Major Péter <[hidden email]>

> I think yes, Wicket is already depending on cglib, so you could create
> something like this:
>
> http://fisheye6.atlassian.com/browse/wicket/branches/wicket-1.4.x/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java?r=HEAD
> or for non-spring code check out the wicketstuff javaee-inject project.
>
> Best Regards,
> Peter
>
Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

smallufo
2010/3/24 smallufo <[hidden email]>

> Thank you , I tried it , and it can successfully
> inject EntityManagerFactory into a WebPage ,
> But it seems unable to inject EntityManager , is it because of some
> thread-safe limitation here ?
>
>
Sorry , I meant wicket-contrib-javaee here.



>  2010/3/23 Major Péter <[hidden email]>
>
>> I think yes, Wicket is already depending on cglib, so you could create
>>
>> something like this:
>>
>> http://fisheye6.atlassian.com/browse/wicket/branches/wicket-1.4.x/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java?r=HEAD
>> or for non-spring code check out the wicketstuff javaee-inject project.
>>
>> Best Regards,
>> Peter
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Inject Dao ( with JPA impl) into Wicket without Spring ?

Per Lundholm
We have put all lookup in the wicket application class. Thus all pages
do: getApplication().getWhatEverService().

I belive this make unit testing a bit easier since you mock the
application the same way every time.

/Per

On Tue, Mar 23, 2010 at 6:05 PM, smallufo <[hidden email]> wrote:

> 2010/3/24 smallufo <[hidden email]>
>
>> Thank you , I tried it , and it can successfully
>> inject EntityManagerFactory into a WebPage ,
>> But it seems unable to inject EntityManager , is it because of some
>> thread-safe limitation here ?
>>
>>
> Sorry , I meant wicket-contrib-javaee here.
>
>
>
>>  2010/3/23 Major Péter <[hidden email]>
>>
>>> I think yes, Wicket is already depending on cglib, so you could create
>>>
>>> something like this:
>>>
>>> http://fisheye6.atlassian.com/browse/wicket/branches/wicket-1.4.x/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java?r=HEAD
>>> or for non-spring code check out the wicketstuff javaee-inject project.
>>>
>>> Best Regards,
>>> Peter
>>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]