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 8314411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:48:38+00:00 2026-06-08T20:48:38+00:00

I managed to write simple program which should simulate passing control in system consisting

  • 0

I managed to write simple program which should simulate passing control in system consisting of three components. But I am not sure if I’ve done it correctly, because logs don’t look like I was expecting.

I couldn’t find mistake. Is it in aspectJ-part or in RMI-part?

RMIServer

public class RMIServer {

    public static void main(String[] args) throws RemoteException,
            MalformedURLException {
        LocateRegistry.createRegistry(1099);
        HelloIF hello = new Hello();
        Naming.rebind("server.Hello", hello);
        System.out.println("Server is ready.");
    }
}

RMIServer2

public class RMIServer2 {

    public static void main(String[] args) throws RemoteException,
            MalformedURLException, NotBoundException, InterruptedException {

            //LocateRegistry.createRegistry(1098);
            LocateRegistry.getRegistry(1099);
        ByeIF bye = new Bye();
        Naming.rebind("server.Bye", bye);
        System.out.println("Server-Client is ready.");

    }

RMIClient

public class RMIClient {
        public static void main(String[] args) throws RemoteException,
                MalformedURLException, NotBoundException, InterruptedException {

            Registry registry = LocateRegistry.getRegistry("localhost");
            ByeIF bye = (ByeIF) registry.lookup("server.Bye");
            System.out.println(bye.farewell(Thread.currentThread().getName()));
        }
}

Hello

public class Hello extends UnicastRemoteObject implements HelloIF {

    public Hello() throws RemoteException {
    }

    public String greeting(String c) throws RemoteException,
            InterruptedException {
        return "Good morning!";
    }
}

Bye

public class Bye extends UnicastRemoteObject implements ByeIF {

    public Bye() throws RemoteException {
    }

    public String farewell(String c) throws RemoteException,
            InterruptedException, NotBoundException {
        Registry registry = LocateRegistry.getRegistry("localhost");
        HelloIF hello = (HelloIF) registry.lookup("server.Hello");
        System.out.println(hello.greeting(Thread.currentThread().getName()));
        return "Bye bye!";
    }

}

And logs look:

[2012-08-03 11:06:18,582] [request1343984778582] [public static void hello.RMIClient.main(java.lang.String[])]
[2012-08-03 11:06:18,738] [request1343984778582] [public java.lang.String hello.Bye.farewell(java.lang.String)]
[2012-08-03 11:06:18,785] [request1343984778582] [public java.lang.String hello.Hello.greeting(java.lang.String)]
[2012-08-03 11:06:18,785] [request1343984778582] [public java.lang.String hello.Hello.greeting(java.lang.String)]
[2012-08-03 11:06:18,847] [request1343984778582] [public static void hello.RMIClient.main(java.lang.String[])]

So one log is missing – Bye.farewell()

I don’t know why aspectJ cannot see when the method ends.

@Aspect
public class ReportingAspect {

    // --------------------------------------LOGGER

    static final Logger logger = Logger.getLogger(ReportingAspect.class);

    // --------------------------------------POINTCUTS

    @Pointcut("execution(public static void hello.RMIClient.main(String[]))")
    public void requestStart() {
    }

    @Pointcut("(execution(String greeting(..)) && args(context)) || "
            + "(execution(String farewell(..)) && args(context))")
    public void RMImethodStart(String context) {
    }

    @Pointcut("execution(String greeting(..)) || "
            + "execution(String farewall(..)) || "
            + "execution(public static void hello.RMIClient.main(String[]))")
    public void general() {
    }

    @Pointcut("execution(public static void hello.RMIServer.main(String[])) || "
            + "execution(public static void hello.RMIServer2.main(String[]))")
    public void setLoggingFile() {
    }

    // --------------------------------------ADVICES

    @Before("requestStart()")
    public void setLoggerAndThreadName(JoinPoint joinPoint) {
        PropertyConfigurator.configure("log4j.properties");
        Thread.currentThread().setName("request" + System.currentTimeMillis());
        report(joinPoint);
    }

    @Before("RMImethodStart(context)")
    public void setThreadName(JoinPoint joinPoint, String context) {
        Thread.currentThread().setName(context);
        report(joinPoint);
    }

    @Before("setLoggingFile()")
    public void setProperties() {
        PropertyConfigurator.configure("log4j.properties");
    }

    @After("general()")
    public void generateReport(JoinPoint joinPoint) {
        report(joinPoint);
    }

    /*//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    @After("execution(public String hello.Bye.farewell(String))")
    public void test(JoinPoint joinPoint)
    {
        report(joinPoint);
    }*/

    // ---------------------------------------REPORT
    void report(JoinPoint jp) {
        logger.error(jp.getSignature().toLongString());
    }
}
  • 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-06-08T20:48:41+00:00Added an answer on June 8, 2026 at 8:48 pm

    If you find a bug that you don’t understand, try to reduce the problem. In your case, how about a few good old System.out.println() in the actual code to see what really happens?

    Also, I don’t see any exception handling. Depending on your version of Java, exceptions in main() might be swallowed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to write a simple function to call unmanaged code from managed code.
I managed to write add program that upon the user click a button, he
So far I have managed to write some code that should print the source
I'm trying to write a simple thread pool program in pthread. However, it seems
// Write a program to check whether or not two arrays are identical in
I have to write a simple chat in C. One program is a server
I'm trying to learn big three in C++.. I managed to do very simple
I'm trying to write a simple Resource Manager for the little hobby game I'm
i managed to write the data to a single column. My req is to
I'm trying to write a managed library in C# that will act as an

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.