THIS IS MY CODE, at the end is the nullpointer error i get....hope you can help me....
public class CuartaApp
{
// These fields are read in from the application.properties file. This file
// must be populated with a valid IP address for Avaya Communication
// Manager, as well as a valid extension number and password for the
// application softphone.
private String callServer;
private String extension;
private String password;
// The Device ID for our extension number will be supplied by the
// Communication Manager API. The Connection ID is formulated from the
// Device ID.
private DeviceID id = null;
private ConnectionID connection = null;
// This thread is used to receive a shutdown notification when the
// application is terminated.
private MyShutdownThread shutdownThread;
// These fields will be populated with the handles of the various services,
// which we will get through the ServiceProvider class.
//private ToneDetectionServices toneDetectSvcs;
private AvayaStation station;
private CallRecordingServices recordSvcs;
private VoiceUnitServices voiceSvcs;
private CallInformationServices callInfoSvcs;
// MonitoringServices will be used to add/remove voice unit listener and
// tone detection listener.
private MonitoringServices montSvcs;
// These are the listeners that will be added to listen for events coming
// from VoiceUnitServices, ToneCollectionServices, TerminalServices, and
// PhysicalDeviceServices.
//private MyToneDetectionListener toneDetectListener;
private MyTerminalListener registrationListener;
private MyCallRecordingDeviceListener callRecordListener;
private MyVoiceUnitListener playAndRecordListener;
private MyCallInfoListener callInfoListener;
private GetLinkStatusResponse devuelve;
private GetCallInformationResponse Devuelveotro;
/**
* Creates an instance of the CuartaApp class, bootstraps it, then starts
* the application.
*/
public static void main(String[] args)
{
CuartaApp app = new CuartaApp();
try
{
app.bootstrap();
app.start();
}
catch (CstaException e)
{
System.out.println("Could not start the application");
e.printStackTrace(System.out);
System.exit(0);
}
catch (Exception e)
{
System.out.println("Could not start the application");
e.printStackTrace(System.out);
System.exit(0);
}
}
public void bootstrap() throws CstaException, Exception
{
// Get all of the arguments from the application properties file
ClassLoader cl = CuartaApp.class.getClassLoader();
URL appURL = cl.getResource("tutorial.properties");
Properties appProp = new Properties();
appProp.load(appURL.openStream());
callServer = appProp.getProperty("callserver");
extension = appProp.getProperty("extension");
password = appProp.getProperty("password");
if ((callServer == null) || (extension == null) || (password == null))
{
System.exit(0);
}
// Get a handle to the ServiceProvider class.
ServiceProvider provider = ServiceProvider.getServiceProvider(null);
recordSvcs = CallRecordingServices.getInstance();
voiceSvcs = (VoiceUnitServices) provider.getService(
ch.ecma.csta.voiceunit.VoiceUnitServices.class.getName());
//toneDetectSvcs =
// (ToneDetectionServices) provider.getService(com.avaya.csta
// .tonedetection.ToneDetectionServices.class.getName());
montSvcs = (MonitoringServices) provider.getService(
ch.ecma.csta.monitor.MonitoringServices.class.getName());
//recordSvcs = (CallRecordingServices) provider.getService(
// com.avaya.csta.callrecording.CallRecordingServices.class.getName());
callInfoSvcs = (CallInformationServices)provider.getService(CallInformationServices.class.getName());
System.out.println("Inicia el callinfo service");
// Create new AvayaStation object
station = new AvayaStationImpl();
station.init(callServer, extension, provider);
}
/**
* This method actually starts the app. It must be called after calling
* bootstrap or it will fail.
*
* @throws Exception - if an Exception is generated by one of the calls to
* the services, it is thrown to the caller.
*/
public void start() throws Exception
{
System.out.println(
"Startup using switch="
+ callServer
+ " ext="
+ extension
+ " pw="
+ password);
// Create a thread in whose context our cleanup will occur if the app
// is terminated. The Communication Manager API connector server code
// will clean up if an app goes away unexpectedly, but it's still good
// to clean up.
shutdownThread = new MyShutdownThread();
Runtime.getRuntime().addShutdownHook(shutdownThread);
// Get the device ID from the station class
id = station.getDeviceID();
System.out.println("device id =" + id);
// A connection ID is needed for requests to data services (tone
// detection) and voice unit services (playing and recording files).
// It is formulated from the device ID.
connection = new ConnectionID();
LocalDeviceID lid = new LocalDeviceID();
lid.setStaticID(id);
connection.setDeviceID(lid);
// Add listeners to be notified of events coming from the various
// services.
addListeners();
// Time to register the device. Pass in the password. Shared control
// is set to false for this application. Default media settings (media
// goes to connector server over G.711 codec) are fine, thus the null
// handle for the MediaInfo
station.register(password, true, null);
//Now we enable the recording in order to have any established
//call recorded completely on the registered device
recordingActivation = new Boolean(true);
recordSvcs.enableRecording(id, recordingActivation);
GetCallInformation callRequest = new GetCallInformation();
callRequest.setDevice(id);
callInfoListener.getCallInformation(callRequest);
System.out.println("Llega hasta aqui");
System.out.println("mirar" + Devuelveotro.getStationName());
// That's all we do for now! The main thread is now going to go away,
// and the rest of the action occurs as a result of events coming into
// our listeners. Note that the Communication Manager API client code
// has some persistent threads that keep the application alive. The
// rest of the code executes in the context of these threads.
}
/**
* Creates listener objects for the different services and adds them so the
* app will be informed of events coming from the various services.
*/
private void addListeners() throws CstaException
{
// Add a listener so we can receive events indicating when the phone is
// registered / unregistered.
registrationListener = new MyTerminalListener();
station.addListener(registrationListener);
// Add an AvayaStationListner to receive events indicating phone rings,
// lamp and display updates.
//avayaStationListener = new MyAvayaStationListener();
//station.addListener(avayaStationListener);
// Para recibir eventos que mustren cuando se establece una llamada,
//cuando termina y cuando falla el inicio y la terminacion de
//una grabacion.
callRecordListener = new MyCallRecordingDeviceListener();
recordSvcs.addCallRecordingDeviceListener(id, callRecordListener);
// Add a listener to receive events indicating when announcements are
// done being played and when recordings have completed.
playAndRecordListener = new MyVoiceUnitListener();
montSvcs.addVoiceUnitListener(id, playAndRecordListener);
//para poder obterner la info de la llamada
callInfoListener = new MyCallInfoListener();
callInfoSvcs.addCallInformationListener(callInfoListener);
System.out.println("Inicia el callinfo listener");
// Add a listener to receive events when touch tones are detected.
//toneDetectListener = new MyToneDetectionListener();
//montSvcs.addToneDetectionListener(id, toneDetectListener);
}
/**
* Removes all of the listeners that were added for the various services.
*/
private void removeListeners() throws CstaException
{
//station.removeListener(avayaStationListener);
station.removeListener(registrationListener);
//montSvcs.removeToneDetectionListener(id, toneDetectListener);
recordSvcs.removeCallRecordingDeviceListener(id, callRecordListener);
montSvcs.removeVoiceUnitListener(id, playAndRecordListener);
}
private void cleanup()
{
System.out.println("The application is terminating: clean up.");
// There is a chance that AvayaStation has already cleaned up as a
// result of getting the unregistered event. In this case, the station
// is already unregistered, the device ID has been released, and the
// server should have cleaned up. Don't bother doing anything else.
if (station.getDeviceID() == null)
{
return;
}
try
{
// Make sure no listeners were left around.
removeListeners();
// This method will unregister the station.
station.unregister();
}
catch (Exception e)
{
System.out.println("Could not clean up properly");
e.printStackTrace(System.out);
}
}
private class MyCallInfoListener implements CallInformationServices, CallInformationListener
{
public void addCallInformationListener(CallInformationListener listener)
{System.out.println("Solucionado?");
}
public GetLinkStatusResponse getLinkStatus(GetLinkStatus request)
{
System.out.println("Solucionado?");
return devuelve;
}
public void removeCallInformationListener(CallInformationListener listener)
{
}
public GetCallInformationResponse getCallInformation(GetCallInformation request)
{
return Devuelveotro;
}
public void linkUp(LinkUpEvent upEvent)
{
}
public void linkDown(LinkDownEvent downEvent)
{
}
}
}
I get the following error
java.lang.NullPointerException
at sampleapps.tutorial.CuartaApp.start(CuartaApp.java:252)
at sampleapps.tutorial.CuartaApp.main(CuartaApp.java:123)
because I reduced the code the line numbre does not correspond. But it refers to th followin lines:
System.out.println("mirar" + Devuelveotro.getStationName());
app.start();