2

I want to develop a SaaS chat that users will be able to embed on their website and also there will be a desktop chat client. Something similar to Live Chat. The problem is that I've never developed server or database programs. Also I'm new to Java but have some experience in desktop C# programming (developed some gui apps). In fact, I'm a student and don't have that much experience.

I'm trying to design a good scalable architecture for our server but after a few days of googling and reading wikipedia I feel overwhelmed with such amount of information. Server needs to be simple since it does not contain any presentation code but it has to be very fast because I'm expecting high traffic if service becomes popular. For now I've choosed most of technologies I'll be using. Here's my version of server architecture:

My current architecture

Now the biggest question is how to design this big 'Jetty' piece that contains business logic. I've already learned that I need to use MVP pattern. But there's still some major problems:

  1. How to properly work with database? Make static DatabaseManager class that can load and save objects to database? Or make special static SaveToDb and LoadFromDb methods on classes? I think there must be an already developed framework for such things (it must be very common task for servers)
  2. How to design event system? How to correctly notify all clients in 'chat room' that they have new message? I can't trivially subscribe all clients to chat room's NewMessage event since most clients are in database, not in memory.
  3. It will be great help if you post some simplified design of main classes: Message, User and Chat room. Where message is sent from user to chat room and chat room is a collection of subscribed users. This will be kind of answer to previous two questions.

It will be very nice if you point me at appropriate technologies or design patterns.

Poma
  • 8,174
  • 18
  • 82
  • 144
  • this is a well written `send me teh codez` with pictures ... –  Jun 27 '11 at 18:43
  • Nope. I'm asking about patterns & technologies that many other people use to design similar things. I cant belive that every website on java uses it's own self-developed database framework. Answer to 3-rd question will be of great help, but it's enough to just answer to first two. – Poma Jun 27 '11 at 18:50
  • are seriously suggesting you didn't find any references to *Hibernate* on Google? If so you need to tackle a much much much smaller scale project to begin with. –  Jun 27 '11 at 18:59
  • Yes, and also I found JPA, TopLink, Ojb, Apache Cayenne, iBATIS and JDBC. And all of them have lots of material to read. That's pretty much and I didn't read info about Hibernate yet. – Poma Jun 27 '11 at 19:10
  • 1
    `Java == lots of material to read and comprehend`, unfortuntately that is the case with all the frameworks for Java, there is no quick and easy solution, and you won't get one here either, this is the world of Java, get used to it. :-) –  Jun 27 '11 at 19:11

1 Answers1

2

What you're missing is the concept of the ORM (Object Relational Mapper). Look up what an ORM is, and how it can help you solve your problem of business logic within your Jetty layer. As mentioned in the comments, Hibernate is a great ORM; there are many ORMs out there. Do some research on what an ORM can do for you; it's the part of the puzzle you're missing, I believe.

Paul Sonier
  • 38,903
  • 3
  • 77
  • 117
  • Thank you. I've already found that and now I know how save load objects from database. But the question is where is the appropriate place for this load and save methods? What are best practices? Place them all in singleton `DbManager` or spread accross all classes? Or maybe do some kind of interface? – Poma Jun 27 '11 at 20:44