[ 
https://issues.apache.org/jira/browse/WICKET-2781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12927615#action_12927615
 ] 

Erkki Lindpere commented on WICKET-2781:
----------------------------------------

Is noone intersted in this? In that case, I suggest this be closed as WONTFIX. 
I'm no longer interested in providing a patch because

1) I no longer work for the project where we used this

2) the logic got even more complicated to support more cases and is kind of 
hard to follow and may have performance impacts

3) it's usefulness was not very great, instead of injecting generics there are 
obviously other ways to solve this

> Support @SpringBean injection into generic superclass
> -----------------------------------------------------
>
>                 Key: WICKET-2781
>                 URL: https://issues.apache.org/jira/browse/WICKET-2781
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-spring
>    Affects Versions: 1.4.7
>            Reporter: Erkki Lindpere
>            Priority: Minor
>         Attachments: wicket-spring-inject-patch.txt
>
>
> It's possible to inject Spring Beans into a generic superclass, if the field 
> type to be injected is a type variable. I will attach a patch that does this 
> (I don't know if it's the best or most general implementation, but it works 
> in my case). This allows us to reduce code in a wicket-spring project and it 
> would be great if you could integrate this change into wicket-spring.
> This also allows better integration with Scala because it seems Scala 
> initialization order is different enough from Java that it seems impossible 
> to make a variable injected into a subclass of a generic superclass available 
> to the generic superclass's constructor.
> Simplified example for the motivation:
> public abstract class EditPage<EntityType, RepoType extends 
> IRepository<EntityType>> {
>   @SpringBean
>   RepoType repository;
>   ...
> }
> Concrete "edit pages" extend this and define EntityType and RepoType. 
> Injecting in the superclass allows the subclasses to be very thin, which is 
> great. I was not able to implement this in Scala (maybe there's some trick 
> but I don't know), even if I replace the repostiory with: protected abstract 
> RepoType getRepository() and implement this in a Scala subclass:
> class UserEditPage extends EditPage<User, UserRepo> {
>   @SpringBean
>   var repo: UserRepo = _
>   def getRepository = repo
> }
> when the superclass' constructor calls getRepository, it will get null (and 
> sometimes method not found getRepository: IRepository, but that might be due 
> to JRebel)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to