Package org.cipango.sipapp

Examples of org.cipango.sipapp.SipAppContext


  //TODO init default context
 
  public void handle(DiameterMessage message) throws IOException
  {
    DiameterListener[] listeners = null;
    SipAppContext context = null;
    if (message instanceof DiameterAnswer)
      context = ((DiameterAnswer) message).getRequest().getContext();
   
    if (context == null)
    {
      AppSessionIf appSession = (AppSessionIf) message.getApplicationSession();
      if (appSession != null)
        context = appSession.getAppSession().getContext();
    }
   
    if (context == null)
      context = _defaultContext;
   
    if (context != null)
    {
      DiameterAppContext ctx = _diameterListeners.get(context.getContextPath());
      if (ctx != null)
        listeners = ctx.getDiameterListeners();
    }

    if (listeners != null && listeners.length != 0)
      context.fire(listeners, _handleMsg, message);
    else
      Log.warn("No diameter listeners for context {} to handle message {}",
          context == null ? "" : context.getName(), message)
  }
View Full Code Here


  }
 
  public void fireNoAnswerReceived(DiameterRequest request, long timeout)
  {
    DiameterErrorListener[] listeners = null;
    SipAppContext context = null;
    AppSessionIf appSession = (AppSessionIf) request.getApplicationSession();
    if (appSession != null)
      context = appSession.getAppSession().getContext();
   
    if (context != null)
    {
      DiameterAppContext ctx = _diameterListeners.get(context.getContextPath());
      if (ctx != null)
        listeners = ctx.getErrorListeners();
    }
   
    if (listeners != null && listeners.length != 0)
      context.fire(listeners, _noAnswerReceived, new DiameterErrorEvent(request, timeout));   
  }
View Full Code Here

    _server.setApplicationRouter(new SipClientApplicationRouter());
   
    SipContextHandlerCollection handler = new SipContextHandlerCollection();
    _server.setHandler(handler);
   
    _context = new SipAppContext();
    _context.setConfigurationClasses(new String[0]);
    _context.setContextPath("/");
    _context.setName(SipClient.class.getName());
   
    SipServletHolder holder = new SipServletHolder();
View Full Code Here

  private SipApplicationKeyAnnotationHandler _handler;

  @Before
  public void setUp() throws Exception
  {
    _context = new SipAppContext();
    _parser = new AnnotationParser();
    _handler = new SipApplicationKeyAnnotationHandler(_context);
        _parser.registerAnnotationHandler("javax.servlet.sip.annotation.SipApplicationKey",
            _handler);
  }
View Full Code Here

  private Decorator _decorator;

  @Before
  public void setUp() throws Exception
  {
    _context = new SipAppContext();
    _injections = new InjectionCollection();
     _context.setAttribute(InjectionCollection.INJECTION_COLLECTION, _injections);
    _decorator = new AnnotationDecorator(_context);
  }
View Full Code Here

  private AnnotationParser _parser;

  @Before
  public void setUp() throws Exception
  {
    _sac = new SipAppContext();
    _parser = new AnnotationParser();
        _parser.registerAnnotationHandler("javax.servlet.sip.annotation.SipServlet",
            new SipServletAnnotationHandler(_sac));
  }
View Full Code Here

        {
            InitialContext ic = new InitialContext();

            Server server = new Server();

            SipAppContext context = new SipAppContext();
            context.setServer(server);
            context.getSipMetaData().setAppName("myApp");
            context.setClassLoader(new WebAppClassLoader(Thread.currentThread().getContextClassLoader(), context));
            context.setOverrideSipDescriptors(Arrays.asList(getClass().getResource("/sip.xml").toString()));
            context.setServletHandler(new SipServletHandler());
           
            Thread.currentThread().setContextClassLoader(context.getClassLoader());
           
      PlusConfiguration plusConfiguration = new PlusConfiguration();
      EnvConfiguration envConfiguration = new EnvConfiguration();
      envConfiguration.setJettyEnvXml(getClass().getResource("/jetty-env.xml"));

      // Need to add a listener or a servlet to ensure that SipFactory is set in JNDI
      context.getSipMetaData().addListener("org.cipango.plus.sipapp.Listener");
     
      context.setConfigurations(new Configuration[] {envConfiguration, plusConfiguration, new SipXmlConfiguration()});
      context.preConfigure();
      context.configure();
      context.postConfigure();   
      context.getSipMetaData().resolve(context);
     

       Object lookup = ic.lookup("java:comp/env/resource/sample");
       Assert.assertNotNull(lookup);
       Assert.assertEquals("1234", lookup);
      
       Assert.assertEquals(context.getSipFactory(), ic.lookup("java:comp/env/sip/myApp/SipFactory"));
       Assert.assertEquals(context.getTimerService(), ic.lookup("java:comp/env/sip/myApp/TimerService"));
       Assert.assertEquals(context.getSipSessionsUtil(), ic.lookup("java:comp/env/sip/myApp/SipSessionsUtil"));
        }
        finally
        {
            Thread.currentThread().setContextClassLoader(old_loader);
        }
