Exemplo n.º 1
0
        public MBeanAttributeResource Put(MBeanAttributeResource valueResource)
        {
            try
            {
                var objectName = (string)ControllerContext.RouteData.Values["objectName"];
                var attribute  = (string)ControllerContext.RouteData.Values["attribute"];

                var attributeInfo = GetAttributeInfo(objectName, attribute);
                var openType      = attributeInfo.Descriptor.GetFieldValue(OpenTypeDescriptor.Field);

                var value = OpenValueFormatter.ExtractValue(openType, valueResource.Value);
                _serverConnection.SetAttribute(objectName, attribute, value);

                var resource = BuildResourceRepresentation(objectName, attribute, openType);
                return(resource);
            }
            catch (FormatException ex)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            catch (InstanceNotFoundException)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
Exemplo n.º 2
0
        private MBeanAttributeResource BuildResourceRepresentation(string objectName, string attribute, OpenType openType)
        {
            var value          = _serverConnection.GetAttribute(objectName, attribute);
            var formattedValue = OpenValueFormatter.FormatValue(openType, value);

            return(new MBeanAttributeResource
            {
                Value = formattedValue,
                Name = attribute,
                MBeanHRef = GetRouteToParent(objectName)
            });
        }