Package org.cipango.servlet

Examples of org.cipango.servlet.SipServletHolder


   
    private void initListeners(SipAppContext context)
    {
      for (String className : _listeners)
    {
      SipServletHolder holder = getServlet(context, className);
       
      // Check listener has not been already added.
      boolean found = false;
      if (context.getEventListeners() != null)
      {
        for (EventListener listener : context.getEventListeners())
        {
          if (listener.getClass().getName().equals(className))
          {
            Log.debug("Found multiple listener declaration " +  className);
            if (holder != null)
              holder.setServlet((Servlet) listener);
            found = true;
            break;
          }
        }
      }
     
      if (found)
        continue;
     
      try
      {
        @SuppressWarnings("rawtypes")
        Class listenerClass = context.loadClass(className);
        @SuppressWarnings("unchecked")
        EventListener listener = newListenerInstance(context, listenerClass);
       
        if (holder != null)
          holder.setServlet((Servlet) listener);
         
        context.addEventListener(listener);
      }
      catch (Exception e)
      {
View Full Code Here


    _context = new SipAppContext();
    _context.setConfigurationClasses(new String[0]);
    _context.setContextPath("/");
    _context.setName(SipClient.class.getName());
   
    SipServletHolder holder = new SipServletHolder();
    holder.setServlet(new ClientServlet());
    holder.setName(ClientServlet.class.getName());
   
    _context.getSipServletHandler().addSipServlet(holder);
    _context.getSipServletHandler().setMainServletName(ClientServlet.class.getName());
   
    handler.addHandler(_context);
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())
View Full Code Here

    public void visitServlet(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
    {
      String servletName = node.getString("servlet-name", false, true);
    String servletClass = node.getString("servlet-class", false, true);
    // FIXME allow deploy with prefix: javaee:servlet-name
    SipServletHolder holder = new SipServletHolder();
    holder.setName(servletName);
    holder.setClassName(servletClass);
   
    Iterator params = node.iterator("init-param");
   
    while (params.hasNext())
    {
      XmlParser.Node param = (XmlParser.Node) params.next();
      String pName = param.getString("param-name", false, true);
      String pValue = param.getString("param-value", false, true);
      holder.setInitParameter(pName, pValue);
    }
   
    XmlParser.Node startup = node.get("load-on-startup");
    if (startup != null)
    {
      String s = startup.toString(false, true);
      int order = 0;
      if (s != null && s.trim().length() > 0)
      {
        try
        {
          order = Integer.parseInt(s);
        }
        catch (NumberFormatException e)
        {
          Log.warn("Cannot parse load-on-startup " + s);
        }
      }
      holder.setInitOrder(order);
    }
   
        // FIXME use same instance for listener and servlet
    ((SipAppContext) context).addSipServlet(holder);
    }
View Full Code Here

      @Override
    public RequestDispatcher getNamedDispatcher(String name)
        {
            if (_servletHandler != null)
            {
                SipServletHolder holder = ((SipServletHandler) _servletHandler).getHolder(name);
                if (holder != null)
                  return new SipDispatcher(holder);
            }
            return super.getNamedDispatcher(name);
        }
View Full Code Here

  public void setHandler(String name) throws ServletException
  {
    checkValid();
   
    SipAppContext context = _appSession.getContext();
    SipServletHolder handler = context.getSipServletHandler().getHolder(name);
   
    if (handler == null)
      throw new ServletException("No handler named " + name);
   
    setHandler(handler);
View Full Code Here

        }
       
        SipServlet annotation = (SipServlet) clazz.getAnnotation(SipServlet.class);
       
       
        SipServletHolder holder = new SipServletHolder();
       
        SipAppContext context = (SipAppContext) _context;
   
        if (!Util.isEmpty(annotation.applicationName()))
        {
         
          if (context.getName() != null && !context.getName().equals(annotation.applicationName()))
          throw new IllegalStateException("App-name in sip.xml: " + context.getName()
              + " does not match with SipApplication annotation: " + annotation.applicationName());
          context.getSipMetaData().setAppName(annotation.applicationName());
        }
       
        if (annotation.name() != null && !"".equals(annotation.name()))
          holder.setName(annotation.name());
        else
          holder.setName(_className.substring(_className.lastIndexOf('.') + 1));
       
        holder.setInitOrder(annotation.loadOnStartup());
        holder.setDisplayName(annotation.description());
        holder.setClassName(_className);
       
        context.addSipServlet(holder);
    }
View Full Code Here

TOP

Related Classes of org.cipango.servlet.SipServletHolder

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.