Hello,

i am new java beginner and have some problems when i try to add "ListeningPoint" in mye class.

I got some error massege like this, but can not fix it:

<identifier> expected
[javac]     myListeningPoint = sipStack.createListeningPoint(port, "udp");
[javac]                     ^
[javac] 1 error

can you please help me ??

Here is the class:

package javax.sip;


import javax.sip.address.Router;
import java.util.*;


public interface SipStack {



public SipProvider createSipProvider(ListeningPoint listeningPoint)
throws ObjectInUseException;


public void deleteSipProvider(SipProvider sipProvider)
throws ObjectInUseException;



public Iterator getSipProviders();



public ListeningPoint createListeningPoint(int port, String transport)
throws TransportNotSupportedException, InvalidArgumentException;


ListeningPoint myListeningPoint();
myListeningPoint= sipStack.createListeningPoint(port, "udp");



public void deleteListeningPoint(ListeningPoint listeningPoint)
throws ObjectInUseException;



public Iterator getListeningPoints();


*/
public String getStackName();



*/
public String getIPAddress();



*/
public Router getRouter();



public boolean isRetransmissionFilterActive();


}

Edited 3 Years Ago by happygeek: fixed formatting

Your class is an interface: public interface SipStack
So you can not write code only declarations of methods and variables.
So this: myListeningPoint= sipStack.createListeningPoint(port, "udp"); shouldn't be there.
And by the way: myListeningPoint is declared as a method: ListeningPoint myListeningPoint();
This would be wrong anywhere you write it : myListeningPoint= sipStack.createListeningPoint(port, "udp");

On the other hand this would be correct:

SipStack stack = //somehow get an instant that extends this interface
ListeningPoint lPoint =  stack.myListeningPoint();

I am not sure that I need to use the method here,
But I would like to add some new ListeningPoint in this class. The primary ListeningPoint and secondary ListeningPoint.
How it is possible ?

Your class is an interface: public interface SipStack
So you can not write code only declarations of methods and variables.
So this: myListeningPoint= sipStack.createListeningPoint(port, "udp"); shouldn't be there.
And by the way: myListeningPoint is declared as a method: ListeningPoint myListeningPoint();
This would be wrong anywhere you write it : myListeningPoint= sipStack.createListeningPoint(port, "udp");

On the other hand this would be correct:

SipStack stack = //somehow get an instant that extends this interface
ListeningPoint lPoint =  stack.myListeningPoint();

Are you talking about variables or methods? If variables just declare them like you would any other variable. You have already declared a lot of stuff, is it difficult to add a few more? or perhaps I don't understand your question

I actually need to instantiate two ListeningPoint objects here and use one per interface. What is your idea to get this ?

Interfaces can only contain method signatures and final static fields. They are not the same as a class. You need to write a class that implements the interface if you want to add other properties.

I have a SipStackImpl class that implements the interface: (attached)

But it contains errors, that i can not find solution to.


Interfaces can only contain method signatures and final static fields. They are not the same as a class. You need to write a class that implements the interface if you want to add other properties.

Attachments
package gov.nist.javax.sip;

import java.util.*;
import javax.sip.*;
import javax.sip.address.*;
import javax.sip.message.*;
import gov.nist.javax.sip.stack.*;
import java.lang.reflect.*;
import gov.nist.core.*;
import gov.nist.core.net.NetworkLayer;


