Esempio n. 1
1
  private static Long latestVersion(Hashtable<String, String> config, dbutil db_util)
      throws Exception {
    if (!config.get("timestamp_stop").equals(Integer.toString(Integer.MAX_VALUE))) {
      return new Long(config.get("timestamp_stop"));
    }

    String rowName = config.get("file_id") + config.get("run_id") + "_";
    if (config.get("task_id") != "") {
      try {
        rowName = rowName + String.format("%04d", new Integer(config.get("task_id")));
      } catch (NumberFormatException E) {
        rowName = rowName + config.get("task_id");
      }
    }
    Get timestampGet = new Get(rowName.getBytes());
    timestampGet.addColumn("d".getBytes(), "update".getBytes());
    Result timestampResult = db_util.doGet(config.get("db_name_updates"), timestampGet);
    KeyValue tsKv = timestampResult.getColumnLatest("d".getBytes(), "update".getBytes());
    if (tsKv == null) {
      rowName = config.get("file_id") + "_";
      timestampGet = new Get(rowName.getBytes());
      timestampGet.addColumn("d".getBytes(), "update".getBytes());
      timestampResult = db_util.doGet(config.get("db_name_updates"), timestampGet);
      tsKv = timestampResult.getColumnLatest("d".getBytes(), "update".getBytes());
    }

    if (tsKv == null) {
      return new Long(Integer.MAX_VALUE);
    }
    Long latestVersion = new Long(tsKv.getTimestamp());
    return latestVersion;
  }
Esempio n. 2
0
 /**
  * Load image from resource path (using getResource). Note that GIFs are loaded as _translucent_
  * indexed images. Images are cached: loading an image with the same name twice will get the
  * cached image the second time. If you want to remove an image from the cache, use purgeImage.
  * Throws JGError when there was an error.
  */
 @SuppressWarnings({"deprecation", "unchecked"})
 public JGImage loadImage(String imgfile) {
   Image img = (Image) loadedimages.get(imgfile);
   if (img == null) {
     URL imgurl = getClass().getResource(imgfile);
     if (imgurl == null) {
       try {
         File imgf = new File(imgfile);
         if (imgf.canRead()) {
           imgurl = imgf.toURL();
         } else {
           imgurl = new URL(imgfile);
           // throw new JGameError(
           //	"File "+imgfile+" not found.",true);
         }
       } catch (MalformedURLException e) {
         // e.printStackTrace();
         throw new JGameError("File not found or malformed path or URL '" + imgfile + "'.", true);
       }
     }
     img = output_comp.getToolkit().createImage(imgurl);
     loadedimages.put(imgfile, img);
   }
   try {
     ensureLoaded(img);
   } catch (Exception e) {
     // e.printStackTrace();
     throw new JGameError("Error loading image " + imgfile);
   }
   return new JREImage(img);
 }
Esempio n. 3
0
  public Object getAttribute(String name) {
    if (name.startsWith("org.apache.tomcat")) {
      // XXX XXX XXX XXX Security - servlets may get too much access !!!
      // right now we don't check because we need JspServlet to
      // be able to access classloader and classpath

      if (name.equals("org.apache.tomcat.jsp_classpath")) {
        String cp = getServletLoader().getClassPath();
        return cp;
      }
      if (name.equals("org.apache.tomcat.protection_domain")) {
        return getProtectionDomain();
      }
      if (name.equals("org.apache.tomcat.classloader")) {
        return this.getServletLoader().getClassLoader();
      }
      if (name.equals(FacadeManager.FACADE_ATTRIBUTE)) {
        if (!allowAttribute(name)) return null;
        return this.getFacadeManager();
      }
      return null; // org.apache.tomcat namespace is reserved in tomcat
    } else {
      Object o = attributes.get(name);
      return attributes.get(name);
    }
  }
