Package org.eclipse.jst.j2ee.webapplication

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


  private static List getConfigFilesForJ2EEApp(IProject project){
    List filesList = new ArrayList();
    WebArtifactEdit webArtifactEdit = WebArtifactEdit.getWebArtifactEditForRead(project);
    if (webArtifactEdit != null) {
      try {
        WebApp webApp = null;
        try {
          webApp = webArtifactEdit.getWebApp();
        } catch(ClassCastException cce) {
          //occasionally thrown from WTP code in RC3 and possibly later
          TapestryCorePlugin.log(IStatus.ERROR, cce.getLocalizedMessage(), cce);
          return filesList;
        }
        if (webApp != null) {
          String filesString = null;
          //need to branch here due to model version differences (BugZilla #119442)
          if (webApp.getVersionID() == J2EEVersionConstants.WEB_2_3_ID) {
            EList contexts = webApp.getContexts();
            Iterator itContexts = contexts.iterator();
            while (itContexts.hasNext()) {
              ContextParam contextParam = (ContextParam)itContexts.next();
              if (contextParam.getParamName().equals(CONFIG_FILES_CONTEXT_PARAM_NAME)) {
                filesString = contextParam.getParamValue();
                break;
              }
            }
          } else {
            EList contextParams = webApp.getContextParams();
            Iterator itContextParams = contextParams.iterator();
            while (itContextParams.hasNext()) {
              ParamValue paramValue = (ParamValue)itContextParams.next();
              if (paramValue.getName().equals(CONFIG_FILES_CONTEXT_PARAM_NAME)) {
                filesString = paramValue.getValue();
View Full Code Here


  private void createServletAndModifyWebXML(
      IProject project, final IDataModel config,IProgressMonitor monitor,
      boolean useSpring, boolean useCayenne, boolean usePerformanceFilter) {

    WebApp webApp = null;
    WebArtifactEdit artifactEdit = null;
    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);
    } finally {
      if (artifactEdit != null) {
View Full Code Here

  }
 
  private void uninstallClickReferencesFromWebApp(IProject project,
      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);
View Full Code Here

  private static List<String> getConfigFilesForJ2EEApp(IProject project){
    List<String> filesList = new ArrayList<String>();
    WebArtifactEdit webArtifactEdit = WebArtifactEdit.getWebArtifactEditForRead(project);
    if (webArtifactEdit != null) {
      try {
        WebApp webApp = null;
        try {
          webApp = webArtifactEdit.getWebApp();
        } catch(ClassCastException cce) {
          //occasionally thrown from WTP code in RC3 and possibly later
          LOG.error(Messages.JSFAppConfigUtils_Error_Reading_WebXml, cce);
          return filesList;
        }
        if (webApp != null) {
          String filesString = null;
          //need to branch here due to model version differences (BugZilla #119442)
          if (webApp.getVersionID() == J2EEVersionConstants.WEB_2_3_ID) {
            EList contexts = webApp.getContexts();
            Iterator itContexts = contexts.iterator();
            while (itContexts.hasNext()) {
              ContextParam contextParam = (ContextParam)itContexts.next();
              if (contextParam.getParamName().equals(CONFIG_FILES_CONTEXT_PARAM_NAME)) {
                filesString = contextParam.getParamValue();
                break;
              }
            }
          } else {
            EList contextParams = webApp.getContextParams();
            Iterator itContextParams = contextParams.iterator();
            while (itContextParams.hasNext()) {
              ParamValue paramValue = (ParamValue)itContextParams.next();
              if (paramValue.getName().equals(CONFIG_FILES_CONTEXT_PARAM_NAME)) {
                filesString = paramValue.getValue();
View Full Code Here

TOP

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

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.