I'm not sure that what you want to do is possible with a cdrom drive (but I may be wrong). CD drives, as far as I know, don't notify the operating system when the drive has been opened or closed, it's the operating system that has to continually poll the drive to see if anything has happened (on Linux this is what HAL does).
What you want to do is possible in the case of USB storage devices since plugging in a USB device generates a UDEV event that the OS can catch; VectorLinux uses this method to automount pen-drives (see http://code.google.com/p/vl-hot/
Perhaps you may have more luck reading HAL's documentation, it might be possible to create a policy that can do what you need (see here for some examples on creating policies: https://wiki.archlinux.org/index.php/HAL
Hope this helps.