• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing two applications from a singleton class  RSS feed

 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a requirement where a singleton class will act as a server and get requests. Based on the requests, it will call either Application1 or Application2. Now both these applications are running independently. Is there a way for me to access the classes of these applications from the server class? When I was thinking of implementing this server calls, I forgot that these are seperate applications. Now I want to rectify the situation by going for an alternative solution to redirect the requests to one of these to application by some means. Somehow I think i will have to use remote communication like RMI , JMS or similar mechanism to interact between these applications.
Is there any alternative solution?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s ravi chandran wrote:I have a requirement where a singleton class will act as a server and get requests. Based on the requests, it will call either Application1 or Application2. Now both these applications are running independently.

Erm, this sounds to me like a "mechanical" question rather than a design one.
First: Why does your "server" need to be a singleton?

Is there a way for me to access the classes of these applications from the server class?

Why would you want to? It seems like an odd way to do things to me.

Is there any alternative solution?

Well, presumably, an Application already knows its own "server", otherwise it wouldn't be able to call it; so why not just have it include its own instance in a server call?
That way, the server will always know which Application to "respond" to.

But I definitely wouldn't be creating singletons unless you absolutely have to.

Winston
 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for incomplete information. The singleton class itself is not the server. We will be getting requests through some mechanism ( not decided on that one yet ).This singleton class will abstract out the two applications Application1 and Application2. Now whatever communication mechanism I will have to use, I will be calling the methods of this singleton class, which in turn should redirect the call to Application1 or Application2 based on one of the request parameters.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s ravi chandran wrote:The singleton class itself is not the server. ... This singleton class will abstract out the two applications Application1 and Application2. Now whatever communication mechanism I will have to use, I will be calling the methods of this singleton class, which in turn should redirect the call to Application1 or Application2 based on one of the request parameters.

OK, so this class is acting as a "forwarder" to one of two Applications - presumably based on the same superclass or interface, and also presumably both loaded or "active" - and it "chooses" which one to forward to based on some parameter passed to it as part of each call.

I'm still not quite sure why this class needs to be a singleton though.

It also strikes me as a mechanical solution to a problem that you haven't really described fully.
Why do you need to do this? If we knew a bit more about the background, we might be able to suggest some alternatives.

HIH

Winston
 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
s ravi chandran wrote:The singleton class itself is not the server. ... This singleton class will abstract out the two applications Application1 and Application2. Now whatever communication mechanism I will have to use, I will be calling the methods of this singleton class, which in turn should redirect the call to Application1 or Application2 based on one of the request parameters.

OK, so this class is acting as a "forwarder" to one of two Applications - presumably based on the same superclass or interface, and also presumably both loaded or "active" - and it "chooses" which one to forward to based on some parameter passed to it as part of each call.

I'm still not quite sure why this class needs to be a singleton though.

It also strikes me as a mechanical solution to a problem that you haven't really described fully.
Why do you need to do this? If we knew a bit more about the background, we might be able to suggest some alternatives.

HIH

Winston


The problem is this: I have two applications which provide some service, they handle data processing independently. Logical workflow is similar but internally they work on different type of data. Now I am trying to create a service which I can provide to client user to execute commands irrespective of application type. From the command I will identify the application and send appropriate response to the client.

Initial idea was to share this class to communicate, later I remembered these applications are seperate processes. Might not work that way. Will make it a normal pojo.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!