Xbee: How do I retrieve data from a listener?

In the xbee java api, all the examples that retrieve data from an Xbee device using a listener demonstrate how to get the data from the xbee message. But then they just print the data from within the listener. They don’t show how to actually get the data back to your main program. Apparently, you can’t use global variables within a listener. Any help or examples would be appreciated.