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

  • Home
  • SEARCH
  • 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 7514985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:39:29+00:00 2026-05-30T00:39:29+00:00

We desing our application with base classes and Event Listener approch, thus the base

  • 0

We desing our application with base classes and Event Listener approch, thus the base class and a event listener interface. base class invoke appropriate event listener method after call any operation. Following code shows my design :

import java.util.EventListener;

public interface MyEventListener extends EventListener
{
    public void preOperation();

    public void postOperation();
}

Then I implement this interface as following :

class MyEventListenerImpl implements MyEventListener
{
    @Override
    public void postOperation()
    {
        System.out.println("Do previous operation");
    }

    @Override
    public void preOperation()
    {
        System.out.println("Do post operation");
    }
}

Then I write base class as following :

abstract class Base
{
    private MyEventListener eventListener; /* this member injected */

    public abstract void operation_1();

    public void doOperation_1()
    {
        eventListener.preOperation(); /* call listener before invoking main operation_1 implementation */

        operation_1(); /* call main operation_1 implementation */

        eventListener.postOperation(); /* call listener after invoking main operation_1 implementation */
    }
}

after these works I write my implementation of Base class and implement operation_1 method.
I do this approach by java.util.EventListener marker interface but after design my problem see another class :

  1. Abstract class EventListenerProxy in java.util package.
  2. EventListenerSupport generic class in org.apache.commons.lang3.event package.

I don’t know using these class never. I want know two things:

  1. Your opinions about my design.(good or bad)
  2. best practice for Event Listener approach.(by said class or any third party frameworks)
  • 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-30T00:39:31+00:00Added an answer on May 30, 2026 at 12:39 am

    It’s hard to discuss about a particular design without knowing which problem it’s supposed to solve.

    Anyway, the principal problem with your design is that you can only have one listener. Using EventListenerSupport would allow easily supporting several ones, and would make the add/remove listener methods trivial to implement.

    Another problem is that your listener methods don’t take any event as parameter. This makes it impossible for a single listener to listen to several Base instances, because it can’t use the event to detect the source of the event.

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

Sidebar

Related Questions

Base class is Task. There are several derived classes such as PhoneCall, Fax, Email....
I am required to move some of our application configuration classes to XMLs. The
Our legacy web application heavily uses stored procedures. We have a central interface through
In our application, we allow administrators of an install to design templates for name
A brief preface: I'm in a game design class where our project for the
We have completed 95% of our application. We want to add additional argument mode=1
we're having this big problem with our application. It's a rather large application with
All, We are having problems with data loading in our application. The purpose of
Generally we need to modularize our design.ie., we have to breakup our application logic
Our .NET application controls measurement instruments. The application is installed and many different windows

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.