There are extremes depending on what kind of phone system your client has in place and what you want to do. If it is just a single line system, with no internal switching, i.e. no other handsets to answer the calls, then that's pretty easy. On the other extreme, if it is a call center with hundreds of incoming lines and people answewring them, you'd need a sophisticated call routing system called an ACU that includes the switching gear and would have an ANI output.
If it is somewhere in between, you'll have to read between the lines. You might find a software based ACU that does what you want. There has been a lot of development in that area in the past few years, especially in VOIP.
Anyway, ithe simplest case, if you only wanted to read the ANI off one line, you could just use a "caller ID box" with a serial port rather than a display. You could then write a bean that connects to the serial port and reads the the ANI info as calls come in. Then you need a listener to respond to the input and a parser to make sense of the ANI.
There is a site called callerid.com that might help. Also, you might want to take a look at this java listener package they offer (including source):
http://www.callerid.com/downloads/Whozz ... r_Java.zip