Esempio n. 4
0
 public Vector getAssociatedLevelLists() {
   Vector levelLists = new Vector();
   Vector endPts = CollectionHelper.makeVector("Keyword");
   Hashtable keywordParents =
       oncotcap.Oncotcap.getDataSource()
           .getParentTree(
               "Keyword", endPts, CollectionHelper.makeVector(this), TreeDisplayModePanel.ROOT);
   // Take each of the parents and get the associated level lists
   if (keywordParents.size() <= 0) return levelLists;
   Hashtable levelListsHashtable =
       oncotcap.Oncotcap.getDataSource()
           .getInstanceTree(
               "EnumLevelList",
               new Vector(),
               makeLevelListFilter(keywordParents),
               TreeDisplayModePanel.ROOT);
   for (Enumeration e = keywordParents.keys(); e.hasMoreElements(); ) {
     System.out.println("Keyword.getAssociatedLevelLists: " + e.nextElement());
   }
   // Collect all the level lists from the hashtable
   Vector selectedItems = CollectionHelper.makeVector(keyword);
   for (Enumeration e = levelListsHashtable.keys(); e.hasMoreElements(); ) {
     Object obj = e.nextElement();
     if (obj instanceof EnumLevelList) {
       levelLists.addElement(obj);
     }
   }
   return levelLists;
 }
Esempio n. 5
0
 private static toFrom checkArgs(Hashtable config) {
   if (config.get("type").equals("l2r")) {
     return toFrom.LOCAL2REMOTE;
   } else if (config.get("type").equals("r2l")) {
     return toFrom.REMOTE2LOCAL;
   } else {
     return toFrom.ERROR;
   }
 }
Esempio n. 6
0
 private void initGetterMap() {
   Method getter = null;
   getter = getGetter("getKeyword");
   getMethodMap.put("keyword", getter);
   getter = getGetter("getParents");
   getMethodMap.put("parentKeyword", getter);
   getter = getGetter("getDescribedInstances");
   getMethodMap.put("describedInstances", getter);
   // 		getter = getGetter("getSubordinateKeywords");
   // 				getMethodMap.put("subordinateKeywords", getter);
 }
Esempio n. 7
0
 private void initSetterMap() {
   Method setter = null;
   setter = getSetter("setKeyword", String.class);
   setMethodMap.put("keyword", setter);
   setter = getSetter("setParents", DefaultPersistibleList.class);
   setMethodMap.put("parentKeyword", setter);
   setter = getSetter("setDescribedInstances", DefaultPersistibleList.class);
   setMethodMap.put("describedInstances", setter);
   //  				setter = getSetter("getSubordinateKeywords");
   //  				getMethodMap.put("subordinateKeywords", setter);
 }
Esempio n. 8
0
 /**
  * Add a servlet with the given name to the container. The servlet will be loaded by the
  * container's class loader and instantiated using the given class name.
  *
  * <p>Called to add a new servlet from web.xml
  */
 public void addServlet(ServletWrapper wrapper) throws TomcatException {
   wrapper.setContext(this);
   String name = wrapper.getServletName();
   //	System.out.println("Adding servlet " + name  + " " + wrapper);
   // check for duplicates
   if (servlets.get(name) != null) {
     log("Removing duplicate servlet " + name + " " + wrapper);
     removeServletByName(name);
     //	    getServletByName(name).destroy();
   }
   servlets.put(name, wrapper);
 }
Esempio n. 9
0
 /** Behaves like loadImage(String). Returns null if there was an error. */
 @SuppressWarnings("unchecked")
 public static JGImage loadImage(URL imgurl) {
   Image img = (Image) loadedimages.get(imgurl);
   if (img == null) {
     img = output_comp.getToolkit().createImage(imgurl);
     loadedimages.put(imgurl, img);
   }
   try {
     ensureLoaded(img);
   } catch (Exception e) {
     System.err.println("Error loading image " + imgurl);
     return null;
   }
   return new JREImage(img);
 }
Esempio n. 10
0
  private void addKeyword(Hashtable table, Keyword word, Keyword parent) {
    boolean recurse = true;

    if (table.containsKey(word)) recurse = false;

    if (parent == null) table.put(word, String.valueOf(-1));
    else table.put(word, parent);

    if (recurse) {
      Iterator it = word.getChildren().iterator();
      while (it.hasNext()) {
        addKeyword(table, (Keyword) it.next(), word);
      }
    }
  }
  /** Prepares the factory for bundle shutdown. */
  public void stop() {
    if (logger.isTraceEnabled()) logger.trace("Preparing to stop all protocol providers of" + this);

    synchronized (registeredAccounts) {
      for (Enumeration<ServiceRegistration> registrations = registeredAccounts.elements();
          registrations.hasMoreElements(); ) {
        ServiceRegistration reg = registrations.nextElement();

        stop(reg);

        reg.unregister();
      }

      registeredAccounts.clear();
    }
  }
