Package org.eclipse.jst.j2ee.webapplication

Examples of org.eclipse.jst.j2ee.webapplication.Servlet


        final Iterator it = webApp.getServlets().iterator();

        while (it.hasNext())
        {
            final Servlet servlet = (Servlet) it.next();
            if (servlet != null && servlet.getWebType() != null)
            {
                if (servlet.getWebType().isServletType())
                {
                    if (((ServletType) servlet.getWebType()).getClassName() != null
                            && ((ServletType) servlet.getWebType())
                                    .getClassName().trim().equals(servletName))
                    {
                        return servlet;
                    }
                }
View Full Code Here


        final Iterator it = webApp.getServlets().iterator();

        while (it.hasNext())
        {
            final Servlet servlet = (Servlet) it.next();
            if (servlet != null && servlet.getWebType() != null)
            {
                if (servlet.getWebType().isServletType())
                {
                    if (((ServletType) servlet.getWebType()).getClassName() != null
                            && ((ServletType) servlet.getWebType())
                                    .getClassName().trim().equals(servletName))
                    {
                        return servlet;
                    }
                }
View Full Code Here

   * @return the <code>Servlet</code> object of the ClickServlet or <code>null</code>
   */
  public static Servlet findClickServlet(WebApp webApp, boolean useSpring) {
    String servletClassName = useSpring ? CLICK_SPRING_SERVLET_CLASS : CLICK_SERVLET_CLASS;

    Servlet servlet = null;
    @SuppressWarnings("rawtypes")
    Iterator it = webApp.getServlets().iterator();

    while (it.hasNext()) {
      servlet = (Servlet) it.next();
      if (servlet.getWebType().isServletType()) {
        if (((ServletType) servlet.getWebType()).getClassName().equals(servletClassName)) {
          break;
        }
      } else if (servlet.getWebType().isJspType()) {
        if (((JSPType) servlet.getWebType()).getJspFile().equals(servletClassName)) {
          break;
        }
      }
    }
    return servlet;
View Full Code Here

   * @return the <code>Servlet</code> object of the ClickServlet or <code>null</code>
   */
  public static Servlet findClickServlet(WebApp webApp, boolean useSpring) {
    String servletClassName = useSpring ? CLICK_SPRING_SERVLET_CLASS : CLICK_SERVLET_CLASS;
   
    Servlet servlet = null;
    @SuppressWarnings("unchecked")
    Iterator it = webApp.getServlets().iterator();
   
    while (it.hasNext()) {
      servlet = (Servlet) it.next();
      if (servlet.getWebType().isServletType()) {
        if (((ServletType) servlet.getWebType()).getClassName().equals(servletClassName)) {
          break;
        }
      } else if (servlet.getWebType().isJspType()) {
        if (((JSPType) servlet.getWebType()).getJspFile().equals(servletClassName)) {
          break;
        }
      }
    }
    return servlet;
View Full Code Here

    try {
      artifactEdit = ClickUtils.getWebArtifactEditForWrite(project);
      webApp = artifactEdit.getWebApp();

      // create or update servlet ref
      Servlet servlet = ClickUtils.findClickServlet(webApp, useSpring);
      if (servlet != null) {
        // remove old mappings
        ClickUtils.removeURLMappings(webApp, servlet);
      }

      servlet = ClickUtils.createOrUpdateServletRef(webApp, config, servlet, useSpring);
     
      if(useSpring){
        ParamValue contextParam = CommonFactory.eINSTANCE.createParamValue();
        contextParam.setName("contextConfigLocation");
        contextParam.setValue("WEB-INF/spring-beans.xml");
        webApp.getContextParams().add(contextParam);
       
        Listener listener = CommonFactory.eINSTANCE.createListener();
        listener.setListenerClassName("org.springframework.web.context.ContextLoaderListener");
        webApp.getListeners().add(listener);
      }
     
      // Add PerformanceFilter
      if(usePerformanceFilter){
        Filter filter = WebapplicationFactory.eINSTANCE.createFilter();
        filter.setName("PerformanceFilter");
        filter.setFilterClassName("org.apache.click.extras.filter.PerformanceFilter");
       
        if (webApp.getJ2EEVersionID() >= J2EEVersionConstants.J2EE_1_4_ID) {
          // J2EE 1.4
          ParamValue initParam = CommonFactory.eINSTANCE.createParamValue();
          initParam.setName("cachable-paths");
          initParam.setValue("/assets/*");
          filter.getInitParamValues().add(initParam);
        } else {
          // J2EE 1.2 or 1.3
          InitParam initParam = WebapplicationFactory.eINSTANCE.createInitParam();
          initParam.setParamName("cachable-paths");
          initParam.setParamValue("/assets/*");
          filter.getInitParams().add(initParam);
        }
       
        webApp.getFilters().add(filter);

        FilterMapping mapping = WebapplicationFactory.eINSTANCE.createFilterMapping();
        mapping.setServletName(servlet.getServletName());
        mapping.setFilter(filter);
        webApp.getFilterMappings().add(mapping);
       
        String[] filterPatterns = {"*.css", "*.js", "*.gif", "*.png"};
        for(String pattern: filterPatterns){
          mapping = WebapplicationFactory.eINSTANCE.createFilterMapping();
          mapping.setFilter(filter);
          mapping.setUrlPattern(pattern);
          webApp.getFilterMappings().add(mapping);
        }
      }
     
      // init mappings
      String[] listOfMappings = {"*.htm"};
      ClickUtils.setUpURLMappings(webApp, listOfMappings, servlet);

      // welcome-file-list
      ClickUtils.createOrUpdateFilelist(webApp);

      // Add Cayenne Support
      if(useCayenne){
        Filter filter = WebapplicationFactory.eINSTANCE.createFilter();
        filter.setFilterClassName(ClickUtils.CAYENNE_FILTER_CLASS);
        filter.setName("DataContextFilter");

        if (webApp.getJ2EEVersionID() >= J2EEVersionConstants.J2EE_1_4_ID) {
          // J2EE 1.4
          ParamValue initParam = CommonFactory.eINSTANCE.createParamValue();
          initParam.setName("session-scope");
          initParam.setValue("false");
          filter.getInitParamValues().add(initParam);
        } else {
          // J2EE 1.2 or 1.3
          InitParam initParam = WebapplicationFactory.eINSTANCE.createInitParam();
          initParam.setParamName("session-scope");
          initParam.setParamValue("false");
          filter.getInitParams().add(initParam);
        }

        webApp.getFilters().add(filter);

        FilterMapping mapping = WebapplicationFactory.eINSTANCE.createFilterMapping();
        mapping.setServletName(servlet.getServletName());
        mapping.setFilter(filter);
        webApp.getFilterMappings().add(mapping);
      }
    } catch(Exception ex){
      ClickPlugin.log(ex);
View Full Code Here

      IDataModel config, IProgressMonitor monitor) {
    WebArtifactEdit artifactEdit = ClickUtils.getWebArtifactEditForWrite(project);
    WebApp webApp = artifactEdit.getWebApp();

    try {
      Servlet servlet = ClickUtils.findClickServlet(webApp, false);
      if (servlet == null){
        servlet = ClickUtils.findClickServlet(webApp, true);
        if(servlet == null){
          return;
        }
View Full Code Here

TOP

Related Classes of org.eclipse.jst.j2ee.webapplication.Servlet

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.