/** * 构造子查询sql * * @param table * @param refKey * @param ids * @param ordersMap * @param fieldName * @return */ private String buildChildQuerySql( String table, String refKey, StringBuffer ids, Map<String, Orders> ordersMap, String fieldName) { StringBuffer childSql = new StringBuffer(); childSql .append("select * from ") .append(NameConverter.toTableName(Constants.DEFAULT_TABLE_PREFIX, table)) .append(" where ") .append(NameConverter.toColumnName(Constants.DEFAULT_COLUMN_PREFIX, refKey)) .append(" in ("); childSql.append(ids); childSql.append(")"); Orders orders = ordersMap.get(fieldName); if (orders != null && orders.value().length > 0) { childSql.append(" order by "); for (Order order : orders.value()) { childSql .append(NameConverter.toColumnName(Constants.DEFAULT_COLUMN_PREFIX, order.key())) .append(" ") .append(order.order()) .append(","); } childSql.deleteCharAt(childSql.length() - 1); } return childSql.toString(); }
private OpenMBeanParameterInfo[] getParameterInfos(ModelNode opNode) { if (!opNode.hasDefined(REQUEST_PROPERTIES)) { return EMPTY_PARAMETERS; } List<OpenMBeanParameterInfo> params = new ArrayList<OpenMBeanParameterInfo>(); for (Property prop : opNode.get(REQUEST_PROPERTIES).asPropertyList()) { ModelNode value = prop.getValue(); final String paramName = NameConverter.convertToCamelCase(prop.getName()); Map<String, String> descriptions = new HashMap<String, String>(); descriptions.put( DESC_EXPRESSIONS_ALLOWED, String.valueOf( prop.getValue().hasDefined(EXPRESSIONS_ALLOWED) && prop.getValue().get(EXPRESSIONS_ALLOWED).asBoolean())); params.add( new OpenMBeanParameterInfoSupport( paramName, getDescription(prop.getValue()), converters.convertToMBeanType(value), new ImmutableDescriptor(descriptions))); } return params.toArray(new OpenMBeanParameterInfo[params.size()]); }
private String findAttributeName(ModelNode attributes, String attributeName) throws AttributeNotFoundException { if (attributes.hasDefined(attributeName)) { return attributeName; } for (String key : attributes.keys()) { if (NameConverter.convertToCamelCase(key).equals(attributeName)) { return key; } } throw MESSAGES.attributeNotFound(attributeName); }
private OpenMBeanOperationInfo[] getOperations() { final boolean root = pathAddress.size() == 0; // TODO include inherited/global operations? List<OpenMBeanOperationInfo> ops = new ArrayList<OpenMBeanOperationInfo>(); for (Map.Entry<String, OperationEntry> entry : resourceRegistration .getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false) .entrySet()) { final String opName = entry.getKey(); if (opName.equals(ADD) || opName.equals(DESCRIBE)) { continue; } if (root) { if (opName.equals(READ_RESOURCE_OPERATION) || opName.equals(READ_ATTRIBUTE_OPERATION) || opName.equals(READ_RESOURCE_DESCRIPTION_OPERATION) || opName.equals(READ_CHILDREN_NAMES_OPERATION) || opName.equals(READ_CHILDREN_TYPES_OPERATION) || opName.equals(READ_CHILDREN_RESOURCES_OPERATION) || opName.equals(READ_OPERATION_NAMES_OPERATION) || opName.equals(READ_OPERATION_DESCRIPTION_OPERATION) || opName.equals(READ_RESOURCE_OPERATION) || opName.equals(READ_RESOURCE_OPERATION) || opName.equals(WRITE_ATTRIBUTE_OPERATION) || opName.equals(ValidateAddressOperationHandler.OPERATION_NAME) || opName.equals(CompositeOperationHandler.NAME) || opName.equals(DeploymentUploadStreamAttachmentHandler.OPERATION_NAME) || opName.equals(RootResourceHack.NAME)) { // Ignore some of the global operations which probably don't make much sense here continue; } } final OperationEntry opEntry = entry.getValue(); if (standalone ? true : opEntry.getFlags().contains(OperationEntry.Flag.READ_ONLY)) { ops.add(getOperation(NameConverter.convertToCamelCase(entry.getKey()), null, opEntry)); } } addChildAddOperations(ops, resourceRegistration); return ops.toArray(new OpenMBeanOperationInfo[ops.size()]); }
private void addChildAddOperations( List<OpenMBeanOperationInfo> ops, ImmutableManagementResourceRegistration resourceRegistration) { for (Map.Entry<PathElement, ChildAddOperationEntry> entry : ChildAddOperationFinder.findAddChildOperations(resourceRegistration).entrySet()) { OpenMBeanParameterInfo addWildcardChildName = null; if (entry.getValue().getElement().isWildcard()) { addWildcardChildName = new OpenMBeanParameterInfoSupport( "name", "The name of the " + entry.getValue().getElement().getKey() + " to add.", SimpleType.STRING); } ops.add( getOperation( NameConverter.createValidAddOperationName(entry.getKey()), addWildcardChildName, entry.getValue().getOperationEntry())); } }
private OpenMBeanAttributeInfo getAttribute(String name) { final String escapedName = NameConverter.convertToCamelCase(name); ModelNode attribute = providedDescription.require(ATTRIBUTES).require(name); AttributeAccess access = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name); final boolean writable; if (!standalone) { writable = false; } else { writable = access != null ? access.getAccessType() == AccessType.READ_WRITE : false; } return new OpenMBeanAttributeInfoSupport( escapedName, getDescription(attribute), converters.convertToMBeanType(attribute), true, writable, false, createAttributeDescriptor(attribute)); }
Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException { if (operationName == null) { throw MESSAGES.nullVar("operationName"); } if (params == null) { params = new Object[0]; } if (signature == null) { signature = new String[0]; } if (params.length != signature.length) { throw MESSAGES.differentLengths("params", "signature"); } final ResourceAndRegistration reg = getRootResourceAndRegistration(); final PathAddress address = resolvePathAddress(name, reg); if (address == null) { throw MESSAGES.mbeanNotFound(name); } final ImmutableManagementResourceRegistration registration = getMBeanRegistration(address, reg); String realOperationName = null; OperationEntry opEntry = registration.getOperationEntry(PathAddress.EMPTY_ADDRESS, operationName); if (opEntry != null) { realOperationName = operationName; } else { String opName = NameConverter.convertFromCamelCase(operationName); opEntry = registration.getOperationEntry(PathAddress.EMPTY_ADDRESS, opName); if (opEntry != null) { realOperationName = opName; } } if (opEntry == null) { // Brute force search in case the operation name is not standard format Map<String, OperationEntry> ops = registration.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false); for (Map.Entry<String, OperationEntry> entry : ops.entrySet()) { if (operationName.equals(NameConverter.convertToCamelCase(entry.getKey()))) { opEntry = entry.getValue(); realOperationName = entry.getKey(); break; } } } if (opEntry == null) { ChildAddOperationEntry entry = ChildAddOperationFinder.findAddChildOperation( reg.getRegistration().getSubModel(address), operationName); if (entry == null) { throw MESSAGES.noOperationCalled(null, operationName, address); } PathElement element = entry.getElement(); if (element.isWildcard()) { if (params.length == 0) { throw MESSAGES.wildcardNameParameterRequired(); } element = PathElement.pathElement(element.getKey(), (String) params[0]); Object[] newParams = new Object[params.length - 1]; System.arraycopy(params, 1, newParams, 0, newParams.length); params = newParams; } return invoke(entry.getOperationEntry(), ADD, address.append(element), params); } return invoke(opEntry, realOperationName, address, params); }