Esempio n. 12
0
  /**
   * @param obj ValueObject related to the current row
   * @param colIndex TableModel column index
   * @return Object contained into the TableModel at the specified column and ValueObject
   */
  public final Object getField(ValueObject obj, int colIndex) {
    try {
      Method[] m = (Method[]) voGetterMethods.get(getFieldName(colIndex));
      if (m == null)
        Logger.error(
            this.getClass().getName(),
            "getField",
            "No getter method for index "
                + colIndex
                + " and attribute name '"
                + getFieldName(colIndex)
                + "'.",
            null);

      for (int i = 0; i < m.length - 1; i++) {
        obj = (ValueObject) m[i].invoke(obj, new Object[0]);
        if (obj == null) {
          if (grids.getGridControl() == null || !grids.getGridControl().isCreateInnerVO())
            return null;
          else obj = (ValueObject) m[i].getReturnType().newInstance();
        }
      }

      return m[m.length - 1].invoke(obj, new Object[0]);
    } catch (Exception ex) {
      ex.printStackTrace();
      return null;
    }
  }
  /**
   * Returns the ServiceReference for the protocol provider corresponding to the specified accountID
   * or null if the accountID is unknown.
   *
   * @param accountID the accountID of the protocol provider we'd like to get
   * @return a ServiceReference object to the protocol provider with the specified account id and
   *     null if the account id is unknown to the provider factory.
   */
  public ServiceReference getProviderForAccount(AccountID accountID) {
    ServiceRegistration registration;

    synchronized (registeredAccounts) {
      registration = registeredAccounts.get(accountID);
    }
    return (registration == null) ? null : registration.getReference();
  }
Esempio n. 14
0
  /**
   * Maps a named servlet to a particular path or extension. If the named servlet is unregistered,
   * it will be added and subsequently mapped.
   *
   * <p>Note that the order of resolution to handle a request is:
   *
   * <p>exact mapped servlet (eg /catalog) prefix mapped servlets (eg /foo/bar/*) extension mapped
   * servlets (eg *jsp) default servlet
   */
  public void addServletMapping(String path, String servletName) throws TomcatException {
    if (mappings.get(path) != null) {
      log("Removing duplicate " + path + " -> " + mappings.get(path));
      mappings.remove(path);
      Container ct = (Container) containers.get(path);
      removeContainer(ct);
    }
    ServletWrapper sw = (ServletWrapper) servlets.get(servletName);
    if (sw == null) {
      // Workaround for frequent "bug" in web.xmls
      // Declare a default mapping
      log("Mapping with unregistered servlet " + servletName);
      sw = addServlet(servletName, servletName);
    }
    if ("/".equals(path)) defaultServlet = sw;

    mappings.put(path, sw);

    Container map = new Container();
    map.setContext(this);
    map.setHandler(sw);
    map.setPath(path);
    contextM.addContainer(map);
    containers.put(path, map);
  }
Esempio n. 15
0
  /**
   * Returns an array containing all installed providers that satisfy the specified selection
   * criterion, or null if no such providers have been installed. The returned providers are ordered
   * according to their <a href= "#insertProviderAt(java.security.Provider, int)">preference
   * order</a>.
   *
   * <p>A cryptographic service is always associated with a particular algorithm or type. For
   * example, a digital signature service is always associated with a particular algorithm (e.g.,
   * DSA), and a CertificateFactory service is always associated with a particular certificate type
   * (e.g., X.509).
   *
   * <p>The selection criterion must be specified in one of the following two formats:
   *
   * <ul>
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type></i>
   *       <p>The cryptographic service name must not contain any dots.
   *       <p>A provider satisfies the specified selection criterion iff the provider implements the
   *       specified algorithm or type for the specified cryptographic service.
   *       <p>For example, "CertificateFactory.X.509" would be satisfied by any provider that
   *       supplied a CertificateFactory implementation for X.509 certificates.
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type> &lt;attribute_name>:&lt
   *       attribute_value></i>
   *       <p>The cryptographic service name must not contain any dots. There must be one or more
   *       space charaters between the the <i>&lt;algorithm_or_type></i> and the
   *       <i>&lt;attribute_name></i>.
   *       <p>A provider satisfies this selection criterion iff the provider implements the
   *       specified algorithm or type for the specified cryptographic service and its
   *       implementation meets the constraint expressed by the specified attribute name/value pair.
   *       <p>For example, "Signature.SHA1withDSA KeySize:1024" would be satisfied by any provider
   *       that implemented the SHA1withDSA signature algorithm with a keysize of 1024 (or larger).
   * </ul>
   *
   * <p>See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java
   * Cryptogaphy Architecture API Specification &amp; Reference </a> for information about standard
   * cryptographic service names, standard algorithm names and standard attribute names.
   *
   * @param filter the criterion for selecting providers. The filter is case-insensitive.
   * @return all the installed providers that satisfy the selection criterion, or null if no such
   *     providers have been installed.
   * @throws InvalidParameterException if the filter is not in the required format
   * @throws NullPointerException if filter is null
   * @see #getProviders(java.util.Map)
   */
  public static Provider[] getProviders(String filter) {
    String key = null;
    String value = null;
    int index = filter.indexOf(':');

    if (index == -1) {
      key = filter;
      value = "";
    } else {
      key = filter.substring(0, index);
      value = filter.substring(index + 1);
    }

    Hashtable hashtableFilter = new Hashtable(1);
    hashtableFilter.put(key, value);

    return (getProviders(hashtableFilter));
  }