/**
 * Implementation of SipStack.
 *
 * The JAIN-SIP stack is initialized by a set of properties (see the JAIN
 * SIP documentation for an explanation of these properties).
 * In addition to these, the following are meaningful properties for 
 * the NIST SIP stack (specify these in the property array when you create
 * the JAIN-SIP statck).:
 *<ul>
 *
 *<li><b>gov.nist.javax.sip.TRACE_LEVEL = integer </b><br/>
 *Currently only 16 and 32 is meaningful. 
 *If this is set to 16 or above, then incoming
 *valid messages are  logged in SERVER_LOG. If you set this to 32 and 
 *specify a DEBUG_LOG then vast amounts of trace information will be dumped
 *in to the specified DEBUG_LOG.  The server log accumulates the signaling
 *trace. 
 *<a href="{@docRoot}/tools/tracesviewer/tracesviewer.html">
 *This can be viewed using the trace viewer tool .</a>
 *Please send us both the server log and debug log 
 * when reporting non-obvious problems.</li>
 *
 *<li><b>gov.nist.javax.sip.SERVER_LOG = fileName </b><br/>
 * Log valid incoming messages here. If this is left null AND the 
 * TRACE_LEVEL is above 16 then the messages are printed to stdout.
 * Otherwise messages are logged in a format that can later be viewed
 * using the trace viewer application which is located in 
 * the tools/tracesviewer directory. 
 *<font color=red> Mail this to us with bug reports.  </font>
 * </li>
 *
 *<li><b>gov.nist.javax.sip.LOG_MESSAGE_CONTENT = true|false </b><br/>
 * Set true if you want to capture content into the log. Default is false.
 * A bad idea to log content if you are using SIP to push a lot of 
 * bytes through TCP.
 *</li>
 *    
 *<li><b>gov.nist.javax.sip.BAD_MESSAGE_LOG = fileName </b><br/>
 *  Messages that do not contain the required headers are dropped.
 *  This file indicates where the bad (unprocessable) messages go. 
 *  Default is null (bad messages are not logged in their own file). </li>
 *
 *    
 *<li><b>gov.nist.javax.sip.DEBUG_LOG = fileName </b><br/>
 *  Where the debug log goes. 
 *	<font color=red> Mail this to us with bug reports.  </font>
 *</li>
 *
 *<li><b>gov.nist.javax.sip.MAX_MESSAGE_SIZE = integer</b> <br/>
 * Maximum size of content that a TCP connection can read. Must be
 * at least 4K. Default is "infinity" -- ie. no limit.
 * This is to prevent DOS attacks launched by writing to a
 * TCP connection until the server chokes.
 *</li>
 *
 *
 *<li><b>gov.nist.javax.sip.MAX_SERVER_TRANSACTIONS = integer</b> <br/>
 *   Max number of open SERVER transactions in the transaction table - incoming
 *  Requests that have the capability to create ServerTransactions will
 *  not be processed if server transaction table exceeds this size
 *  (default value is "infinity"). </li>
 *
 *<li><b>gov.nist.javax.sip.CACHE_SERVER_CONNECTIONS = [true|false] </b> <br/>
 *  Default value is true. Setting this to true makes the Stack close the server socket after
 *  a Server Transaction goes to the TERMINATED state. This allows a server to protectect against 
 *  TCP based Denial of Service attacks launched by clients (ie. initiate hundreds of client gransactions).
 *  If false (default action), the stack will keep the socket open so as to maximize performance at 
 *   the expense of Thread and memory resources - leaving itself open to DOS attacks. 
 *</li>
 *
 *<li><b>gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS = [true|false] </b> <br/>
 *  Default value is true. Setting this to true makes the Stack 
 *  close the server socket aftera Client Transaction goes to the 
 * TERMINATED state. This allows a client release any buffers
 *  threads and socket connections associated with a client 
 *  transaction after the transaction has
 *  terminated at the expense of performance.
 *</li>
 *
 *<li> <b>gov.nist.javax.sip.THREAD_POOL_SIZE = integer </b> <br/>
 *  Concurrency control for number of simultaneous active threads.
 *  If unspecificed, the default is "infinity".
 *  This feature is useful if you are trying to build a container.
 * <ul>
 * <li>
 *  <li> If this is not specified, <b> and the listener is re-entrant</b>,  
 *   each event delivered to the listener is run in the context of a 
 *   new thread. </li>
 *  <li>If this is specified and the listener is re-entrant, 
 *   then the stack will run the listener using a 
 *   thread from the thread pool.  This allows you to manage the 
 *   level of concurrency to a fixed maximum. Threads are pre-allocated
 *   when the stack is instantiated.</li>
 *  <li> If this is specified and the listener is not re-entrant, 
 *   then the stack will use the thread pool thread from this pool to
 *   parse and manage the state machine but will run the listener in
 *   its own thread.
 * </li>
 *</ul>
 *
 *<li> <b>gov.nist.javax.sip.REENTRANT_LISTENER = true|false </b> <br/>
 *  Default is false. Set to true if the listener is re-entrant. 
 * If the listener is re-entrant then the stack manages a thread pool
 * and synchronously calls the listener from the same thread which read the
 * message. Multiple transactions may concurrently receive messages and
 * this will result in multiple threads being active in the listener at
 * the same time. The listener has to be written with this in mind.
 * </li>
 *
 *<li> <b>gov.nist.javax.sip.MAX_CONNECTIONS = integer </b> <br/>
 *   Max number of simultaneous TCP connections handled by stack. 
 *  (Was mis-spelled - Documentation bug fix by Bob Johnson)</li>
 *
 *
 *<li> <b>gov.nist.javax.sip.READ_TIMEOUT = integer </b> <br/>
 * This is relevant for incoming TCP connections to prevent starvation at
 * the server.
 * This defines the timeout in miliseconds between successive reads after the 
 * first byte of a SIP message is read by the stack. All the sip headers
 * must be delivered in this interval and each successive buffer must be
 * of the content  delivered in this interval.
 * Default value is -1  (ie. the stack is wide open to starvation attacks) and
 * the client can be as slow as it wants to be.
 *</li>
 *
 *<li> <b>gov.nist.javax.sip.NETWORK_LAYER = classpath </b> <br/>
 * This is an EXPERIMENTAL property (still under active devlopment).
 * Defines a network layer that allows a client to have control over socket
 * allocations and monitoring of socket activity. A network layer should
 * implement gov.nist.core.net.NetworkLayer. The default implementation simply
 * acts as a wrapper for the standard java.net socket layer. This functionality
 * is still under active development (may be extended to support security and
 * other features).
 *</li>
 *
 * <li> <b> gov.nist.javax.sip.STRIP_ROUTE_HEADER = [ true| false ] </b>
 * If set to true (default behavior), 
 * stack will strip topmpost route header on an incoming request
 * if the route header matches the listening point on which it was received.
 * If set to false, the route header is passed up to the application and it is
 * the application layer's responsibility to strip the route header. 
 *</li>
 *
 * <li> <b> javax.sip.AUTOMATIC_DIALOG_SUPPORT = [ true | false ] </b>
 * <b> This is a planned feature for the next version of the spec </b>
 * if set to true JAIN-SIP provides automatic dialog suport 
 * (this is the default). If set to true (default) the dialog is created
 * by the stack automatically when the request is handled statefully.
 * If set to false, the stack will not create a dialog for the application
 * implicitly. In this case the stack is responsible for creating and 
 * associating the dialog.
 *
 * </li>
 *
 *</ul>
 * 
 * @version JAIN-SIP-1.1 $Revision: 1.40 $ $Date: 2005/04/04 09:29:02 $
 * 
 * @author M. Ranganathan <mranga@nist.gov>  <br/>
 *
 * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
 *
 *
 */
