Package java.util

Examples of java.util.Iterator


   * @throws HibernateException
   */
  protected synchronized void initDataSource(Properties props) throws HibernateException {
    String dataSourceClass = null;
    Properties new_props = new Properties();
    Iterator keys = props.keySet().iterator();
    while(keys.hasNext()){
      String key = (String)keys.next();
      //System.out.println(key+"="+props.getProperty(key));
      if(ENCODING_KEY.equalsIgnoreCase(key)){
        encoding = "true".equalsIgnoreCase(props.getProperty(key));
        useProxy = true;
      }
View Full Code Here


        q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
        if(user != null)
          q.setInteger("user", user.getId());
      }
      int total = 0;
      Iterator logs = q.list().iterator();
      while(logs.hasNext()){
        tempCal.setTime((Date)logs.next());
        int date = tempCal.get(Calendar.DATE);
        logCounts[date]++;
        total ++;
      }
     
View Full Code Here

* @throws IOException
*/
    protected boolean writeMarkupAttributes(Properties markup)
    throws IOException {
      if (markup == null) return false;
      Iterator attributeIterator = markup.keySet().iterator();
      String name;
      while (attributeIterator.hasNext()) {
        name = String.valueOf(attributeIterator.next());
        write(name, markup.getProperty(name));
      }
      markup.clear();
      return true;
    }
View Full Code Here

                    cmd.getPackageMetaData().addSequence(seqmd);
                }

                if (indices != null)
                {
                    Iterator iter = indices.iterator();
                    while (iter.hasNext())
                    {
                        IndexMetaData idxmd = (IndexMetaData)iter.next();
                        idxmd.setParent(cmd);
                        cmd.addIndex(idxmd);
                    }
                }
                if (uniqueKeys != null)
                {
                    Iterator iter = uniqueKeys.iterator();
                    while (iter.hasNext())
                    {
                        UniqueMetaData unimd = (UniqueMetaData)iter.next();
                        unimd.setParent(cmd);
                        cmd.addUniqueConstraint(unimd);
                    }
                }
                if (fks != null)
                {
                    Iterator iter = fks.iterator();
                    while (iter.hasNext())
                    {
                        ForeignKeyMetaData fkmd = (ForeignKeyMetaData)iter.next();
                        fkmd.setParent(cmd);
                        cmd.addForeignKey(fkmd);
                    }
                }
                if (unmappedColumns != null)
                {
                    Iterator iter = fks.iterator();
                    while (iter.hasNext())
                    {
                        ColumnMetaData colmd = (ColumnMetaData)iter.next();
                        colmd.setParent(cmd);
                        cmd.addUnmappedColumn(colmd);
                    }
                }
                if (extensions != null)
                {
                    Iterator<ExtensionMetaData> iter = extensions.iterator();
                    while (iter.hasNext())
                    {
                        ExtensionMetaData extmd = iter.next();
                        cmd.addExtension(extmd.getVendorName(), extmd.getKey(), extmd.getValue());
                    }
                }
            }
        }
