Hi, I have a class A that has a series of handlers e.g. public void handleEv1(),public void handleEv2() etc. When an event occurs, another thread in class B, calls the correspondent handler from class A (class B has a reference to class A kind of observer-observable). In the handling of the event in the corresponding method of class A, A eventually raises an event to an eventListener (class C which is not created by me). My question is the following: is there a pattern I can use to "hide" the handling methods of class A from the classes that act as eventListeners (not implemented by me), and be "visible/accesible" only to class B (which I implement)?
I am editing my original question. I have class Csystem that has a lot of methods and the handlers I am talking about
public class Csystem()
{
private AListener listener;//implements an event listener (the class C in my question)
//some methods here
public void handleEventIncoming(Event e){
//Do some logic here
listener.raiseEvent(e);
}
public void handleEventOutgoing(Event e); etc
}
CSystem is a class that is essentially an interface for other developers of other components to my code. Some other developer will write his own version of class AListener (class A) and use Csystem in his code. Whenever an event occurs somewhere (e.g. a message in the network arrived) class B will pass the event to the event handlers of CSystem
public class Dispatch{
//This is class B
private CSystem s;
private void event_occured(Event e)
{
s.handleEventIncoming(e);
}
}
} My problem is that both class Dispatch (implemented by me) and class AListener "see" the same interface of CSystem. I would like the developers who implement the AListener to see a different view of CSystem and "see" and be able to use only methods that are public. I don't think that it is a good idea to see methods someone actually can not use (handlers are meaningful to be used only by dispatcher) Is there a pattern to achieve this?
Thank you!