Esempio n. 16
0
 /**
  * @param fieldName attribute name
  * @return int column index
  */
 public final int getFieldIndex(String fieldName) {
   Integer index = (Integer) reverseIndexes.get(fieldName);
   if (index != null) return index.intValue();
   Logger.error(
       this.getClass().getName(),
       "getFieldIndex",
       "The column '" + fieldName + "' does not exist",
       null);
   return (-1);
 }
  /**
   * Gets a pluggable editor for a particular object class name.
   *
   * @param ocName the object class name to look up
   * @return a corresponding editor, or null if none exists.
   */
  PluggableEditor getEditor(String ocName) {
    ocName = ocName.toLowerCase();

    Object editorFromHash = editors.get(PACKAGEPREFIX + ocName);

    if (editorFromHash != null)
      return castToPluggableEditor(editorFromHash, ocName); // get it from storage

    return loadEditorFromDisk(PACKAGEPREFIX + ocName); // may be null
  }
Esempio n. 18
0
 /**
  * @param colIndex TableModel column index
  * @return TableModel column name
  */
 public final String getFieldName(int colIndex) {
   String attributeName = (String) indexes.get(new Integer(colIndex));
   if (attributeName == null)
     Logger.error(
         this.getClass().getName(),
         "getFieldName",
         "No attribute found for index " + colIndex + ".",
         null);
   return attributeName;
 }
Esempio n. 19
0
    public org.omg.CORBA.Contained[] lookup_name( String search_name, 
                                                  int levels_to_search, 
                                                  org.omg.CORBA.DefinitionKind limit_type, 
                                                  boolean exclude_inherited )
    {
        if( levels_to_search == 0 )
            return null;

        org.omg.CORBA.Contained[] c = contents( limit_type, exclude_inherited );
        Hashtable found = new Hashtable();

        for( int i = 0; i < c.length; i++)
            if( c[i].name().equals( search_name ) )
                found.put( c[i], "" );

        if( levels_to_search > 1 || levels_to_search == -1 )
        {
            // search up to a specific depth or undefinitely
            for( int i = 0; i < c.length; i++)
            {
                if( c[i] instanceof org.omg.CORBA.Container )
                {
                    org.omg.CORBA.Contained[] tmp_seq = 
                        ((org.omg.CORBA.Container)c[i]).lookup_name( search_name, 
                                                                     levels_to_search-1, 
                                                                     limit_type, 
                                                                     exclude_inherited);
                    if( tmp_seq != null )
                        for( int j = 0; j < tmp_seq.length; j++)
                            found.put( tmp_seq[j], "" );
                }
            } 			
        }

		
        org.omg.CORBA.Contained[] result = new org.omg.CORBA.Contained[ found.size() ];
        int idx = 0;

        for( Enumeration e = found.keys(); e.hasMoreElements(); )
            result[ idx++] = (org.omg.CORBA.Contained)e.nextElement();

        return result;
    }
