Package org.jvnet.glassfish.comms.deployment.backend

Examples of org.jvnet.glassfish.comms.deployment.backend.SipApplication


    }
   
    public void generatePolicy(ArchiveDescriptor desc) throws Exception {
        SipBundleDescriptor sipDesc = (org.jvnet.glassfish.comms.deployment.backend.SipBundleDescriptor) desc;

        SipApplication sipApplication = (SipApplication) sipDesc.getSipApplication();

        SipSecurityManager manager = SipSecurityManager.createManager(sipDesc, true);
        String pContextId = manager.getContextID();

        if (!manager.inService()) {
View Full Code Here


      * will be added to the listener list.
      *
      * @throws DeploymentException
      */
     private void postProcessListenerAnnotations() throws DeploymentException {
         SipApplication sipApplication = (SipApplication) sbd.getSipApplication();
         Collection<SipListener> listeners = sipApplication.getAnnotatedListeners();
         ApplicationMatcher matcher = new ApplicationMatcher(sipApplication);
         for (SipListener listener : listeners) {
             /// XXX: Commenting out for now.
             /*if (matcher.match(listener.getPackageName(),
                         listener.getApplicationName())) { */
                 sipApplication.addListener(listener.getListenerClass());
            
         }
     }
View Full Code Here

      *
      * @throws DeploymentException
      */
     private void postProcessSipApplicationKeyAnnotations()
         throws DeploymentException {
         SipApplication sipApplication = (SipApplication) sbd.getSipApplication();
         /**
          * Fetch the candidates.
          */
         Collection<SipApplicationKey> sipApplicationKeyAnnotationCandidates = sipApplication.getAnnotatedSipApplicationKeys();
         ApplicationMatcher matcher = new ApplicationMatcher(sipApplication);
         /**
          * Create temporary object that stores all application name matching such
          */
         ArrayList<SipApplicationKey> matchingSipApplicationKeyAnnotations = new ArrayList<SipApplicationKey>();
         /**
          * Match.
          */
         for (SipApplicationKey listener : sipApplicationKeyAnnotationCandidates) {
             /* if (matcher.match(listener.getPackageName(),
                         listener.getApplicationName())) { */
                 matchingSipApplicationKeyAnnotations.add(listener);
            /* } */
         }
         /**
          * There may be at most one matching @SipApplicationKey
          */
        
         if (matchingSipApplicationKeyAnnotations.size() > 1) {
             // Several sipApplicationKey methods
             String errMsg = newLocalStrings.getString(
                        "enterprise.deployment.backend.sip.duplicatesak.found",
                           sipApplication.getModuleID());
             logger.log(Level.SEVERE, errMsg );
             String exMsg = newLocalStrings.getString(
                        "enterprise.deployment.backend.sip.cannot.have.dupsak");
             throw new DeploymentException(exMsg);
         }
        
         if (matchingSipApplicationKeyAnnotations.size() == 1) {
             sipApplication.setSipApplicationKey(matchingSipApplicationKeyAnnotations.get(
                     0).getApplicationKeyMethod());
         }
     }
View Full Code Here

        // 1. If only one annotated SipServlet exists, then the SipApplication
        // annotation is optional.
        // Otherwise a logging error

        SipApplication sipApplication = (SipApplication) sbd
                .getSipApplication();
       
        String ApplicationName = sipApplication.getAppName();
        String mainServletName = sipApplication.getMainservletName();

        Map<String, Servlet> annotatedServlets = sipApplication.getAnnotatedServlets();

        if (annotatedServlets == null || annotatedServlets.isEmpty()) {
            Extension.getInstance().processAnnotations(sipApplication);
        }

        // Find the number of annotated servlets
        int noAnnotatedServlets = annotatedServlets.size();

        // Find the number of servlets defined in the DD.
        int declarativeDefinedServlets = sipApplication.getServlets().size();

        // If multiple annotated servlets exists, then a main servlet has to be
        // defined in the SipApplication annotation.
        // If a servlet-mapping mechanism is used, then we do not need the
        // main-servlet

        if (mainServletName == null &&
                noAnnotatedServlets > 1 &&
                    sipApplication.getServletMappings() == null) {
            logger.log(Level.SEVERE,
                            "No main servlet defined in a SAR archive " +
                            "with multiple annotated servlets");
            throw new DeploymentException(
                    "No main servlet defined in a SAR archive " +
                    "with multiple annotated servlets");
        }
       
        if ( mainServletName != null ) {
            ExistsOperand existsOperand = new ExistsOperand();
            existsOperand.setVariable("request.method");
            Pattern pattern = new Pattern();
            pattern.addCondition(existsOperand);

            ServletMapping servletMapping = new ServletMapping();
            servletMapping.setServletName(mainServletName);
            servletMapping.setPattern(pattern);
           
            // applicable if main servlet is annotated
            Servlet servlet = annotatedServlets.remove(mainServletName);
           
            if ( servlet != null ) {
              sipApplication.addServlet(servlet);
            }
           
            sipApplication.addServletMapping(servletMapping);
        }
       

        for (String servletName : annotatedServlets.keySet()) {
            Servlet servlet = annotatedServlets.get(servletName);

            // Check that the servlet belongs to the same application, by bening
            // defined in same package

            // Check that this servlet name is not defined in sip.xml
            // then ignore it.
            Map<String, Servlet> servlets = sipApplication.getServlets();

            // Servlets defined in sip.xml overrides annotations
            if (servlets.get(servletName) != null) {
                // Servlet specified in sip.xml
                if (logger.isLoggable(Level.INFO)) {
                    logger.log(Level.INFO,
                        "Annotated servlet found with same name " +
                        "as servlet defined in sip.xml name = " + servletName);
                    logger.log(Level.INFO, "Annotated servlet discarded");
                }

                continue;
            }
           
            // check if the same servlet class has been defined twice using annotations and sip.xml
            boolean isDuplicateClass = false;
            Iterator servletNameIter = sipApplication.getServletNames();
            while( servletNameIter.hasNext()) {
                String servletNameinDD = (String) servletNameIter.next();
                if(sipApplication.getServlet(servletNameinDD).getServletClass().equals(
                    servlet.getServletClass())) {
                    String msg = newLocalStrings.getString(
                        "enterprise.deployment.backend.sip.same.servlet.class.used",
                            servlet.getServletName());
                    logger.log(Level.WARNING, msg);                   
                    isDuplicateClass = true;
                    break;
                }
            }
           
            if(isDuplicateClass) continue;

            /*
             * Check that the Servlet belongs to the same Application, That is
             * 1. Same Package as the package-info.java package annotation, or
             * 2. Same Application Name
             *
             */
            String servletPackage = servlet.getPackageName();
            String anotatedServletApplication = servlet.getApplicationName();

            /// XXX: Fix me later
            /*
            if (!new ApplicationMatcher(sipApplication).match(servletPackage,
                        anotatedServletApplication)) {
                // Not in same application, discharge his servlet
                if (logger.isLoggable(Level.INFO)) {
                    logger.log(Level.INFO,
                        "Annotated servlet found " + servletName +
                        " Servlet not defined as part of Sip Application " +
                        sipApplication.getAppName() + "and discharged");
                }

                continue;
            } else {
                if (logger.isLoggable(Level.INFO)) {
                    logger.log(Level.INFO,
                        "Deploying " + servletName +
                        " as belonging to application " +
                        sipApplication.getAppName());
                }
            }
             */

            ExistsOperand existsOperand = new ExistsOperand();

            // If only one annotated servlet exist, this is regarded as main
            // servlet
            if (servletName.equals(mainServletName) ||
                    (noAnnotatedServlets == 1)) {
                // Create a match all Pattern
                existsOperand.setVariable("request.method");
            } else {
                // Create a match nothing Pattern
                // This is not part of Operand.getAttributeValue()
                existsOperand.setVariable("NeverMatchMe");
            }

            sipApplication.addServlet(servlet);
            if(sipApplication.getServletMappings(servletName) == null ) {
                Pattern pattern = new Pattern();
                pattern.addCondition(existsOperand);

                ServletMapping servletMapping = new ServletMapping();
                servletMapping.setServletName(servletName);
                servletMapping.setPattern(pattern);
                sipApplication.addServletMapping(servletMapping);
            }
        }
    }
View Full Code Here

            }

            if ((is != null) && (confDD != null)) {
                confDD.setXMLValidation(super.getRuntimeXMLValidation());
                confDD.setXMLValidationLevel(super.getRuntimeXMLValidationLevel());
                SipApplication sipApplication = (SipApplication) confDD.read(is);
                this.sbd = (SipBundleDescriptor) sipApplication.getReferringDescriptor();
            }
        } catch (SAXParseException spe) {
           String msg =
                   newLocalStrings.getString("enterprise.deployment.backend.sip.saxparseexception")
                   + spe.getMessage();
View Full Code Here

        }

        // We create a dummy descriptor for checkin for annotations in the handles() method.
        SipBundleDescriptor dummySbd = new SipBundleDescriptor();
        // create a new dummy SipApplication object and add it to the dummySbd
        SipApplication dummySipApp = new SipApplication();
        dummySbd.setSipApplication(dummySipApp);
        File destForArchive = null;
        boolean isDirectoryDeploy = false;
      
        //Create an Annotation processor here
View Full Code Here

    protected void initInvalidateWhenReady() {
        SipSessionManager manager = getSipSessionManager();
        if (manager != null) {
            ConvergedContext ctx = manager.getContext();
            if (ctx != null) {
                SipApplication descriptor = ctx.getSipApplication();
                if (descriptor != null &&
                        SipApplication.ApplicationVersion.VERSION_1_0.equals(
                                descriptor.getApplicationVersion())) {
                    invalidateWhenReady = false;
                    return;
                }
            }
        }
View Full Code Here

    protected void initInvalidateWhenReady() {
        SipSessionManager manager = getSipSessionManager();
        if (manager != null) {
            ConvergedContext ctx = manager.getContext();
            if (ctx != null) {
                SipApplication descriptor = ctx.getSipApplication();
                if (descriptor != null &&
                        SipApplication.ApplicationVersion.VERSION_1_0.equals(
                                descriptor.getApplicationVersion())) {
                    invalidateWhenReady = false;
                    return;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.jvnet.glassfish.comms.deployment.backend.SipApplication

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.