/*
* Created on Nov 16, 2004
*
* Copyright 2005 CafeSip.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.cafesip.jiplet;
import javax.sip.ServerTransaction;
import javax.sip.TimeoutEvent;
import org.cafesip.jiplet.sip.SipCommunicator;
/**
* This class conatins methods that is used by a jiplet to retrieve information about a timeout event.
* When there is a time-out receiving response from a SIP UAC, the container sends the timeout
* event notification by calling the jilet's callback method Jiplet.processTimeout(). This object is passed
* as a parameter to the callback method.
*
* @author Amit Chatterjee
*
*/
public class JipletTimeout extends JipletEvent
{
private TimeoutEvent timeoutEvent;
private JipletTransaction transaction;
private Jiplet jiplet;
/**
* A constructor for this class.
*
*
*/
protected JipletTimeout()
{
}
/**
* @return Returns the timeoutEvent.
*/
public TimeoutEvent getTimeoutEvent()
{
return timeoutEvent;
}
/**
* @param timeoutEvent The timeoutEvent to set.
*/
protected void setTimeoutEvent(TimeoutEvent timeoutEvent)
{
this.timeoutEvent = timeoutEvent;
}
/**
* Get the session object associated with this event. A session identifies the SIP endpoint (UAC).
* Session-scope variables are supported similar to servlets and this object is used for storing
* session-scope variables.
*
* @param create
* create the session object if it does not exist.
*
* @return the session object. Null if the create parameter is false and the session object does not
* exist.
*/
public JipletSession getSession(boolean create)
{
ServerTransaction trans = timeoutEvent.getServerTransaction();
if (trans == null)
{
return null;
}
return super.getSession(trans.getRequest(), create);
}
/**
* @return Returns the transaction.
*/
public JipletTransaction getTransaction()
{
return transaction;
}
/**
* @param transaction The transaction to set.
*/
protected void setTransaction(JipletTransaction transaction)
{
this.transaction = transaction;
}
/**
* @return Returns the jiplet.
*/
public Jiplet getJiplet()
{
return jiplet;
}
/**
* @param jiplet The jiplet to set.
*/
protected void setJiplet(Jiplet jiplet)
{
this.jiplet = jiplet;
}
/**
* This method returns a proxy object which can be used to proxy SIP requests, responses,
* handle proxy timeouts as well as other SIP-related operations.
* @return
*/
public SipCommunicator getSipCommunicator()
{
return new SipCommunicator(jiplet, timeoutEvent );
}
}