Esempio n. 20
0
  private static Class getAdapterClass(
      Scriptable scope, Class superClass, Class[] interfaces, Scriptable obj) {
    ClassCache cache = ClassCache.get(scope);
    Hashtable generated = cache.javaAdapterGeneratedClasses;

    ObjToIntMap names = getObjectFunctionNames(obj);
    JavaAdapterSignature sig;
    sig = new JavaAdapterSignature(superClass, interfaces, names);
    Class adapterClass = (Class) generated.get(sig);
    if (adapterClass == null) {
      String adapterName = "adapter" + cache.newClassSerialNumber();
      byte[] code = createAdapterCode(names, adapterName, superClass, interfaces, null);

      adapterClass = loadAdapterClass(adapterName, code);
      if (cache.isCachingEnabled()) {
        generated.put(sig, adapterClass);
      }
    }
    return adapterClass;
  }
 /**
  * Set the current opcode. This sets four global fields: the currentOpcode, the
  * currentOpcodeArgTable, the currentFormat and the currentOpcodeSymbolicNames.
  *
  * @param opcode The IA32 architecture opcode to make the current opcode
  */
 static void setCurrentOpcode(String opcode) {
   try {
     currentOpcode = opcode;
     currentOpcodeArgTable = (int[]) opcodeArgTables.get(opcode);
     currentFormat = OperatorFormatTables.getFormat(opcode);
     Field f = formats.getDeclaredField(currentFormat + "ParameterNames");
     currentOpcodeSymbolicNames = (String[]) f.get(null);
   } catch (Throwable e) {
     throw new Error("Cannot handle Assembler opcode " + opcode, e);
   }
 }
Esempio n. 22
0
  /**
   * Reads the children of an XML element and matches them to properties of a bean.
   *
   * @param ob The bean to receive the values
   * @param element The element the corresponds to the bean
   * @throws IOException If there is an error reading the document
   */
  public void readObject(Object ob, Element element) throws IOException {
    // If the object is null, skip the element
    if (ob == null) {
      return;
    }

    try {
      BeanInfo info = (BeanInfo) beanCache.get(ob.getClass());

      if (info == null) {
        // Get the bean info for the object
        info = Introspector.getBeanInfo(ob.getClass(), Object.class);

        beanCache.put(ob.getClass(), info);
      }

      // Get the object's properties
      PropertyDescriptor[] props = info.getPropertyDescriptors();

      // Get the attributes of the node
      NamedNodeMap attrs = element.getAttributes();

      // Get the children of the XML element
      NodeList nodes = element.getChildNodes();

      int numNodes = nodes.getLength();

      for (int i = 0; i < props.length; i++) {
        // Treat indexed properties a little differently
        if (props[i] instanceof IndexedPropertyDescriptor) {
          readIndexedProperty(ob, (IndexedPropertyDescriptor) props[i], nodes, attrs);
        } else {
          readProperty(ob, props[i], nodes, attrs);
        }
      }
    } catch (IntrospectionException exc) {
      throw new IOException(
          "Error getting bean info for " + ob.getClass().getName() + ": " + exc.toString());
    }
  }
Esempio n. 23
0
  private static Dictionary<String, Object> getDictionary(
      Map<String, Type> types, Map<String, Object> values) throws Exception {
    Hashtable<String, Object> ht = new Hashtable<String, Object>();
    for (Map.Entry<String, Object> e : values.entrySet()) {
      String key = e.getKey();
      Object value = e.getValue();

      Type type;
      if (types != null && (type = types.get(key)) != null) {

        if (type.scalar != null) {
          value = convert(value, type.scalar);
        } else if (type.vectorOf != null) {
          Collection<Object> coll = (Collection<Object>) value;
          Vector vector = new Vector();
          for (Object o : coll) {
            vector.add(convert(o, type.vectorOf));
          }
          value = vector;
        } else if (type.arrayOf != null) {
          if (value instanceof String && type.arrayOf.equals("byte")) {
            value = Base64.decodeBase64((String) value);
          } else {
            Collection<Object> coll = (Collection<Object>) value;
            Object array = Array.newInstance(getClass(type.arrayOf), coll.size());
            int n = 0;
            for (Object o : coll) {
              Array.set(array, n++, convert(o, type.arrayOf));
            }
            value = array;
          }
        } else {
          throw new IllegalArgumentException(
              "Key " + key + " has type but neither scalar, vectorOf, nor arrayOf is set");
        }
      }
      ht.put(key, value);
    }
    return ht;
  }
