⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 corehandler.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            return doGetInvoke(cmd, pubSessionId.substring(1), subjectInfo, I_AdminSubject.class);         }         String sessionAttr = cmd.getSessionAttrLevel();         if (sessionAttr == null || sessionAttr.length() < 1 || sessionAttr.startsWith("?")==false)            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid session attribute in '" + cmd.getCommand() + "'.");         if (sessionAttr.startsWith("?")) {            // for example "client/joe/ses17/?queue/callback/maxEntries"            I_AdminSession sessionInfo = subjectInfo.getSessionByPubSessionId(Long.parseLong(pubSessionId));            if (sessionInfo == null)               throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "The public session ID '" + pubSessionId + "' in '" + cmd.getCommand() + "' is unknown.");            return doGetInvoke(cmd, sessionAttr.substring(1), sessionInfo, I_AdminSession.class);         }      }      else if (registerKey.equals(ContextNode.TOPIC_MARKER_TAG)) { // "topic"         String topicId = cmd.getUserNameLevel();         if (topicId == null || topicId.length() < 1 || topicId.startsWith("?"))            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid topicId in '" + cmd.getCommand() + "' with '" + topicId + "' is invalid");         TopicHandler topicHandler = this.glob.getTopicAccessor().access(topicId);         if (topicHandler == null)            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid topicId in '" + cmd.getCommand() + "' topicId '" + topicId + "' is unknown");         try {            String methodName = cmd.getFifthLevel();            if (methodName == null || methodName.length() < 1)               throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid method name in '" + cmd.getCommand() + "'.");               if (methodName.startsWith("?")) {               // for example "/node/heron/topic/hello/?topicId"               return doGetInvoke(cmd, methodName.substring(1), topicHandler, I_AdminTopic.class);            }         }         finally {            this.glob.getTopicAccessor().release(topicHandler);         }      }      else if (registerKey.equals(ContextNode.QUEUE_MARKER_TAG)) { // "queue"         String queueId = cmd.getUserNameLevel();         if (queueId == null || queueId.length() < 1 || queueId.startsWith("?"))            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid queueId in '" + cmd.getCommand() + "' with '" + queueId + "' is invalid");         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_NOTIMPLEMENTED, ME, "Administer queue is not implemented");      }      else if (registerKey.equals("map")) {         String mapId = cmd.getUserNameLevel();         if (mapId == null || mapId.length() < 1 || mapId.startsWith("?"))            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid mapId in '" + cmd.getCommand() + "' with '" + mapId + "' is invalid");         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_NOTIMPLEMENTED, ME, "Administer map is not implemented");      }      else if (registerKey.equals(ContextNode.SUBSCRIPTION_MARKER_TAG)) { // "subscription"         String subscriptionId = cmd.getUserNameLevel();         if (subscriptionId == null || subscriptionId.length() < 1 || subscriptionId.startsWith("?"))            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid subscriptionId in '" + cmd.getCommand() + "' with '" + subscriptionId + "' is invalid");         SubscriptionInfo subscriptionInfo = glob.getRequestBroker().getClientSubscriptions().getSubscription(subscriptionId);         if (subscriptionInfo == null)            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid subscriptionId in '" + cmd.getCommand() + "' subscriptionId '" + subscriptionId + "' is unknown");         String methodName = cmd.getFifthLevel();         if (methodName == null || methodName.length() < 1)            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid method name in '" + cmd.getCommand() + "'.");         if (methodName.startsWith("?")) {            // for example "/node/heron/subscription/__subId:3/?topicId"            return doGetInvoke(cmd, methodName.substring(1), subscriptionInfo, I_AdminSubscription.class);         }      }      log.info(cmd.getCommand() + " not implemented");      return new MsgUnit[0];   }   /**    * Set a value.     */   public String set(AddressServer addressServer, String sessionId, CommandWrapper cmd) throws XmlBlasterException {      if (cmd == null)         throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which is not null");      String client = cmd.getThirdLevel();      if (client == null || client.length() < 1)         throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid property added, '" + cmd.getCommand() + "' is invalid, aborted request.");      if (client.startsWith("?")) {         // for example "/node/heron/?freeMem"         /*String ret = ""+*/setInvoke(cmd.getKey(), glob.getRequestBroker(), I_AdminNode.class, cmd.getArgs());         log.info("Set " + cmd.getCommandStripAssign() + "=" + cmd.getArgsString());         return cmd.getArgsString();      }      String loginName = cmd.getUserNameLevel();      if (loginName == null || loginName.length() < 1 || loginName.startsWith("?"))         throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid client name in '" + cmd.getCommand() + "' with '" + loginName + "' is invalid");      I_AdminSubject subjectInfo = glob.getAuthenticate().getSubjectInfoByName(new SessionName(glob, loginName));      if (subjectInfo == null)         throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid client name in '" + cmd.getCommand() + "' client '" + loginName + "' is unknown");      String pubSessionId = cmd.getSessionIdLevel();      if (pubSessionId == null || pubSessionId.length() < 1)         throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid public session ID in '" + cmd.getCommand() + "'.");      if (pubSessionId.startsWith("?")) {         // for example "/node/heron/joe/?uptime"         /*String ret = ""+*/setInvoke(cmd.getKey(), subjectInfo, I_AdminSubject.class, cmd.getArgs());         log.info("Set " + cmd.getCommandStripAssign() + "=" + cmd.getArgsString());         return cmd.getArgsString();      }      String sessionAttr = cmd.getSessionAttrLevel();      if (sessionAttr == null || sessionAttr.length() < 1 || sessionAttr.startsWith("?")==false)         throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "Please pass a command which has a valid session attribute in '" + cmd.getCommand() + "'.");      if (sessionAttr.startsWith("?")) {         // for example "client/joe/ses17/?queue/callback/maxEntries"         I_AdminSession sessionInfo = subjectInfo.getSessionByPubSessionId(Long.parseLong(pubSessionId));         if (sessionInfo == null)            throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME, "The public session ID '" + pubSessionId + "' in '" + cmd.getCommand() + "' is unknown.");         /*String ret = ""+*/setInvoke(cmd.getKey(), sessionInfo, I_AdminSession.class, cmd.getArgs());         log.info("Set " + cmd.getCommandStripAssign() + "=" + cmd.getArgsString());         return cmd.getArgsString();      }      log.info(cmd.getCommand() + " not implemented");      return null;   }   /**    * @param property e.g. "uptime", the method "getUptime()" will be called    * @param aClass e.g. I_AdminSubject.class    * @return Object typically of type String or String[]    */   /*   private Object getInvoke(String property, Object impl, Class aInterface, QueryKeyData XXkeyData, QueryQosData qosData)       throws XmlBlasterException {      String methodName = null;      if (property == null || property.length() < 2)         throw new XmlBlasterException(glob, ErrorCode.USER_ILLEGALARGUMENT, ME,                   "Please pass a vaild command, aborted request.");      try {         Invoker invoker = new Invoker(glob, impl, aInterface);         methodName = "get" + property.substring(0,1).toUpperCase() + property.substring(1);         Object obj = invoker.execute(methodName, qosData, keyData);         if (log.isLoggable(Level.FINE)) log.trace(ME, "Return for '" + methodName + "' is '" + obj + "'");         return obj;         // This code worked only when a corresponding setXXX() was specified:         //PropertyDescriptor desc = new PropertyDescriptor(property, aClass);         //Method method = desc.getReadMethod();         ////Object[] argValues = new Object[0];         //Object returnValue = method.invoke (impl, null); //argValues);         //log.info(ME, "Invoke method '" + property + "' return=" + returnValue + " class=" + returnValue.getClass());         //return returnValue;      }      catch (Exception e1) {         log.trace(ME, "Invoke for get method '" + methodName + "' on class=" + aInterface + " on object=" + impl.getClass() + " failed: " + e1.toString());         try {            // Check if there is a 'operation' method to be called,            // instead of getXY() call XY():            Method method = aInterface.getDeclaredMethod(property, new Class[0]); // NoSuchMethodException             Object returnValue = method.invoke (impl, null); //argValues);            log.info(ME, "Invoke method '" + property + "' return=" + returnValue);            return returnValue;         }         catch (Exception e) {            //e.printStackTrace();            log.warn(ME, "Invoke for get method '" + methodName + "' on class=" + aInterface + " on object=" + impl.getClass() + " failed: " + e.toString());            throw XmlBlasterException.convert(glob, ME, "Invoke for get method '" + property + "' on class=" + aInterface + " on object=" + impl.getClass() + " failed", e);         }      }   }   */   private Object[] convertMethodArguments(Class[] classes, String[] args)       throws XmlBlasterException {      if (args == null) return new Object[0];      if (classes.length != args.length) {         throw new XmlBlasterException(this.glob, ErrorCode.USER_ILLEGALARGUMENT, ME + ".convertMethodArguments", "wrong number of arguments: '" + args.length + "' but should be '" + classes.length + "'");      }      Object[] ret = new Object[classes.length];      for (int i=0; i < classes.length; i++) {         if (classes[i] == String.class) ret[i] = args[i];         else if (classes[i] == Boolean.TYPE || classes[i] == Boolean.class) {            try {               ret[i] = Boolean.valueOf(args[i]);              }            catch (Throwable ex) {               throw new XmlBlasterException(this.glob, ErrorCode.USER_ILLEGALARGUMENT, ME + ".convertMethodArguments", "wrong type of argument nr. '" + (i+1) + "' should be of type '" + classes[i].getName() + "' but its value is '" + args[i] + "'");            }         }                  else if (classes[i] == Short.TYPE || classes[i] == Short.class) {            try {               ret[i] = Short.valueOf(args[i]);              }            catch (Throwable ex) {               throw new XmlBlasterException(this.glob, ErrorCode.USER_ILLEGALARGUMENT, ME + ".convertMethodArguments", "wrong type of argument nr. '" + (i+1) + "' should be of type '" + classes[i].getName() + "' but its value is '" + args[i] + "'");            }         }                  else if (classes[i] == Integer.TYPE || classes[i] == Integer.class) {            try {               ret[i] = Integer.valueOf(args[i]);              }            catch (Throwable ex) {               throw new XmlBlasterException(this.glob, ErrorCode.USER_ILLEGALARGUMENT, ME + ".convertMethodArguments", "wrong type of argument nr. '" + (i+1) + "' should be of type '" + classes[i].getName() + "' but its value is '" + args[i] + "'");            }         }         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -