@Override
 public void init(ServletConfig config) throws ServletException {
   // TODO Auto-generated method stub
   super.init(config);
   String state = config.getInitParameter("st");
   System.out.println("OneServ.init() ---->" + state);
 }
 @Override
 public void init(final ServletConfig servletConfig) throws ServletException {
   super.init(servletConfig);
   final String brokerIdParameter = servletConfig.getInitParameter(BROKER_ID_PARAMETER_NAME);
   if (!EmptyCheck.isEmpty(brokerIdParameter)) {
     brokerId = brokerIdParameter;
   }
 }
Beispiel #3
0
 /**
  * Registers all JSP page servlets for a plugin.
  *
  * @param manager the plugin manager.
  * @param plugin the plugin.
  * @param webXML the web.xml file containing JSP page names to servlet class file mappings.
  */
 public static void registerServlets(PluginManager manager, Plugin plugin, File webXML) {
   pluginManager = manager;
   if (!webXML.exists()) {
     Log.error(
         "Could not register plugin servlets, file "
             + webXML.getAbsolutePath()
             + " does not exist.");
     return;
   }
   // Find the name of the plugin directory given that the webXML file
   // lives in plugins/[pluginName]/web/web.xml
   String pluginName = webXML.getParentFile().getParentFile().getParentFile().getName();
   try {
     // Make the reader non-validating so that it doesn't try to resolve external
     // DTD's. Trying to resolve external DTD's can break on some firewall configurations.
     SAXReader saxReader = new SAXReader(false);
     try {
       saxReader.setFeature(
           "http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
     } catch (SAXException e) {
       Log.warn("Error setting SAXReader feature", e);
     }
     Document doc = saxReader.read(webXML);
     // Find all <servlet> entries to discover name to class mapping.
     List classes = doc.selectNodes("//servlet");
     Map<String, Class> classMap = new HashMap<String, Class>();
     for (int i = 0; i < classes.size(); i++) {
       Element servletElement = (Element) classes.get(i);
       String name = servletElement.element("servlet-name").getTextTrim();
       String className = servletElement.element("servlet-class").getTextTrim();
       classMap.put(name, manager.loadClass(plugin, className));
     }
     // Find all <servelt-mapping> entries to discover name to URL mapping.
     List names = doc.selectNodes("//servlet-mapping");
     for (int i = 0; i < names.size(); i++) {
       Element nameElement = (Element) names.get(i);
       String name = nameElement.element("servlet-name").getTextTrim();
       String url = nameElement.element("url-pattern").getTextTrim();
       // Register the servlet for the URL.
       Class servletClass = classMap.get(name);
       if (servletClass == null) {
         Log.error("Unable to load servlet, " + name + ", servlet-class not found.");
         continue;
       }
       Object instance = servletClass.newInstance();
       if (instance instanceof GenericServlet) {
         // Initialize the servlet then add it to the map..
         ((GenericServlet) instance).init(servletConfig);
         servlets.put(pluginName + url, (GenericServlet) instance);
       } else {
         Log.warn("Could not load " + (pluginName + url) + ": not a servlet.");
       }
     }
   } catch (Throwable e) {
     Log.error(e.getMessage(), e);
   }
 }
Beispiel #4
0
  public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);

    try {
      String home = servletConfig.getInitParameter("penrose.home");

      System.out.println("Starting Penrose Server at " + home + "...");
      penroseServer = new PenroseServer(home);
      penroseServer.start();

      System.out.println("Penrose Server started.");

    } catch (Exception e) {
      System.out.println("Failed starting Penrose Server: " + e.getMessage());
      throw new ServletException(e);
    }
  }
  private void _addTaglibSupportFTL(Map<String, Object> contextObjects, PageContext pageContext)
      throws Exception {

    // FreeMarker servlet application

    final Servlet servlet = (Servlet) pageContext.getPage();

    GenericServlet genericServlet = null;

    if (servlet instanceof GenericServlet) {
      genericServlet = (GenericServlet) servlet;
    } else {
      genericServlet = new GenericServletWrapper(servlet);

      genericServlet.init(pageContext.getServletConfig());
    }

    ServletContextHashModel servletContextHashModel =
        new ServletContextHashModel(genericServlet, ObjectWrapper.DEFAULT_WRAPPER);

    contextObjects.put(
        PortletDisplayTemplateConstants.FREEMARKER_SERVLET_APPLICATION, servletContextHashModel);

    // FreeMarker servlet request

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

    HttpRequestHashModel requestHashModel =
        new HttpRequestHashModel(request, response, ObjectWrapper.DEFAULT_WRAPPER);

    contextObjects.put(
        PortletDisplayTemplateConstants.FREEMARKER_SERVLET_REQUEST, requestHashModel);

    // Taglib Liferay hash

    TemplateHashModel taglibLiferayHash =
        FreeMarkerTaglibFactoryUtil.createTaglibFactory(pageContext.getServletContext());

    contextObjects.put(PortletDisplayTemplateConstants.TAGLIB_LIFERAY_HASH, taglibLiferayHash);
  }