Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: How to use java 1.5 generics features

  1. #1
    Join Date
    Apr 2005
    Location
    Belo Horizonte, MG - Brasil
    Posts
    25

    Default How to use java 1.5 generics features

    Hi,

    I would like to know if is possible to use generics with BeanFactory and how to use it?

    thank's

    Moa.
    Moa
    \"With no walls and fences on Linux who needs Windows and Gates\"

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Moa,

    Most of Spring's code is written to run on Java 1.3 so you won't be able to take advantage of any generics features with most of Spring codebase. Some specific features are written for 1.4 or 1.5 but as yet there is no generics support in the API.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  3. #3
    Join Date
    Apr 2005
    Location
    Belo Horizonte, MG - Brasil
    Posts
    25

    Default

    Hi Robh, thank's for the fast answer.

    Just one last question, do you know when this feature will be implemented?

    bye.
    Moa
    \"With no walls and fences on Linux who needs Windows and Gates\"

  4. #4
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    No plans as yet to make Spring dependent on Java 1.5 and its probably not something you will see for some time. We are committed to making sure that the widest range of users can take advantage of Spring so we will continue to support Java 1.3 for the forseeable future.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  5. #5
    Join Date
    Sep 2008
    Posts
    11

    Default Well Java6 is out and Spring can't do generics

    Hello robh,

    it about 3 years ago from your post. Does spring now supports generics?

    Greetings

    astrapi

  6. #6
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Spring always supported generics, in a certain way. What exactly do you want to do?

  7. #7
    Join Date
    Sep 2008
    Posts
    11

    Question

    Hi dejanp,

    here is my code:

    package beans;

    import service.AbstractBusinessService;

    public interface AbstractBackingBean<E, BB, SR, SF> {


    public E getDomainObject();


    public BB getBusinessBean();

    public AbstractBusinessService <E, SR, SF> getBusinessService();

    public void setDomainObject(E pDomainObject);

    }

    ______________________________________________

    package generics;

    import java.util.List;

    import service.AbstractBusinessService;

    public class GenericBackingBean<E, BB, SR, SF> {

    private Class<E> entity;

    private Class<BB> bb;

    private Class<SR> sr;

    private Class<SF> sf;

    private AbstractBusinessService<E, SR, SF> abs;

    public GenericBackingBean(Class<E> entity, Class<BB> bb, Class<SR> sr, Class<SF> sf) {
    this.entity = entity;
    this.bb = bb;
    this.sr = sr;
    this.sf = sf;
    }

    public void saveEntity(E entity) {
    abs.saveVersion(entity);
    }

    public List<SR> findBySearchFilter(SF searchBean) {
    return abs.findBySearchFilter(searchBean);
    }

    }

    _____________________________________________

    My Question:
    How do I define the Class in the applicationContext.xml?

    <bean id="myBackingBean" class="generics.GenericBackingBean">
    <constructor-arg>
    <value>domain.Person</value>
    <value>beans.BusinessBean</value>
    <value>beans.SearchResultBean</value>
    <value>beans.SearchBean</value>
    </constructor-arg>
    </bean>

  8. #8
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Does it work like that?

  9. #9
    Join Date
    Sep 2008
    Posts
    11

    Default

    No i have problem with the "value"-Element in the "constructor-arg"-Element.

    How do i make this in Spring?

  10. #10
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Post the stacktrace of the error please.

Similar Threads

  1. Appropriate to use Spring with a standalone java app?
    By spovilaitis in forum Container
    Replies: 4
    Last Post: Aug 8th, 2005, 09:45 AM
  2. Replies: 1
    Last Post: May 15th, 2005, 12:51 AM
  3. New PR3 Features
    By Keith Donald in forum Web Flow
    Replies: 5
    Last Post: Apr 27th, 2005, 02:25 AM
  4. New PR3 Features under consideration
    By Keith Donald in forum Web Flow
    Replies: 3
    Last Post: Apr 25th, 2005, 12:10 AM
  5. Replies: 5
    Last Post: Mar 2nd, 2005, 07:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •