Package org.jboss.util

Examples of org.jboss.util.JBossStringBuilder


               if (ctx.getState().equals(ControllerState.ERROR))
                  errors.add(ctx);
               else
                  incomplete.add(ctx);
            }
            JBossStringBuilder buffer = new JBossStringBuilder();
            buffer.append("Incompletely deployed:\n");
            if (errors.size() != 0)
            {
               buffer.append("\nDEPLOYMENTS IN ERROR:\n");
               for (ControllerContext ctx : errors)
               {
                  buffer.append(String.format("  Deployment \"%s\" is in error due to: %s\n", ctx.getName(), ctx.getError()));
               }
            }
            if (incomplete.size() != 0)
            {
               buffer.append("\nDEPLOYMENTS MISSING DEPENDENCIES:\n");
               for (ControllerContext ctx : incomplete)
               {
                  Object name = ctx.getName();
                  buffer.append(String.format("  Deployment \"%s\" is missing the following dependencies:\n", name));
                  DependencyInfo dependsInfo = ctx.getDependencyInfo();
                  Set<DependencyItem> depends = dependsInfo.getIDependOn(null);
                  for (DependencyItem item : depends)
                  {
                     ControllerState dependentState = item.getDependentState();
                     if (dependentState == null)
                        dependentState = ControllerState.INSTALLED;
                    
                     ControllerState otherState = null;
                     ControllerContext other = null;
                     Object iDependOn = item.getIDependOn();

                     if (name.equals(iDependOn) == false)
                     {
                        if (iDependOn != null)
                        {
                           other = controller.getContext(iDependOn, null);
                           if (other != null)
                              otherState = other.getState();
                        }

                        boolean print = true;
                        if (otherState != null && otherState.equals(ControllerState.ERROR) == false)
                        {
                           ControllerStateModel states = controller.getStates();
                           if (states.isBeforeState(otherState, dependentState) == false)
                              print = false;
                        }

                        if (print)
                        {
                           buffer.append(String.format("    Dependency \"%s\" (should be in state \"%s\", but is actually %s)\n",
                                   iDependOn,
                                   dependentState.getStateString(),
                                   iDependOn == null ?
                                           String.format("unresolved (%s)",
                                           item.toHumanReadableString()) :
                                           other == null ?
                                                   "not found" :
                                                   String.format("in state \"%s\"", otherState.getStateString())));
                        }
                     }
                  }
               }
            }
            throw new IllegalStateException(buffer.toString());
         }
      }
   }
View Full Code Here


      Locator locator = delegateHandler.getDocumentLocator();
      if (locator == null)
         return fileName;
      else
      {
         JBossStringBuilder buffer = new JBossStringBuilder();
         String id = locator.getSystemId();
         if (id == null)
            id = locator.getPublicId();
         buffer.append(id).append('@');
         buffer.append(locator.getLineNumber());
         buffer.append(',');
         buffer.append(locator.getColumnNumber());
         return buffer.toString();
      }
   }
View Full Code Here

      buffer.append(jndiName);
   }
   @Override
   public String toShortString()
   {
      JBossStringBuilder buffer = new JBossStringBuilder();
      toShortString(buffer);
      return buffer.toString();
   }
View Full Code Here

      return jndiNames;
   }

   public String toShortString()
   {
      JBossStringBuilder buffer = new JBossStringBuilder();
      toShortString(buffer);
      return buffer.toString();
   }
View Full Code Here

               if (ctx.getState().equals(ControllerState.ERROR))
                  errors.add(ctx);
               else
                  incomplete.add(ctx);
            }
            JBossStringBuilder buffer = new JBossStringBuilder();
            buffer.append("Incompletely deployed:\n");
            if (errors.size() != 0)
            {
               buffer.append("\nDEPLOYMENTS IN ERROR:\n");
               for (ControllerContext ctx : errors)
               {
                  buffer.append(String.format("  Deployment \"%s\" is in error due to: %s\n", ctx.getName(), ctx.getError()));
               }
            }
            if (incomplete.size() != 0)
            {
               buffer.append("\nDEPLOYMENTS MISSING DEPENDENCIES:\n");
               for (ControllerContext ctx : incomplete)
               {
                  Object name = ctx.getName();
                  buffer.append(String.format("  Deployment \"%s\" is missing the following dependencies:\n", name));
                  DependencyInfo dependsInfo = ctx.getDependencyInfo();
                  Set<DependencyItem> depends = dependsInfo.getIDependOn(null);
                  for (DependencyItem item : depends)
                  {
                     ControllerState dependentState = item.getDependentState();
                     if (dependentState == null)
                        dependentState = ControllerState.INSTALLED;
                    
                     ControllerState otherState = null;
                     ControllerContext other = null;
                     Object iDependOn = item.getIDependOn();

                     if (name.equals(iDependOn) == false)
                     {
                        if (iDependOn != null)
                        {
                           other = controller.getContext(iDependOn, null);
                           if (other != null)
                              otherState = other.getState();
                        }

                        boolean print = true;
                        if (otherState != null && otherState.equals(ControllerState.ERROR) == false)
                        {
                           ControllerStateModel states = controller.getStates();
                           if (states.isBeforeState(otherState, dependentState) == false)
                              print = false;
                        }

                        if (print)
                        {
                           buffer.append(String.format("    Dependency \"%s\" (should be in state \"%s\", but is actually %s)\n",
                                   iDependOn,
                                   dependentState.getStateString(),
                                   iDependOn == null ?
                                           String.format("unresolved (%s)",
                                           item.toHumanReadableString()) :
                                           other == null ?
                                                   "not found" :
                                                   String.format("in state \"%s\"", otherState.getStateString())));
                        }
                     }
                  }
               }
            }
            throw new IllegalStateException(buffer.toString());
         }
      }
   }
View Full Code Here

      return txRepository.getPreparedTransactions();
   }
  
   public String showMessageDetails(Long msgId) throws Exception
   {
      JBossStringBuilder buffer = new JBossStringBuilder();
      buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
     
      buffer.append("<tr>");
      buffer.append("<th>message_id</th>");
      buffer.append("<th>expiration</th>");
      buffer.append("<th>timestamp</th>");
      buffer.append("<th>priority</th>");
      buffer.append("<th>type</th>");
      buffer.append("<th>headers</th>");
      buffer.append("<th>payload</th>");
      buffer.append("<th>payload type</th>");
      buffer.append("</tr>");
     
      List<Long> ids = new ArrayList<Long>();
      ids.add(msgId);
      List msgs = persistenceManager.getMessages(ids);
      Iterator msgIter = msgs.iterator();
      while (msgIter.hasNext())
      {
         Message m = (Message)msgIter.next();
         buffer.append("<tr>");
         buffer.append("<td>" + m.getMessageID() + "</td>");
         buffer.append("<td>" + m.getExpiration() + "</td>");
         buffer.append("<td>" + new Date(m.getTimestamp()) + "</td>");
         buffer.append("<td>" + m.getPriority() + "</td>");
         buffer.append("<td>" + m.getType() + "</td>");
         buffer.append("<td>" + m.getHeaders() + "</td>");
         buffer.append("<td>" + m.getPayload() + "</td>");
         buffer.append("<td>" + m.getPayload().getClass().getName() + "</td>");
         buffer.append("</tr>");
      }
     
      return buffer.toString();
   }
