I have a queue of single message objects with several producers and one consumer. The consumer publishes the information and should be able to provide access based on the data source, so I want the manufacturer to send the appropriate identifier along with the message. Manufacturers themselves cannot be held responsible for external access restrictions.
The identifier should relate to the role of the producer in my application. I want to ensure that all producers must define one and that a subclass producer can inherit or redefine it. The manufacturer class name will be a good approximation, but the property that I want to identify is not really inherent in the class structure, it is rather something that I define.
I could use reflection to find out the name of the class, or perhaps the name of the interface, but that smells of too much overhead. Also, I'm not sure if I will look for a suitable property.
Like all sub-elements of producers of the same abstract parent class, I thought that a good way would be to place the constant there (or in the interface), but then I realized that in Java the "constant" is really a "static" final, which means that I cannot override it, so it does not work that way.
How could a more experienced Java programmer do this?
source
share