Announcement Announcement Module
Collapse
No announcement yet.
How to outsource data? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to outsource data?

    Hello,

    I am developing a servlet and I use JSP/JSTL as the view components. Those JSPs have to display various types of information (CD info, Location info, biographies, projects,...). All have in common:

    - A unique ID
    - A description (the content to be displayed)
    - A picture

    I don't want the data and images to be managed inside the servlet, but in a separate repository. My idea is that the objects only know about their IDs (e.g. biography_elvis_presley).

    Then the controller class has to connect to the repository (via SQL? Web Service? Whatever?) and fetch the additional info to create a bean, that can be passed to the JSP-view.

    Now my question is how to design such a repository. I have full access to an Apache, Tomcat,... Server that is accessible via www. Is it a good idea to set up a MySQL-Database for that purpose?

    Any other ideas? The architecture should be as easy as possible.

  • #2
    Nobody any idea which kind of repository to choose?

    Comment


    • #3
      It is not exactly clear to me what you're asking, but as we're on the spring forum I'm going to assume that you mean bean ~ POJO and that you're looking for a solution based on Spring and Hibernate.

      My first advice would be: don't think about the database first. You need a repository, fine from your model create a Repository interface for each aggregate root (CarefullyNamedBean). Then implement this repository with a NaiveCarefullyNamedBeanRepository that just returns some hardcoded stuff for you to test with.

      After you've got some screens to show you change the implementation of the repository so that it gets real stuff from the database. Use in memory hsqldb at first. You can unittest almost all your config (except for the DataSource and hibernate properties) before you even think about what database you're going to use.

      When you're all set and you need to install, just let Hibernate generate your schema.

      Through this excercise you will end up with an application that is completely decoupled from the database. The bonus is that you will not need any database to develop or unittest.

      My personal favourite for a database is postgressql if it has to be open source, but it doesn't really matter that much if you keep the data access layer clean. You can always switch if you need to

      Let us know if you find another elegant solution.

      Comment


      • #4
        Thank you for your detailed suggestions. You're right, it's no good idea to think about a database first. But I am not at the beginning with my program. I used hsqldb and hibernate for various issues. But I realized that it somehow gets too messy.

        My servlet will run on several computers and it isn't necessary that each one stores its data seperately. Imagine you had a servlet that should display cd-covers and its running on 100 computers. I don't want each computer to hold a cover-image-database.

        The programm logic should decide which cd to display *then get the cover image (link) from the remote repository by ID*, build a bean and hand it over to the appropriate view.

        Perhaps this is to simple to be a problem for most of you. But I really don't know what is the common approach for such a repository.

        - What technology is the common choice for a simple web-accessible repository from which one should get certain text blocks by ID?

        - What technology would you choose to access this remote repository? Axis Web Services?

        Comment


        • #5
          Would you recommend a JCR repository or a MySQL-DB?

          Comment


          • #6
            I get the point. The architecture you describe clearly asks for a remote repository.

            I haven't got any experience with JCR. JCR looks like a nice solution (if you go for it make sure you've read http://www.infoq.com/articles/spring-modules-jcr), but you might get away with something much simpler, for example a servlet that coughs up the url to the image if you give it an ID. In both cases you can have a mysql under the cover, depends on personal preference mostly.

            This is might be a nice case for Spring-WS I would say, Axis would not my first option.

            BTW this sounds far from trivial. If you're going to work with 100 nodes you're going to have to be very careful with caching and such... performance tuning this one is going to be sweet.

            Let me know if you need some help...

            Comment

            Working...
            X