Examples of WebAppController


Examples of com.caucho.server.webapp.WebAppController

    Path archivePath = null;

    if (contextUrl == null)
      contextUrl = webUri;

    WebAppController controller = null;

    if (webUri.endsWith(".war")) {
      // server/2a16
      String name = webUri.substring(0, webUri.length() - 4);
      int p = name.lastIndexOf('/');
      if (p > 0)
        name = name.substring(p + 1);

      // XXX:
      if (contextUrl.equals(""))
        contextUrl = "/" + name;

      if (contextUrl.endsWith(".war"))
        contextUrl = contextUrl.substring(0, contextUrl.length() - 4);

      Path expandPath = _webappsPath;

      try {
        expandPath.mkdirs();
      } catch (Exception e) {
        log.log(Level.WARNING, e.toString(), e);
      }

      archivePath = path;
      path = expandPath.lookup(name);
    } else {
      // server/2a15
      if (contextUrl.equals("")) {
        String name = webUri;
        int p = name.lastIndexOf('/');
        if (p > 0)
          name = name.substring(p + 1);
        contextUrl = "/" + name;
      }

      // server/2a17
      if (contextUrl.endsWith(".war"))
        contextUrl = contextUrl.substring(0, contextUrl.length() - 4);
    }

    if (! contextUrl.startsWith("/"))
      contextUrl = "/" + contextUrl;

    controller = findWebAppEntry(contextUrl);

    if (controller == null) {
      controller = new WebAppController(contextUrl,
                                        contextUrl,
                                        path,
                                        _container);

      _webApps.add(controller);
    }

    if (archivePath != null)
      controller.setArchivePath(archivePath);

    controller.setDynamicDeploy(true);

    if (_configException != null)
      controller.setConfigException(_configException);

    for (WebAppConfig config : web.getWebAppList())
      controller.addConfigDefault(config);
  }
View Full Code Here

Examples of com.caucho.server.webapp.WebAppController

   * Returns any matching web-app.
   */
  public WebAppController findWebAppEntry(String name)
  {
    for (int i = 0; i < _webApps.size(); i++) {
      WebAppController controller = _webApps.get(i);

      if (controller.isNameMatch(name))
        return controller;
    }

    return null;
  }
View Full Code Here

