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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:58:32+00:00 2026-05-16T08:58:32+00:00

I want to extend a base class in apache commons email, the base class

  • 0

I want to extend a base class in apache commons email, the base class is Email. I simply want to add some throttling to the .send() method

3 other classes extend Email: HtmlEmail, SimpleEmail, and MultiPartEmail

There is no factory method for creating these 3 derived classes.

Is there a best way that I can extend this one method from the base Email class? All I can think of is to extend the 3 derived classes, override .send() in each, and have each of them call a common static method to accomplish the .send() throttling functionality.

  • 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-16T08:58:33+00:00Added an answer on May 16, 2026 at 8:58 am

    It looks like you can use the decorator pattern and write e.g. a ThrottledEmail. It simply decorates another instance of Email (it can be ANY Email subclass) and it can @Override the send method to enforce some throttling. All other methods are simply delegated to the underlying Email instance.

    This is similar to how a java.io.BufferedReader works, for example. It can decorate any Reader to give it a buffering feature. Other examples include java.util.Collections that provides utility methods such as Collection<T> synchronizedCollection(Collection<T>) which wraps ANY Collection<T> and decorates it with synchronization features.

    Unless the base class is clearly documented to facilitate subclasses to @Override certain methods, you should generally favor composition (has-a) over inheritance (is-a) relationship.

    See also

    • Effective Java 2nd Edition, Item 16: Favor composition over inheritance
    • Effective Java 2nd Edition, Item 17: Design and document for inheritance, or else prohibit it

    Related questions

    • when do we need Decorator Pattern?
    • Prefer composition over inheritance?
    • Examples of GoF Design Patterns
    • Guava ForwardingList usage example
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class with several derived classes that extend it. I want
I want to create an abstract base class for all paramter-type classes to inherit
I want to add a bool variable and property to the base Entity class
I want to extend RuntimeException to create this specific exception: class CompileLinkException extends RuntimeException
I want to extend Ion Auth to only allow certain email addresses to register.
I want to extend the IEnumerable class but only for types that can be
I have a class PlaylistTrack that I want to extend class Song. When I
Folks I have a sealed class as follows. I want to extend this sealed
I have several queues that all extend a Queue class. I want to do
I have a .NET window Service which extend a custom base class, this serves

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.