Can we use stub methods for implementing interfaces ? i.e., suppose I get a message that says I must implement ServletRequestAttributeListener and HttpSessionListener – what do I need to do? Can I simply put the method signature, and use dummy values?
Can we use stub methods for implementing interfaces ? i.e., suppose I get a
Share
I understand that you’re in general talking about those
XxxListenerinterfaces in the Servlet API.If you’re not interested in hooking on the event, just do nothing. Leave the method body empty. If necesary, add a comment like
NOOP(no operation) to suppress the IDE “empty body” warning.For other interfaces, it depends on their contract. I’d read their javadocs to be sure.