public class SipStackImpl
	extends SIPTransactionStack
	implements javax.sip.SipStack {

	private Hashtable listeningPoints;
	private LinkedList sipProviders;

	private String outboundProxy;
	protected String routerPath;

	protected EventScanner eventScanner;
	// All the methods of the listener must be synchronized for
	// this to work.
	protected boolean reEntrantListener;

	// Flag to indicate whether stack or application will handle
	// removal of topmost route header.
	protected boolean stripRouteHeader;

	// Flag to indicate whether the stack will provide dialog
	// support.
	protected boolean dialogSupport;


	/** Creates a new instance of SipStackImpl.
	*/

	protected SipStackImpl() {
		super();
		NistSipMessageFactoryImpl msgFactory =
			new NistSipMessageFactoryImpl(this);
		super.setMessageFactory(msgFactory);
		this.listeningPoints = new Hashtable();
		this.sipProviders = new LinkedList();
		this.eventScanner = new EventScanner(this);
	}

	/** ReInitialize the stack instance.
	*/
	protected  void reInit() {
		super.reInit();
		this.listeningPoints = new Hashtable();
		this.sipProviders = new LinkedList();
		this.eventScanner = new EventScanner(this);
	}

	public SipStackImpl(Properties configurationProperties)
		throws PeerUnavailableException {
		this();
		String address =
			configurationProperties.getProperty("javax.sip.IP_ADDRESS");
		try {
			/** Retrieve the stack IP address */
			if (address == null)
				throw new PeerUnavailableException("address not specified");
			super.setHostAddress(address);
			/** This is for STUN support  --  Stun overwrites the original adderess*/
			super.setRealHostAddress(address);
		} catch (java.net.UnknownHostException ex) {
			throw new PeerUnavailableException("bad address " + address);
		}

		/** Retrieve the stack name */
		String name =
			configurationProperties.getProperty("javax.sip.STACK_NAME");
		if (name == null)
			throw new PeerUnavailableException("stack name is missing");
		super.setStackName(name);

		/** Retrieve the rou

I actually need to instantiate two ListeningPoint objects here and use one per interface. What is your idea to get this ?

What do you mean use one per interface? The interface is one and you cannot instantiate it

I presume a terminal like SIP Communicator such use JAIN-SIP SIP-stack, with more than
one network interface. If more than one network interface can be used, one of them chosen
as the main/primary interface, while the other will act as backup interface.

I may still need to track interface state in some cases, but I am not sure HOW ?
Can you please help me ?

What do you mean use one per interface? The interface is one and you cannot instantiate it

This article has been dead for over six months. Start a new discussion instead.