View Full Code Here

  {
    Session session = null;
   
    if (request.isInitial())
    {
      SipAppContext appContext = (SipAppContext) request.getHandlerAttribute(ID.CONTEXT_ATTRIBUTE);
      SipServletHolder handler = ((SipServletHandler) appContext.getServletHandler()).findHolder(request);
 
      if (handler == null)
      {
        Log.debug("SIP application {} has no matching servlet for {}", appContext.getName(), request.getMethod());
        if (!request.isAck())
        {           
          SipResponse response = (SipResponse) request.createResponse(SipServletResponse.SC_NOT_FOUND);
          response.to().setParameter(SipParams.TAG, ID.newTag());
          ((ServerTransaction) request.getTransaction()).send(response);
        }
        return;
      }
     
      AppSession appSession;
     
      String key = (String) request.getHandlerAttribute(ID.SESSION_KEY_ATTRIBUTE);
     
      if (key != null)
      {
        String id = ID.getIdFromKey(appContext.getName(), key);
        appSession = request.getCallSession().getAppSession(id);
        if (appSession == null)
          appSession = request.getCallSession().createAppSession(appContext, id);
      }
      else
View Full Code Here

      if (isInitial(request))
          {
        request.setInitial(true);
       
        SipApplicationRouterInfo routerInfo = null;
        SipAppContext appContext = null;
       
        try
        {
          if (route != null)
          {
            SipURI uri = (SipURI) route.getURI();
            if (RouterInfoUtil.ROUTER_INFO.equals(uri.getUser()))
            {
              routerInfo = RouterInfoUtil.decode(uri);
              route = popLocalRoute(request);
            }
            if (route != null)
              request.setPoppedRoute(route);
          }
         
          if (routerInfo == null)
          {
            routerInfo = ((Server) getServer()).getApplicationRouter().getNextApplication(
              request, null, SipApplicationRoutingDirective.NEW, null, null);
          }
        }
        catch (Throwable t)
        {
          if (!request.isAck())
          {
            SipResponse response = new SipResponse(
                request,
                SipServletResponse.SC_SERVER_INTERNAL_ERROR,
                "Application router error: " + t.getMessage());
            ExceptionUtil.fillStackTrace(response, t);
            getConnectorManager().sendResponse(response);
          }
          return;
        }
       
        if (routerInfo != null && routerInfo.getNextApplicationName() != null)
        {
          boolean handle = handlingRoute(request, routerInfo);
          if (handle)
            return;
         
          request.setStateInfo(routerInfo.getStateInfo());
          request.setRegion(routerInfo.getRoutingRegion());
         
          String s = routerInfo.getSubscriberURI();
          if (s != null)
          {
            try
            {
              request.setSubscriberURI(URIFactory.parseURI(s));
            }
            catch (ServletParseException e)
            {
              Log.debug(e);
            }
          }
         
          String applicationName = routerInfo.getNextApplicationName();
          appContext = (SipAppContext) getContext(applicationName);
                   
          Method method = appContext == null ? null : appContext.getSipApplicationKeyMethod();
          if (method != null)
          {
            try
            {
              String sessionKey = (String) method.invoke(null, request);
View Full Code Here

      {
        String sessionKey = (String) request.getHandlerAttribute(ID.SESSION_KEY_ATTRIBUTE);
     
        if (sessionKey != null)
        {
          SipAppContext context = (SipAppContext) request.getHandlerAttribute(ID.CONTEXT_ATTRIBUTE);
          return ID.getIdFromKey(context.getName(), sessionKey);
        }
      }
      else
      {   
        String appSessionId = request.getParameter(ID.APP_SESSION_ID_PARAMETER);
View Full Code Here

TOP

Related Classes of org.cipango.sipapp.SipAppContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.