コード例 #1
0
ファイル: RulesBase.java プロジェクト: imace/coffee
  /**
   * Set the Digester instance with which this Rules instance is associated.
   *
   * @param digester The newly associated Digester instance
   */
  public void setDigester(Digester digester) {

    this.digester = digester;
    Iterator<Rule> items = rules.iterator();
    while (items.hasNext()) {
      Rule item = items.next();
      item.setDigester(digester);
    }
  }
コード例 #2
0
ファイル: RulesBase.java プロジェクト: imace/coffee
  /**
   * Register a new Rule instance matching the specified pattern.
   *
   * @param pattern Nesting pattern to be matched for this Rule
   * @param rule Rule instance to be registered
   */
  public void add(String pattern, Rule rule) {
    // to help users who accidently add '/' to the end of their patterns
    int patternLength = pattern.length();
    if (patternLength > 1 && pattern.endsWith("/")) {
      pattern = pattern.substring(0, patternLength - 1);
    }

    List<Rule> list = cache.get(pattern);
    if (list == null) {
      list = new ArrayList<Rule>();
      cache.put(pattern, list);
    }
    list.add(rule);
    rules.add(rule);
    if (this.digester != null) {
      rule.setDigester(this.digester);
    }
    if (this.namespaceURI != null) {
      rule.setNamespaceURI(this.namespaceURI);
    }
  }
コード例 #3
0
ファイル: RulesBase.java プロジェクト: imace/coffee
  /**
   * Return a List of Rule instances for the specified pattern that also match the specified
   * namespace URI (if any). If there are no such rules, return <code>null</code>.
   *
   * @param namespaceURI Namespace URI to match, or <code>null</code> to select matching rules
   *     regardless of namespace URI
   * @param pattern Pattern to be matched
   */
  protected List<Rule> lookup(String namespaceURI, String pattern) {

    // Optimize when no namespace URI is specified
    List<Rule> list = this.cache.get(pattern);
    if (list == null) {
      return (null);
    }
    if ((namespaceURI == null) || (namespaceURI.length() == 0)) {
      return (list);
    }

    // Select only Rules that match on the specified namespace URI
    ArrayList<Rule> results = new ArrayList<Rule>();
    Iterator<Rule> items = list.iterator();
    while (items.hasNext()) {
      Rule item = items.next();
      if ((namespaceURI.equals(item.getNamespaceURI())) || (item.getNamespaceURI() == null)) {
        results.add(item);
      }
    }
    return (results);
  }
 public static void startManagers() {
   Rule.startManagers();
   try {
     if (gerenciadornuvem0 == null)
       gerenciadornuvem0 =
           (Gerenciadornuvem0Interface) Naming.lookup("rmi://0:1099/gerenciadornuvem0");
     if (gerenciadornuvem1 == null)
       gerenciadornuvem1 =
           (Gerenciadornuvem1Interface) Naming.lookup("rmi://1:1099/gerenciadornuvem1");
   } catch (RemoteException e) {
     e.printStackTrace();
   } catch (NotBoundException e) {
     e.printStackTrace();
   } catch (MalformedURLException e) {
     e.printStackTrace();
   }
 }