View Full Code Here

      return buffer.toString();
   }

   public String listAllPreparedTransactions() throws Exception
   {
      JBossStringBuilder buffer = new JBossStringBuilder();
      buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
     
      buffer.append("<tr>");
      buffer.append("<th>transaction_id</th>");
      buffer.append("<th>branch_qual</th>");
      buffer.append("<th>format_id</th>");
      buffer.append("<th>global_txid</th>");
      buffer.append("<th>elapsed_time</th>");
      buffer.append("<th>queue_name (channel_id)</th>");
      buffer.append("<th>message_id (state)</th>");
      buffer.append("</tr>");
     
      List txs = txRepository.listPreparedTransactions();
      Iterator ittx = txs.iterator();
     
      while (ittx.hasNext())
      {
         Transaction tx = (Transaction)ittx.next();
         Xid xid = tx.getXid();
         long tid = tx.getId();
         String stid = String.valueOf(tid);
         String hexGlobalTxid = new String(xid.getGlobalTransactionId());
         String hexBranchQual = new String(xid.getBranchQualifier());
         String hexFormatId = String.valueOf(xid.getFormatId());
        
         Map<String, List<String>> qInfo = new HashMap<String, List<String>>();
        
         List msgList1 = persistenceManager.getMessageChannelPairRefsForTx(tid);
         List msgList2 = persistenceManager.getMessageChannelPairAcksForTx(tid);
        
         Iterator mIter1 = msgList1.iterator();
         while (mIter1.hasNext())
         {
            MessageChannelPair pair = (MessageChannelPair)mIter1.next();
            Binding binding = postOffice.getBindingForChannelID(pair.getChannelId());
            String qname = binding.queue.getName();
            Long chid = binding.queue.getChannelID();
            String qkey = qname + " (" + chid + ")";
            List<String> msgs = qInfo.get(qkey);
            if (msgs == null)
            {
               msgs = new ArrayList<String>();
               qInfo.put(qkey, msgs);
            }
            msgs.add(String.valueOf(pair.getMessage().getMessageID()) + " (+)");
         }
        
         Iterator mIter2 = msgList2.iterator();
         while (mIter2.hasNext())
         {
            MessageChannelPair pair = (MessageChannelPair)mIter2.next();
            Binding binding = postOffice.getBindingForChannelID(pair.getChannelId());
            String qname = binding.queue.getName();
            Long chid = binding.queue.getChannelID();
            String qkey = qname + " (" + chid + ")";
            List<String> msgs = qInfo.get(qkey);
            if (msgs == null)
            {
               msgs = new ArrayList<String>();
               qInfo.put(qkey, msgs);
            }
            msgs.add(String.valueOf(pair.getMessage().getMessageID()) + " (-)");
         }

         buffer.append("<tr>");
         buffer.append("<td>" + stid + "</td>");
         buffer.append("<td>" + hexBranchQual + "</td>");
         buffer.append("<td>" + hexFormatId + "</td>");
         buffer.append("<td>" + hexGlobalTxid + "</td>");
         long age = tx.getAge();
         if ((!this.supportsTxAge) || age == Long.MIN_VALUE)
         {
            buffer.append("<td>N/A</td>");
         }
         else
         {
            buffer.append("<td>" + tx.getAge() + "</td>");
         }
        
         StringBuffer sbq = new StringBuffer();
         StringBuffer sbm = new StringBuffer();
        
         Iterator<String> itqs = qInfo.keySet().iterator();
         while (itqs.hasNext())
         {
            String qname = itqs.next();
            sbq.append(qname);
           
            List<String> msgs = qInfo.get(qname);
            for (String m : msgs)
            {
               sbq.append("<br/>");
               sbm.append(m);
               sbm.append("<br/>");
            }
         }
        
         buffer.append("<td>");
         buffer.append(sbq.toString());
         buffer.append("</td>");
        
         buffer.append("<td>");
         buffer.append(sbm.toString());
         buffer.append("</td>");
        
         buffer.append("</tr>");
      }
     
      buffer.append("</table>");
      return buffer.toString();
   }
View Full Code Here

   }

   public String listPreparedTransactions(Long elapsedTime) throws Exception
   {
      if (elapsedTime == null) elapsedTime = 0l;
      JBossStringBuilder buffer = new JBossStringBuilder();
      buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
     
      buffer.append("<tr>");
      buffer.append("<th>transaction_id</th>");
      buffer.append("<th>branch_qual</th>");
      buffer.append("<th>format_id</th>");
      buffer.append("<th>global_txid</th>");
      buffer.append("<th>elapsed_time</th>");
      buffer.append("<th>queue_name (channel_id)</th>");
      buffer.append("<th>message_id (state)</th>");
      buffer.append("</tr>");
     
      List txs = txRepository.listPreparedTransactions(elapsedTime);
      Iterator ittx = txs.iterator();
     
      while (ittx.hasNext())
      {
         Transaction tx = (Transaction)ittx.next();
         Xid xid = tx.getXid();
         long tid = tx.getId();
         String stid = String.valueOf(tid);
         String hexGlobalTxid = new String(xid.getGlobalTransactionId());
         String hexBranchQual = new String(xid.getBranchQualifier());
         String hexFormatId = String.valueOf(xid.getFormatId());
        
         Map<String, List<String>> qInfo = new HashMap<String, List<String>>();
        
         List msgList1 = persistenceManager.getMessageChannelPairRefsForTx(tid);
         List msgList2 = persistenceManager.getMessageChannelPairAcksForTx(tid);
        
         Iterator mIter1 = msgList1.iterator();
         while (mIter1.hasNext())
         {
            MessageChannelPair pair = (MessageChannelPair)mIter1.next();
            Binding binding = postOffice.getBindingForChannelID(pair.getChannelId());
            String qname = binding.queue.getName();
            Long chid = binding.queue.getChannelID();
            String qkey = qname + " (" + chid + ")";
            List<String> msgs = qInfo.get(qkey);
            if (msgs == null)
            {
               msgs = new ArrayList<String>();
               qInfo.put(qkey, msgs);
            }
            msgs.add(String.valueOf(pair.getMessage().getMessageID()) + " (+)");
         }
        
         Iterator mIter2 = msgList2.iterator();
         while (mIter2.hasNext())
         {
            MessageChannelPair pair = (MessageChannelPair)mIter2.next();
            Binding binding = postOffice.getBindingForChannelID(pair.getChannelId());
            String qname = binding.queue.getName();
            Long chid = binding.queue.getChannelID();
            String qkey = qname + " (" + chid + ")";
            List<String> msgs = qInfo.get(qkey);
            if (msgs == null)
            {
               msgs = new ArrayList<String>();
               qInfo.put(qkey, msgs);
            }
            msgs.add(String.valueOf(pair.getMessage().getMessageID()) + " (-)");
         }

         buffer.append("<tr>");
         buffer.append("<td>" + stid + "</td>");
         buffer.append("<td>" + hexBranchQual + "</td>");
         buffer.append("<td>" + hexFormatId + "</td>");
         buffer.append("<td>" + hexGlobalTxid + "</td>");
         long age = tx.getAge();
         if (age == Long.MIN_VALUE)
         {
            buffer.append("<td>N/A</td>");
         }
         else
         {
            buffer.append("<td>" + tx.getAge() + "</td>");
         }
        
         StringBuffer sbq = new StringBuffer();
         StringBuffer sbm = new StringBuffer();
        
         Iterator<String> itqs = qInfo.keySet().iterator();
         while (itqs.hasNext())
         {
            String qname = itqs.next();
            sbq.append(qname);
           
            List<String> msgs = qInfo.get(qname);
            for (String m : msgs)
            {
               sbq.append("<br/>");
               sbm.append(m);
               sbm.append("<br/>");
            }
         }
        
         buffer.append("<td>");
         buffer.append(sbq.toString());
         buffer.append("</td>");
        
         buffer.append("<td>");
         buffer.append(sbm.toString());
         buffer.append("</td>");
        
         buffer.append("</tr>");
      }
     
      buffer.append("</table>");
      return buffer.toString();
   }
