/**
   * Handle the beginning of an XML element.
   *
   * @param attributes The attributes of this element
   * @exception Exception if a processing error occurs
   */
  public void begin(String namespace, String nameX, Attributes attributes) throws Exception {

    for (int i = 0; i < attributes.getLength(); i++) {
      String name = attributes.getLocalName(i);
      if ("".equals(name)) {
        name = attributes.getQName(i);
      }
      if ("path".equals(name) || "docBase".equals(name)) {
        continue;
      }
      String value = attributes.getValue(i);
      if (!digester.isFakeAttribute(digester.peek(), name)
          && !IntrospectionUtils.setProperty(digester.peek(), name, value)
          && digester.getRulesValidation()) {
        digester
            .getLogger()
            .warn(
                "[SetContextPropertiesRule]{"
                    + digester.getMatch()
                    + "} Setting property '"
                    + name
                    + "' to '"
                    + value
                    + "' did not find a matching property.");
      }
    }
  }
Пример #2
0
 private void guessHome() {
   String home = wEnv.getJkHome();
   if (home != null) return;
   home = IntrospectionUtils.guessInstall("jk2.home", "jk2.home", "tomcat-jk2.jar", CNAME);
   if (home != null) {
     log.info("Guessed home " + home);
     wEnv.setJkHome(home);
   }
 }
Пример #3
0
 /** Generic properties, introspected */
 @Override
 public boolean setProperty(String name, String value) {
   final String selectorPoolName = "selectorPool.";
   try {
     if (name.startsWith(selectorPoolName)) {
       return IntrospectionUtils.setProperty(
           selectorPool, name.substring(selectorPoolName.length()), value);
     } else {
       return super.setProperty(name, value);
     }
   } catch (Exception x) {
     log.error("Unable to set attribute \"" + name + "\" to \"" + value + "\"", x);
     return false;
   }
 }
Пример #4
0
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
   Enumeration<String> paramNames = filterConfig.getInitParameterNames();
   while (paramNames.hasMoreElements()) {
     String paramName = paramNames.nextElement();
     if (!IntrospectionUtils.setProperty(
         this, paramName, filterConfig.getInitParameter(paramName))) {
       String msg =
           sm.getString("filterbase.noSuchProperty", paramName, this.getClass().getName());
       if (isConfigProblemFatal()) {
         throw new ServletException(msg);
       } else {
         getLogger().warn(msg);
       }
     }
   }
 }
Пример #5
0
  public static void main(String args[]) {
    try {
      if (args.length == 1 && ("-?".equals(args[0]) || "-h".equals(args[0]))) {
        System.out.println("Usage: ");
        System.out.println("  JkMain [args]");
        System.out.println();
        System.out.println("  Each bean setter corresponds to an arg ( like -debug 10 )");
        System.out.println("  System properties:");
        System.out.println("    jk2.home    Base dir of jk2");
        return;
      }

      jkMain = new JkMain();

      IntrospectionUtils.processArgs(jkMain, args, new String[] {}, null, new Hashtable());

      jkMain.init();
      jkMain.start();
    } catch (Exception ex) {
      log.warn("Error running", ex);
    }
  }
Пример #6
0
 protected Object getInstance(
     Module module, String moduleName, String className, List<ParamValueMetaData> params)
     throws DeploymentUnitProcessingException {
   try {
     ClassLoader moduleClassLoader = null;
     if (moduleName == null) {
       moduleClassLoader = module.getClassLoader();
     } else {
       moduleClassLoader = module.getModule(ModuleIdentifier.create(moduleName)).getClassLoader();
     }
     Object instance = moduleClassLoader.loadClass(className).newInstance();
     if (params != null) {
       for (ParamValueMetaData param : params) {
         IntrospectionUtils.setProperty(instance, param.getParamName(), param.getParamValue());
       }
     }
     return instance;
   } catch (Throwable t) {
     throw new DeploymentUnitProcessingException(
         MESSAGES.failToCreateContainerComponentInstance(className), t);
   }
 }
Пример #7
0
  /* A bit of magic to support workers.properties without giving
     up the clean get/set
  */
  public void setBeanProperty(Object target, String name, String val) {
    if (val != null) val = IntrospectionUtils.replaceProperties(val, props, null);
    if (log.isDebugEnabled()) log.debug("setProperty " + target + " " + name + "=" + val);

    IntrospectionUtils.setProperty(target, name, val);
  }
Пример #8
0
  private void bootstrap(String catalinaHome, String webRoot, int port, String address)
      throws LifecycleException {
    Engine engine = null;

    // Create an embedded server
    this.embedded = new Embedded();
    this.embedded.setUseNaming(false);
    this.embedded.setCatalinaHome(catalinaHome);
    // set the memory realm
    MemoryRealm memRealm = new MemoryRealm();
    this.embedded.setRealm(memRealm);

    engine = this.embedded.createEngine();
    engine.setDefaultHost("localhost");

    // Create a default virtual host
    File tempHost = null;

    try {
      tempHost = File.createTempFile("empty", "");
      tempHost.mkdirs();
      log.debug("Embbed Host Root:" + tempHost.getAbsolutePath());
    } catch (IOException e) {
      tempHost = new File(".");
      log.warn(e, e);
    }
    this.host = this.embedded.createHost("localhost", tempHost.getAbsolutePath());
    engine.addChild(this.host);

    // Create the ROOT context
    this.rootcontext = this.embedded.createContext("", webRoot);

    this.rootcontext.addApplicationListener(SiteLoader.class.getName());
    this.rootcontext.setPrivileged(true);
    this.rootcontext.setReloadable(false);
    this.rootcontext.addWelcomeFile("index.jsp");
    this.host.addChild(this.rootcontext);

    // Install the assembled container hierarchy
    this.embedded.addEngine(engine);
    // String addr = null;
    connector = this.embedded.createConnector(address, port, false);
    if (connector == null) {
      /*
       * embedded.createConnector(...)
       * seems to be broken.. it always returns a null connector.
       * see work around below
       */
      try {
        connector = new Connector();
        // httpConnector.setScheme("http");
        connector.setSecure(false);
        // address = InetAddress.getLocalHost();
        IntrospectionUtils.setProperty(connector, "address", "" + address);
        IntrospectionUtils.setProperty(connector, "port", "" + port);

      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    connector.setEnableLookups(false);
    this.embedded.addConnector(connector);

    // Start the embedded server
    this.embedded.start();
  }