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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:05:23+00:00 2026-05-11T09:05:23+00:00

I have a queue of uniform message objects with multiple producers and a single

  • 0

I have a queue of uniform message objects with multiple producers and a single consumer. The consumer is publishing the information and needs to be able to grant access based on the data’s origin, so I want the producer send a suitable identifier along with the message. The producers themselves can’t be responsible for the far side access restrictions.

The id should relate to the role of the producer in my application. I want to enforce that all producers have to define one and that a subclassed producer may choose to inherit or redefine it. The producer’s class name would be a good approximation, but the property I want to identify is not really inherent in the class structure, it’s rather something I define.

I could use reflection to find out the class name or maybe an interface name, but this smells of too much overhead. Also, I’m unsure what the appropriate property would be to look for.

As all producers subclass the same abstract parent class, I thought a good way would be to put a constant in there (or in an interface), but then I realised that in Java, a ‘constant’ is really a ‘static final’, which means I can’t override it, so it doesn’t work that way.

How would a more experienced Java programmer do this?

  • 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. 2026-05-11T09:05:24+00:00Added an answer on May 11, 2026 at 9:05 am

    If there’s a ‘type’ that you need to identify, define an interface that forces a class to give you that type, then implement that interface everywhere.

    Example:

    public interface IHasType {    public String getTypeId(); } 

    However, if the list of types is fixed, I would go one step further and make the type an Enum:

    public enum MyType {    TYPE_A, TYPE_B; } 

    And then return this enum instead of a String.

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

Sidebar

Ask A Question

Stats

  • Questions 155k
  • Answers 155k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you write an implementation file (.cpp, .cxx, etc) your… May 12, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer Doctrine is, in my opinion, imperfect for DDD because of… May 12, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer Or there is the simple solution :) Press these keys:… May 12, 2026 at 10:43 am

Related Questions

I have a list/queue of 200 commands that I need to run in a
I have a group of checkboxes that I only want to allow a set
I have a List object being accessed by multiple threads. There is mostly one
I have a simple question, but I'm about 80% sure that the answer to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.