View Full Code Here

   }

   public String showPreparedTransactionsAsHTML()
   {
      List txs = txRepository.getPreparedTransactions();
      JBossStringBuilder buffer = new JBossStringBuilder();
      buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
      buffer.append("<tr><th>Xid</th></tr>");
      for (Iterator i = txs.iterator(); i.hasNext();)
      {
         Xid xid = (Xid)i.next();
         if (xid != null)
         {
            buffer.append("<tr><td>");
            buffer.append(xid);
            buffer.append("</td></tr>");
         }
      }
      buffer.append("</table>");
      return buffer.toString();
   }
View Full Code Here

               if (ctx.getState().equals(ControllerState.ERROR))
                  errors.add(ctx);
               else
                  incomplete.add(ctx);
            }
            JBossStringBuilder buffer = new JBossStringBuilder();
            buffer.append("Incompletely deployed:\n");
            if (errors.size() != 0)
            {
               buffer.append("\n*** DEPLOYMENTS IN ERROR: Name -> Error\n");
               for (ControllerContext ctx : errors)
               {
                  buffer.append(ctx.getName()).append(" -> ").append(ctx.getError().toString()).append('\n');
               }
            }
            if (incomplete.size() != 0)
            {
               buffer.append("\n*** DEPLOYMENTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}\n");
               for (ControllerContext ctx : incomplete)
               {
                  buffer.append(ctx.getName()).append(" -> ");
                  DependencyInfo dependsInfo = ctx.getDependencyInfo();
                  Set depends = dependsInfo.getIDependOn(null);
                  for (Iterator j = depends.iterator(); j.hasNext();)
                  {
                     DependencyItem item = (DependencyItem)j.next();
                     buffer.append(item.getIDependOn()).append('{').append(item.getWhenRequired().getStateString());
                     buffer.append(':');
                     Object iDependOn = item.getIDependOn();
                     if (iDependOn == null)
                     {
                        // FIXME needs to print something better than item.toString()
                        buffer.append("** UNRESOLVED " + item + " **");
                     }
                     else
                     {
                        ControllerContext other = controller.getContext(item.getIDependOn(), null);
                        if (other == null)
                           buffer.append("** NOT FOUND **");
                        else
                           buffer.append(other.getState().getStateString());
                     }
                     buffer.append('}');
                     if (j.hasNext())
                        buffer.append(", ");
                  }
                  buffer.append('\n');
               }
            }
            throw new IllegalStateException(buffer.toString());
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.util.JBossStringBuilder

Copyright © 2018 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.