Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1078317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:42:20+00:00 2026-05-16T21:42:20+00:00

I have two applications communicating via RMI, a slave server (of which there will

  • 0

I have two applications communicating via RMI, a slave server (of which there will be multiple) and a master server.

Following good abstract design, I’d like to implement the slave in a way that it doesn’t know that when talking to the master, it’s using RMI (so that the two apps can also be run inside the same JVM, for instance):

public static void main(String[] a) {
     Master ms = magicGetTheMasterFromRMI();
     new Slave(ms);
}

...

class Slave {

   public Slave(Master m) {
       m.registerSlave(this); // PROBLEM LINE   
   }

}

Problem: The line marked PROBLEM LINE above doesn’t work, because I cannot simply pass this (the Slave itself is a Remote which Master will talk back to). I have to explicitly do a UnicastRemoteObject.exportObject(this, 0) (or toStub(this) if it’s exported earlier) but that makes the Slave class depend on RMI, breaking the design.

Additionally, registerSlave forces me to catch RemoteException, which also adds RMI dependency.

What would you suggest to solve these issues?

(It also bugs me that these classes must implement Remote, but I guess we can only go so far with abstraction)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:42:20+00:00Added an answer on May 16, 2026 at 9:42 pm

    Well, I’ve done it like this:

    interface Service {
       void doIt();
    }
    
    class ServiceImpl implements Service {
      public void doIt() { ... }
    }
    
    interface RemoteService extends Remote {
      void proxyDoIt() throws RemoteException;
    }
    
    class RemoteServiceHost implements RemoteService {
      public void proxyDoIt() throws RemoteException {
        // serviceImpl is a field, defined in the constructor
        serviceImpl.doIt();
      }
    }
    
    class RemoteServiceClient implements Service {
      public void doIt() {
       try {
        // remoteService is a field, defined in the constructor
        remoteService.proxyDoIt();
       } catch (RemoteException e) {
        throw new RuntimeException(e);
       }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two applications: c++ service and a RoR web server (they are both
I have two desktop applications. After closing the first application, the first application will
I have two WAR applications and the mode of communication between them is via
Let's say you have a project that will involve two web applications (that will
I have a setup in which some applications communicate with each other via Tibco
I have two .net applications communicating with sockets on port 5672 and everthing works
We have a Service Broker application where we're communicating between two SQL Server instances
I have two applications Web Socket and Web Service created in .Net/Web Form and
I have two applications in my project 'test' the applications are one.mxml and two.mxml
public enum ObjectType { Country=0, Region=1, Province=2, City=3, Hotel=4 } I have two applications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.