Esempio n. 24
0
 private OncFilter makeLevelListFilter(Hashtable keywords) {
   // Create a filter
   OncFilter filter = new OncFilter(false);
   OncTreeNode rootNode = filter.getRootNode();
   OncTreeNode orNode = new OncTreeNode(TcapLogicalOperator.OR, Persistible.DO_NOT_SAVE);
   OncTreeNode keywordNode;
   for (Enumeration e = keywords.keys(); e.hasMoreElements(); ) {
     Object obj = e.nextElement();
     if (obj instanceof Keyword) orNode.add(new OncTreeNode(obj, (Persistible.DO_NOT_SAVE)));
   }
   rootNode.add(orNode);
   return filter;
 }
Esempio n. 25
0
  /**
   * When this class is loaded, preload the cache with a few items which we think will often be
   * needed. This can avoid the necessity of running a belief network context in simple problems.
   */
  static {
    System.err.println("PiHelperLoader.static: preload the helper cache.");

    helper_cache = new Hashtable();
    Vector seq = new Vector();

    seq.addElement(riso.distributions.ConditionalDiscrete.class);
    seq.addElement(riso.distributions.Discrete.class);

    helper_cache.put(
        new HelperCacheKey("pi", seq),
        riso.distributions.computes_pi.ConditionalDiscrete_Discrete.class);

    seq = new Vector();
    seq.addElement(riso.distributions.Discrete.class);

    helper_cache.put(
        new HelperCacheKey("lambda", seq), riso.distributions.computes_lambda.Discrete.class);

    seq = new Vector();
    seq.addElement(riso.distributions.AbstractDistribution.class);
    seq.addElement(riso.distributions.AbstractDistribution.class);

    helper_cache.put(
        new HelperCacheKey("pi_message", seq),
        riso.distributions.computes_pi_message.AbstractDistribution_AbstractDistribution.class);

    seq = new Vector();
    seq.addElement(riso.distributions.ConditionalDiscrete.class);
    seq.addElement(riso.distributions.Discrete.class);
    seq.addElement(riso.distributions.Discrete.class);

    helper_cache.put(
        new HelperCacheKey("lambda_message", seq),
        riso.distributions.computes_lambda_message.ConditionalDiscrete_Discrete_Discrete.class);

    seq = new Vector();
    seq.addElement(riso.distributions.ConditionalDiscrete.class);
    seq.addElement(riso.distributions.Discrete.class);

    helper_cache.put(
        new HelperCacheKey("lambda_message", seq),
        riso.distributions.computes_lambda_message.ConditionalDiscrete_Discrete_.class);

    seq = new Vector();
    seq.addElement(riso.distributions.Discrete.class);
    seq.addElement(riso.distributions.Discrete.class);

    helper_cache.put(
        new HelperCacheKey("posterior", seq),
        riso.distributions.computes_posterior.Discrete_Discrete.class);

    System.err.println("PiHelperLoader.static: helper_cache.size(): " + helper_cache.size());
  }