View Full Code Here

   * @return true if removed.
   */
  private static boolean removeInterceptor(String interceptorClassName, List interceptors) {
    boolean removed = false;
    if (interceptorClassName != null) {
      Iterator it = interceptors.iterator();
      while (it.hasNext()) {
        if (interceptorClassName.equals(it.next().getClass().getName())) {
          removed=true;
          it.remove();
          break;
        }
      }
    }
    return removed;
View Full Code Here

    if (newInterceptorClassName != null && oldInterceptorClassName != null && interceptors != null) {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "replaceInterceptor(" + newInterceptorClassName + ", " + oldInterceptorClassName + ", " + interceptors + ')');
      try {
        boolean replaced = false;
        Iterator it = interceptors.iterator();
        while (it.hasNext()) {
          MessageInterceptor oldMI = (MessageInterceptor) it.next();
          if (oldInterceptorClassName.equals(oldMI.getClass().getName())) {
            int index = interceptors.indexOf(oldMI);
            interceptors.remove(index);
            interceptors.add(index, (MessageInterceptor)Class.forName(newInterceptorClassName).newInstance());
            if (logger.isLoggable(BasicLevel.DEBUG))
View Full Code Here

  public static String getListInterceptors(List interceptors) {
    if (interceptors != null) {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "getListInterceptors(" + interceptors + ')');
      StringBuffer buff = new StringBuffer();
      Iterator it = interceptors.iterator();
      while (it.hasNext()) {
        MessageInterceptor messageInterceptor = (MessageInterceptor) it.next();
        buff.append(messageInterceptor.getClass().getName());
        if (it.hasNext()) buff.append(INTERCEPTOR_CLASS_NAME_SEPARATOR);
      }
      return buff.toString();
    }
    return null;
  }
View Full Code Here

        int diff = 0;
        if (srvInfo.messagesToAck.size() > 0) {
          MessageAndIndex msgi = (MessageAndIndex) srvInfo.messagesToAck.getFirst();
          diff = msgi.index - 2;
        }
        Iterator iterMessages = srvInfo.messagesToAck.iterator();
        MessageAndIndex msgi = null;
       
        long currentTimeMillis = System.currentTimeMillis();
        while (iterMessages.hasNext()) {
          msgi = (MessageAndIndex) iterMessages.next();
         
          if ((msgi.msg.not.expiration > 0L)
              && (msgi.msg.not.expiration < currentTimeMillis)) {
            if (msgi.msg.not.deadNotificationAgentId != null) {
              if (logmon.isLoggable(BasicLevel.DEBUG)) {
                logmon.log(BasicLevel.DEBUG, getName() + ": forward expired notification1 "
                    + msgi.msg.from + ", " + msgi.msg.not + " to "
                    + msgi.msg.not.deadNotificationAgentId);
              }
              AgentServer.getTransaction().begin();
              Channel.post(Message.alloc(AgentId.localId, msgi.msg.not.deadNotificationAgentId,
                  new ExpiredNot(msgi.msg.not, msgi.msg.from, msgi.msg.to)));
              Channel.validate();
              AgentServer.getTransaction().commit(true);
            } else {
              if (logmon.isLoggable(BasicLevel.DEBUG)) {
                logmon.log(BasicLevel.DEBUG, getName() + ": removes expired notification "
                    + msgi.msg.from + ", " + msgi.msg.not);
              }
            }
            iterMessages.remove();
            diff += msgi.size;
          }
         
          if (logmon.isLoggable(BasicLevel.DEBUG)) {
            logmon.log(BasicLevel.DEBUG, "Changed index " + msgi.index + "->" + (msgi.index - diff) + " "
View Full Code Here

                  }
                  continue;
                }

                // Re-send the messages
                Iterator iterMessages = servInfo.messagesToAck.iterator();
                while (iterMessages.hasNext()) {
                  try {
                    MessageAndIndex msgi = (MessageAndIndex) iterMessages.next();
                    netServerOut.reSendMessageOutputStream.writeMessage(servInfo, addr, msgi.index,
                        msgi.msg, currentTimeMillis);
                    if (this.logmon.isLoggable(BasicLevel.DEBUG)) {
                      this.logmon.log(BasicLevel.DEBUG, this.getName() + ", re-send message " + msgi.msg);
                    }
View Full Code Here

            qout.pop();
          }
          long currentTimeMillis = System.currentTimeMillis();
          ServerDesc server = null;

          Iterator iterator = sendList.toSendIterator();

          while (iterator.hasNext()) {
            msg = (Message) iterator.next();
            short msgto = msg.getDest();

            if (this.logmon.isLoggable(BasicLevel.DEBUG))
              this.logmon.log(BasicLevel.DEBUG,
                              this.getName() +
                              ", check msg#" + msg.getStamp() +
                              " from " + msg.from +
                              " to " + msg.to);

            if (msg.not.expiration > 0L && msg.not.expiration < currentTimeMillis) {
             
              // Remove the message.
              AgentServer.getTransaction().begin();

              if (msg.not.deadNotificationAgentId != null) {
                if (logmon.isLoggable(BasicLevel.DEBUG)) {
                  logmon.log(BasicLevel.DEBUG, getName() + ": forward expired notification " + msg.from
                      + ", " + msg.not + " to " + msg.not.deadNotificationAgentId);
                }
                ExpiredNot expiredNot = new ExpiredNot(msg.not, msg.from, msg.to);
                Channel.post(Message.alloc(AgentId.localId, msg.not.deadNotificationAgentId, expiredNot));
                Channel.validate();
              } else {
                if (logmon.isLoggable(BasicLevel.DEBUG)) {
                  logmon.log(BasicLevel.DEBUG, getName() + ": removes expired notification " + msg.from + ", "
                      + msg.not);
                }
              }

              // Deletes the processed notification
              iterator.remove();
    // AF: A reprendre.
//               // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
              continue;
            }

            try {
              server = AgentServer.getServerDesc(msgto);
            } catch (UnknownServerException exc) {
              this.logmon.log(BasicLevel.ERROR,
                              this.getName() + ", can't send message: " + msg,
                              exc);
              // Remove the message, may be we have to post an error
              // notification to sender.
              AgentServer.getTransaction().begin();
              // Deletes the processed notification
              iterator.remove();
    // AF: A reprendre.
//              // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
              continue;
            }

            if (servers.contains(server)) {
              // The server has already been tested during this round
              continue;
            }

            this.logmon.log(BasicLevel.DEBUG,
                            this.getName() + server.active + ',' +
                            server.retry + ',' +
                            server.last + ',' +
                            currentTimeMillis);

            if ((server.active) ||
                ((server.retry < WDNbRetryLevel1) &&
                 ((server.last + WDRetryPeriod1) < currentTimeMillis)) ||
                ((server.retry < WDNbRetryLevel2) &&
                 ((server.last + WDRetryPeriod2) < currentTimeMillis)) ||
                ((server.last + WDRetryPeriod3) < currentTimeMillis)) {
              try {
                if (this.logmon.isLoggable(BasicLevel.DEBUG))
                  this.logmon.log(BasicLevel.DEBUG,
                                  this.getName() +
                                  ", send msg#" + msg.getStamp());

                // Open the connection.
                Socket socket = createSocket(server);
                // The connection is ok, reset active and retry flags.
                server.active = true;
                server.retry = 0;
                server.last = currentTimeMillis;

                setSocketOption(socket);

                send(socket, msg, currentTimeMillis);
              } catch (SocketException exc) {
                if (this.logmon.isLoggable(BasicLevel.WARN))
                  this.logmon.log(BasicLevel.WARN,
                                  this.getName() + ", let msg in watchdog list",
                                  exc);
                server.active = false;
                server.retry++;
                server.last = currentTimeMillis;
               
                // Do not send following messages to this server
                servers.add(server);
                //  There is a connection problem, let the message in the
                // waiting list.
                continue;
              } catch (Exception exc) {
                this.logmon.log(BasicLevel.ERROR,
                                this.getName() + ", error", exc);
              }

              AgentServer.getTransaction().begin();
              //  Deletes the processed notification
              iterator.remove();
// AF (TODO): To remove ?
//               // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
View Full Code Here

TOP

Related Classes of java.util.Iterator

Copyright © 2015 www.massapicom. 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.