Teo Choong Ping
Teo Choong Ping

Reputation: 12808

What is the simplest solution to integrate 2 apps within a Tomcat server?

I'm new to this and is looking at Apache Camel, Spring Integration and even Terracotta.

I'm looking at sharing of common data like user/groups/account/permission and common business data like inventory/product details/etc.

Any example will be really appreciated.

Upvotes: 1

Views: 161

Answers (5)

duffymo
duffymo

Reputation: 308998

I'm looking at sharing of common data like user/groups/account/permission and common business data like inventory/product details/etc.

Common data like users, groups, and permissions belong in a central LDAP or database. These are part of your Spring Security solution, and all apps can share those regardless of whether they're on the same app server or not.

It can be argued that common business data like inventory, product details, etc. should be "owned" by a single service. It's the only one that can modify the data. Others can get access by querying the service, but it's the one that manages CRUD operations on those tables.

If you do this, you keep objects and systems from being coupled at the database level. You're trading looser coupling for increased network latency.

Upvotes: 1

Tobias M
Tobias M

Reputation: 1338

If your new an idea may be to build the classes to handle the common data and just build a separate servlet for each application.

This will at least get you started and more familiar with the technologies.

Upvotes: 0

You should consider creating a full blown EAR instead, if you want this to be web container independent.

As different web applications have different classloaders you cannot just create an object in one web app which is immediately usable by another. Hence you need to have a common classloader which knows about the classes in common, and - to be 100% compliant - these classes may not be in either web apps WEB-INF/lib. This is hard to get right, and the result is fragile.

Therefore consider migrating to a web container which can deploy EAR's instead as they may contain several web applications sharing objects. I believe a good choice for starting would be JBoss.

Upvotes: 1

Thilo
Thilo

Reputation: 262814

How about database-level integration?

Have both applications access the same relational database. Those are built for that kind of task.

To do that, the two applications can use a shared library (of which for the sake of simplicity each one will have a copy in their WEB-INF/lib).

Upvotes: 1

Yuval
Yuval

Reputation: 8087

In theory, every application has its own memory space, but off the top of my head I can think of a number of methods for sharing information between applications.

If the amount of shared information is small, perhaps a direct approach is best. set up a communication channel (web services are a bit of an overkill, but a good example) and have the applications request info from each other.

If there is massive sharing, perhaps the two applications should be reading from the same database or local file. Mind you, This brings up synchronization issues, and gets you into the realm of lockings and blockings. Tread lightly in this realm...

Upvotes: 0

Related Questions