Esempio n. 26
0
  /**
   * Check the helpers currently stored in the helper cache to see if any of them can handle the
   * sequence we've just been given. This avoids pinging the belief network context to get a helper
   * list.
   */
  public static Class find_helper_class1(
      Vector seq, String helper_type, int[] max_class_score, int[] max_count_score)
      throws ClassNotFoundException {
    int[] class_score1 = new int[1], count_score1 = new int[1];
    max_class_score[0] = -1;
    max_count_score[0] = -1;
    Class cmax_score = null;

    for (Enumeration e = helper_cache.keys(); e.hasMoreElements(); ) {
      try {
        HelperCacheKey key = (HelperCacheKey) e.nextElement();
        if (!key.helper_type.equals(helper_type)) continue;
        Class c = (Class) helper_cache.get(key);
        SeqTriple[] sm = (SeqTriple[]) invoke_description(c);
        if (sm == null) continue; // apparently not a helper class
        if (MatchClassPattern.matches(sm, seq, class_score1, count_score1)) {
          if (class_score1[0] > max_class_score[0]
              || (class_score1[0] == max_class_score[0] && count_score1[0] > max_count_score[0])) {
            cmax_score = c;
            max_class_score[0] = class_score1[0];
            max_count_score[0] = count_score1[0];
          }
        }
      } catch (Exception e2) {
      } // eat it; stagger forward
    }

    if (Global.debug > 1)
      System.err.println(
          "PiHelperLoader.find_helper_class1: helper "
              + (cmax_score == null ? "is NOT" : "is")
              + " in cache.");
    if (cmax_score == null) // no luck; try to get a helper list from the bnc & plunge ahead
    return find_helper_class0(seq, helper_type, max_class_score, max_count_score);
    else // success!
    return cmax_score;
  }
  /** Look on disk for an editor with the class name 'ocName'. */
  PluggableEditor loadEditorFromDisk(String ocName) {
    // if here, we need to look on disk for a pluggable editor class...
    log.finer("looking for ocName: " + ocName);
    try {
      Class c = myLoader.loadClass(ocName);
      Constructor constructor = c.getConstructor(new Class[0]);

      // XXX If the pluggable editor has an error in the constructor, under some
      // XXX circumstances it can fail so badly that this call never returns, and
      // XXX the thread hangs!  It doesn't even get to the exception handler below...
      // XXX but sometimes if the constructor fails everything works as expected.  Wierd.
      PluggableEditor editor = (PluggableEditor) constructor.newInstance(new Object[0]);

      editors.put(ocName, editor); // add the new editor to our list
      return editor;
    } catch (Exception e) // expected condition - just means no pluggable editor available
    {
      if (e
          instanceof
          InvocationTargetException) // rare exception - an error was encountered in the plugin's
                                     // constructor.
      {
        log.warning("unable to load special editor for: '" + ocName + "' " + e);
        if (JXConfig.debugLevel >= 1) {
          log.warning("Error loading plugin class: ");
          ((InvocationTargetException) e).getTargetException().printStackTrace();
        }
      }

      log.log(Level.FINEST, "'Expected' Error loading " + ocName, e);
      editors.put(ocName, NONE); // add a blank place holder - we can't load
      // an editor for this, and there's no point looking again. (change if want dynamic loading,
      // i.e. look *every* time)
    }
    return null; // only here if an error has occured.
  }
Esempio n. 28
0
    public org.omg.CORBA.Contained[] contents(org.omg.CORBA.DefinitionKind limit_type, 
                                              boolean exclude_inherited)
    {
        Hashtable limited = new Hashtable();

        // analog constants, exceptions etc.

        for( Enumeration e = contained.elements(); e.hasMoreElements();  )
        {
            org.omg.CORBA.Contained c = (org.omg.CORBA.Contained)e.nextElement();
            if( limit_type == org.omg.CORBA.DefinitionKind.dk_all || 
                limit_type == c.def_kind() )
            {
                limited.put( c, "" );
            }
        }

        org.omg.CORBA.Contained[] c = new org.omg.CORBA.Contained[limited.size()];
        int i;
        Enumeration e;
        for( e = limited.keys(), i=0 ; e.hasMoreElements(); i++ )
            c[i] = (org.omg.CORBA.Contained)e.nextElement();
        return c;			
    }
Esempio n. 29
0
  /**
   * Will add a new security constraint: For all paths: if( match(path) && match(method) && match(
   * transport ) ) then require("roles")
   *
   * <p>This is equivalent with adding a Container with the path, method and transport. If the
   * container will be matched, the request will have to pass the security constraints.
   */
  public void addSecurityConstraint(
      String path[], String methods[], String roles[], String transport) throws TomcatException {
    for (int i = 0; i < path.length; i++) {
      Container ct = new Container();
      ct.setContext(this);
      ct.setTransport(transport);
      ct.setRoles(roles);
      ct.setPath(path[i]);
      ct.setMethods(methods);

      // XXX check if exists, merge if true.
      constraints.put(path[i], ct);
      // contextM.addSecurityConstraint( this, path[i], ct);
      contextM.addContainer(ct);
    }
  }
Esempio n. 30
0
    public void define()
    {
        org.jacorb.util.Debug.output(2, "Struct " + name +  " defining...");
        for( Enumeration e = containedLocals.elements();
             e.hasMoreElements();
             ((IRObject)e.nextElement()).define())
            ;

        for( int i = 0; i < members.length; i++ )
        {
            members[i].type_def = IDLType.create( members[i].type, containing_repository);
            org.jacorb.util.Debug.assert( members[i].type_def != null,
                                      "No type_def for member " + members[i].name + 
                                      " in struct " +  full_name );
        }
        defined = true;
        org.jacorb.util.Debug.output(2, "Struct " + name +  " defined");

    }