Examples of hudson.stapler.WebAppController

    public void contextInitialized(ServletContextEvent event) {
        try {
            final ServletContext context = event.getServletContext();

            // Install the current servlet context, unless its already been set
            final WebAppController controller = WebAppController.get();
            try {
                // Attempt to set the context
                controller.setContext(context);
            }
            catch (IllegalStateException e) {
                // context already set ignore
            }

            // Setup the default install strategy if not already configured
            try {
                controller.setInstallStrategy(new DefaultInstallStrategy());
            }
            catch (IllegalStateException e) {
                // strategy already set ignore
            }

            // use the current request to determine the language
            LocaleProvider.setProvider(new LocaleProvider() {
                public Locale get() {
                    Locale locale=null;
                    StaplerRequest req = Stapler.getCurrentRequest();
                    if(req!=null)
                        locale = req.getLocale();
                    if(locale==null)
                        locale = Locale.getDefault();
                    return locale;
                }
            });

            // quick check to see if we (seem to) have enough permissions to run. (see #719)
            JVM jvm;
            try {
                jvm = new JVM();
                new URLClassLoader(new URL[0],getClass().getClassLoader());
            } catch(SecurityException e) {
                controller.install(new InsufficientPermissionDetected(e));
                return;
            }

            try {// remove Sun PKCS11 provider if present. See http://wiki.hudson-ci.org/display/HUDSON/Solaris+Issue+6276483
                Security.removeProvider("SunPKCS11-Solaris");
            } catch (SecurityException e) {
                // ignore this error.
            }

            installLogger();

            File dir = getHomeDir(event);
            try {
                dir = dir.getCanonicalFile();
            }
            catch (IOException e) {
                dir = dir.getAbsoluteFile();
            }
            final File home = dir;
            home.mkdirs();

            LOGGER.info("Home directory: " + home);

            // check that home exists (as mkdirs could have failed silently), otherwise throw a meaningful error
            if (! home.exists()) {
                controller.install(new NoHomeDir(home));
                return;
            }

            // make sure that we are using XStream in the "enhanced" (JVM-specific) mode
            if(jvm.bestReflectionProvider().getClass()==PureJavaReflectionProvider.class) {
                // nope
                controller.install(new IncompatibleVMDetected());
                return;
            }

//  JNA is no longer a hard requirement. It's just nice to have. See HUDSON-4820 for more context.
//            // make sure JNA works. this can fail if
//            //    - platform is unsupported
//            //    - JNA is already loaded in another classloader
//            // see http://wiki.hudson-ci.org/display/HUDSON/JNA+is+already+loaded
//            // TODO: or shall we instead modify Hudson to work gracefully without JNA?
//            try {
//                /*
//                    java.lang.UnsatisfiedLinkError: Native Library /builds/apps/glassfish/domains/hudson-domain/generated/jsp/j2ee-modules/hudson-1.309/loader/com/sun/jna/sunos-sparc/libjnidispatch.so already loaded in another classloader
//                        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1743)
//                        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674)
//                        at java.lang.Runtime.load0(Runtime.java:770)
//                        at java.lang.System.load(System.java:1005)
//                        at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:746)
//                        at com.sun.jna.Native.loadNativeLibrary(Native.java:680)
//                        at com.sun.jna.Native.<clinit>(Native.java:108)
//                        at hudson.util.jna.GNUCLibrary.<clinit>(GNUCLibrary.java:86)
//                        at hudson.Util.createSymlink(Util.java:970)
//                        at hudson.model.Run.run(Run.java:1174)
//                        at hudson.matrix.MatrixBuild.run(MatrixBuild.java:149)
//                        at hudson.model.ResourceController.execute(ResourceController.java:88)
//                        at hudson.model.Executor.run(Executor.java:123)
//                 */
//                String.valueOf(Native.POINTER_SIZE); // this meaningless operation forces the classloading and initialization
//            } catch (LinkageError e) {
//                if (e.getMessage().contains("another classloader"))
//                    controller.install(new JNADoublyLoaded(e));
//                else
//                    controller.install(new HudsonFailedToLoad(e));
//            }

            // make sure this is servlet 2.4 container or above
            try {
                ServletResponse.class.getMethod("setCharacterEncoding",String.class);
            } catch (NoSuchMethodException e) {
                controller.install(new IncompatibleServletVersionDetected(ServletResponse.class));
                return;
            }

            // make sure that we see Ant 1.7
            try {
                FileSet.class.getMethod("getDirectoryScanner");
            } catch (NoSuchMethodException e) {
                controller.install(new IncompatibleAntVersionDetected(FileSet.class));
                return;
            }

            // make sure AWT is functioning, or else JFreeChart won't even load.
            if(ChartUtil.awtProblemCause!=null) {
                controller.install(new AWTProblem(ChartUtil.awtProblemCause));
                return;
            }

            // some containers (in particular Tomcat) doesn't abort a launch
            // even if the temp directory doesn't exist.
            // check that and report an error
            try {
                File f = File.createTempFile("test", "test");
                f.delete();
            } catch (IOException e) {
                controller.install(new NoTempDir(e));
                return;
            }

            // Tomcat breaks XSLT with JDK 5.0 and onward. Check if that's the case, and if so,
            // try to correct it
            try {
                TransformerFactory.newInstance();
                // if this works we are all happy
            } catch (TransformerFactoryConfigurationError x) {
                // no it didn't.
                LOGGER.log(Level.WARNING, "XSLT not configured correctly. Hudson will try to fix this. See http://issues.apache.org/bugzilla/show_bug.cgi?id=40895 for more details",x);
                System.setProperty(TransformerFactory.class.getName(),"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
                try {
                    TransformerFactory.newInstance();
                    LOGGER.info("XSLT is set to the JAXP RI in JRE");
                } catch(TransformerFactoryConfigurationError y) {
                    LOGGER.log(Level.SEVERE, "Failed to correct the problem.");
                }
            }

            installExpressionFactory(event);

            controller.install(new HudsonIsLoading());

            new Thread("hudson initialization thread") {
                @Override
                public void run() {
                    try {
                        // Creating of the god object performs most of the booting muck
                        Hudson hudson = new Hudson(home,context);

                        // once its done, hook up to stapler and things should be ready to go
                        controller.install(hudson);

                        // trigger the loading of changelogs in the background,
                        // but give the system 10 seconds so that the first page
                        // can be served quickly
                        Trigger.timer.schedule(new SafeTimerTask() {
                            public void doRun() {
                                User.getUnknown().getBuilds();
                            }
                        }, 1000*10);
                    } catch (Error e) {
                        LOGGER.log(Level.SEVERE, "Failed to initialize Hudson",e);
                        controller.install(new HudsonFailedToLoad(e));
                        throw e;
                    } catch (Exception e) {
                        LOGGER.log(Level.SEVERE, "Failed to initialize Hudson",e);
                        controller.install(new HudsonFailedToLoad(e));
                    }
                }
            }.start();
        } catch (Error e) {
            LOGGER.log(Level.SEVERE, "Failed to initialize Hudson",e);
View Full Code Here

Examples of hudson.stapler.WebAppController

        }
        hudson.setNoUsageStatistics(true); // collecting usage stats from tests are pointless.
       
        hudson.setCrumbIssuer(new TestCrumbIssuer());

        final WebAppController controller = WebAppController.get();
        try {
            controller.setContext(hudson.servletContext);
        } catch (IllegalStateException e) {
            // handle tests which run several times inside the same JVM
            Field f = WebAppController.class.getDeclaredField("context");
            f.setAccessible(true);
            f.set(controller,hudson.servletContext);
        }
        try {
            controller.setInstallStrategy(new DefaultInstallStrategy());
        } catch (IllegalStateException e) {
            // strategy already set ignore
        }
        controller.install(hudson);

        hudson.servletContext.setAttribute("version","?");
        WebAppMain.installExpressionFactory(new ServletContextEvent(hudson.servletContext));

        // set a default JDK to be the one that the harness is using.
View Full Code Here

Examples of org.exoplatform.web.WebAppController

      final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
      boolean hasChanged = false;
      try
      {
         ServletConfig config = new PortalServletConfig(sConfig, portalContainer);
         WebAppController controller =
            (WebAppController)portalContainer.getComponentInstanceOfType(WebAppController.class);
         // Set the full classloader of the portal container
         Thread.currentThread().setContextClassLoader(portalContainer.getPortalClassLoader());
         hasChanged = true;
         PortalApplication application = new PortalApplication(config);
         application.onInit();
         controller.addApplication(application);
         controller.register(new PortalRequestHandler());
         log.info("The WebAppController has been successfully initialized for the portal '" + portalContainer.getName()
            + "'");
      }
      catch (Throwable t)
      {
View Full Code Here

Examples of org.exoplatform.web.WebAppController

   protected void onService(ExoContainer container, HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException
   {
      try
      {
         WebAppController controller = (WebAppController)container.getComponentInstanceOfType(WebAppController.class);
         controller.service(req, res);
      }
      catch (Throwable t)
      {
         throw new ServletException(t);
      }
View Full Code Here

Examples of org.exoplatform.web.WebAppController

               uiApp.addMessage(new ApplicationMessage("UIGadgetManagement.msg.deleteGadgetInUse", null));
               return;
            }
         }
         service.removeGadget(name);
         WebAppController webController = uiManagement.getApplicationComponent(WebAppController.class);
         webController.removeApplication(GadgetApplication.EXO_GADGET_GROUP + "/" + name);
         Gadget gadget = uiManagement.getGadget(name);
         if (gadget.isLocal())
         {
            // get dir path of gadget
            String gadgetUrl = gadget.getUrl();
View Full Code Here

Examples of org.exoplatform.web.WebAppController

     *
     * If it does not exist a new PortletApplication object is created, init and cached in the controller
     */
    private PortletApplication getPortletApplication() throws Exception {
        ExoContainer container = ExoContainerContext.getCurrentContainer();
        WebAppController controller = (WebAppController) container.getComponentInstanceOfType(WebAppController.class);
        PortletApplication application = controller.getApplication(applicationId_);
        if (application == null) {
            if (appProvider != null) {
                // We are only expecting one
                application = appProvider.createApplication(getPortletConfig());
            } else {
                application = new PortletApplication(getPortletConfig());
            }
            application.onInit();
            application = controller.addApplication(application);
        }
        return application;
    }
View Full Code Here

Examples of org.exoplatform.web.WebAppController

        List<ExoContainer> containers = rootContainer.getComponentInstancesOfType(ExoContainer.class);
        containers.add(rootContainer);
        try {
            for (ExoContainer container : containers) {
                ExoContainerContext.setCurrentContainer(container);
                WebAppController controller = (WebAppController) container.getComponentInstanceOfType(WebAppController.class);
                // TODO: figure out what is happening with the controller not existing during shutdown
                if (controller != null) {
                    PortletApplication application = controller.getApplication(applicationId_);
                    if (application != null) {
                        application.onDestroy();
                        controller.removeApplication(applicationId_);
                    }
                }

                PortletConfigRegistry registry = (PortletConfigRegistry) container
                        .getComponentInstanceOfType(PortletConfigRegistry.class);
View Full Code Here

Examples of org.exoplatform.web.WebAppController

    * controller
    */
   private PortletApplication getPortletApplication() throws Exception
   {
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      WebAppController controller = (WebAppController)container.getComponentInstanceOfType(WebAppController.class);
      PortletApplication application = controller.getApplication(applicationId_);
      if (application == null)
      {
         application = new PortletApplication(getPortletConfig());
         application.onInit();
         controller.addApplication(application);
      }
      return application;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.