org.apache.tomcat.util.modeler.Registry.convertValue()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(14.6k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.apache.tomcat.util.modeler.Registry.convertValue方法的一些代码示例,展示了Registry.convertValue的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.convertValue方法的具体详情如下:
包路径:org.apache.tomcat.util.modeler.Registry
类名称:Registry
方法名:convertValue

Registry.convertValue介绍

[英]EXPERIMENTAL Convert a string to object, based on type. Used by several components. We could provide some pluggability. It is here to keep things consistent and avoid duplication in other tasks
[中]根据类型将字符串转换为对象。由多个组件使用。我们可以提供一些可插拔性。这是为了保持事情的一致性,避免在其他任务中重复

代码示例

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Sets an MBean attribute's value.
 */
private void setAttributeInternal(String onameStr, String attributeName, String value)
    throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname = new ObjectName(onameStr);
  String type = registry.getType(oname, attributeName);
  Object valueObj = registry.convertValue(type, value);
  mBeanServer.setAttribute(oname, new Attribute(attributeName, valueObj));
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

public void setAttribute( PrintWriter writer,
             String onameStr, String att, String val )
{
  try {
    ObjectName oname=new ObjectName( onameStr );
    String type=registry.getType(oname, att);
    Object valueObj=registry.convertValue(type, val );
    mBeanServer.setAttribute( oname, new Attribute(att, valueObj));
    writer.println("OK - Attribute set");
  } catch( Exception ex ) {
    writer.println("Error - " + ex.toString());
    ex.printStackTrace(writer);
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

public void setAttribute( PrintWriter writer,
             String onameStr, String att, String val )
{
  try {
    ObjectName oname=new ObjectName( onameStr );
    String type=registry.getType(oname, att);
    Object valueObj=registry.convertValue(type, val );
    mBeanServer.setAttribute( oname, new Attribute(att, valueObj));
    writer.println("OK - Attribute set");
  } catch( Exception ex ) {
    writer.println("Error - " + ex.toString());
  }
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

public void setAttribute( PrintWriter writer,
             String onameStr, String att, String val )
{
  try {
    ObjectName oname=new ObjectName( onameStr );
    String type=registry.getType(oname, att);
    Object valueObj=registry.convertValue(type, val );
    mBeanServer.setAttribute( oname, new Attribute(att, valueObj));
    writer.println("OK - Attribute set");
  } catch( Exception ex ) {
    writer.println("Error - " + ex.toString());
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Sets an MBean attribute's value.
 */
private void setAttributeInternal(String onameStr,
                 String attributeName,
                 String value)
  throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname=new ObjectName( onameStr );
  String type=registry.getType(oname, attributeName);
  Object valueObj=registry.convertValue(type, value );
  mBeanServer.setAttribute( oname, new Attribute(attributeName, valueObj));
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

public void setAttribute( PrintWriter writer,
             String onameStr, String att, String val )
{
  try {
    ObjectName oname=new ObjectName( onameStr );
    String type=registry.getType(oname, att);
    Object valueObj=registry.convertValue(type, val );
    mBeanServer.setAttribute( oname, new Attribute(att, valueObj));
    writer.println("OK - Attribute set");
  } catch( Exception ex ) {
    writer.println("Error - " + ex.toString());
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Sets an MBean attribute's value.
 */
private void setAttributeInternal(String onameStr, String attributeName, String value)
    throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname = new ObjectName(onameStr);
  String type = registry.getType(oname, attributeName);
  Object valueObj = registry.convertValue(type, value);
  mBeanServer.setAttribute(oname, new Attribute(attributeName, valueObj));
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Sets an MBean attribute's value.
 */
private void setAttributeInternal(String onameStr,
                 String attributeName,
                 String value)
  throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname=new ObjectName( onameStr );
  String type=registry.getType(oname, attributeName);
  Object valueObj=registry.convertValue(type, value );
  mBeanServer.setAttribute( oname, new Attribute(attributeName, valueObj));
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

private void invokeOperation(PrintWriter writer, String onameStr, String op,
    String[] valuesStr) {
  try {
    ObjectName oname=new ObjectName( onameStr );
    MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,op);
    MBeanParameterInfo[] signature = methodInfo.getSignature();
    String[] signatureTypes = new String[signature.length];
    Object[] values = new Object[signature.length];
    for (int i = 0; i < signature.length; i++) {
      MBeanParameterInfo pi = signature[i];
      signatureTypes[i] = pi.getType();
      values[i] = registry.convertValue(pi.getType(), valuesStr[i] );
    }
    Object retVal = mBeanServer.invoke(oname,op,values,signatureTypes);
    if (retVal != null) {
      writer.println("OK - Operation " + op + " returned:");
      output("", writer, retVal);
    } else {
      writer.println("OK - Operation " + op + " without return value");
    }
  } catch( Exception ex ) {
    writer.println("Error - " + ex.toString());
    ex.printStackTrace(writer);
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Invokes an operation on an MBean.
 *
 * @param onameStr The name of the MBean.
 * @param operation The name of the operation to invoke.
 * @param parameters An array of Strings containing the parameters to the
 *            operation. They will be converted to the appropriate types to
 *            call the requested operation.
 * @return The value returned by the requested operation.
 */
private Object invokeOperationInternal(String onameStr, String operation, String[] parameters)
    throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname = new ObjectName(onameStr);
  MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation);
  MBeanParameterInfo[] signature = methodInfo.getSignature();
  String[] signatureTypes = new String[signature.length];
  Object[] values = new Object[signature.length];
  for (int i = 0; i < signature.length; i++) {
    MBeanParameterInfo pi = signature[i];
    signatureTypes[i] = pi.getType();
    values[i] = registry.convertValue(pi.getType(), parameters[i]);
  }
  return mBeanServer.invoke(oname, operation, values, signatureTypes);
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Invokes an operation on an MBean.
 *
 * @param onameStr The name of the MBean.
 * @param operation The name of the operation to invoke.
 * @param parameters An array of Strings containing the parameters to the
 *            operation. They will be converted to the appropriate types to
 *            call the requested operation.
 * @return The value returned by the requested operation.
 */
private Object invokeOperationInternal(String onameStr, String operation, String[] parameters)
    throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname = new ObjectName(onameStr);
  MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation);
  MBeanParameterInfo[] signature = methodInfo.getSignature();
  String[] signatureTypes = new String[signature.length];
  Object[] values = new Object[signature.length];
  for (int i = 0; i < signature.length; i++) {
    MBeanParameterInfo pi = signature[i];
    signatureTypes[i] = pi.getType();
    values[i] = registry.convertValue(pi.getType(), parameters[i]);
  }
  return mBeanServer.invoke(oname, operation, values, signatureTypes);
}

代码示例来源:origin: jboss.web/jbossweb

private void processAttribute(MBeanServer server,
               Node descN, String objectName ) {
  String attName=DomUtil.getAttribute(descN, "name");
  String value=DomUtil.getAttribute(descN, "value");
  String type=null; // DomUtil.getAttribute(descN, "type");
  if( value==null ) {
    // The value may be specified as CDATA
    value=DomUtil.getContent(descN);
  }
  try {
    if( log.isDebugEnabled())
      log.debug("Set attribute " + objectName + " " + attName +
          " " + value);
    ObjectName oname=new ObjectName(objectName);
    // find the type
    if( type==null )
      type=registry.getType(  oname, attName );
    if( type==null ) {
      log.info("Can't find attribute " + objectName + " " + attName );
    } else {
      Object valueO=registry.convertValue( type, value);
      server.setAttribute(oname, new Attribute(attName, valueO));
    }
  } catch( Exception ex) {
    log.error("Error processing attribute " + objectName + " " +
        attName + " " + value, ex);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Invokes an operation on an MBean.
 * @param onameStr The name of the MBean.
 * @param operation The name of the operation to invoke.
 * @param parameters An array of Strings containing the parameters to the
 *                   operation. They will be converted to the appropriate
 *                   types to call the reuested operation.
 * @return The value returned by the requested operation.
 */
private Object invokeOperationInternal(String onameStr,
                    String operation,
                    String[] parameters)
  throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname=new ObjectName( onameStr );
  MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,operation);
  MBeanParameterInfo[] signature = methodInfo.getSignature();
  String[] signatureTypes = new String[signature.length];
  Object[] values = new Object[signature.length];
  for (int i = 0; i < signature.length; i++) {
    MBeanParameterInfo pi = signature[i];
    signatureTypes[i] = pi.getType();
    values[i] = registry.convertValue(pi.getType(), parameters[i] );
   }
  return mBeanServer.invoke(oname,operation,values,signatureTypes);
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Invokes an operation on an MBean.
 * @param onameStr The name of the MBean.
 * @param operation The name of the operation to invoke.
 * @param parameters An array of Strings containing the parameters to the
 *                   operation. They will be converted to the appropriate
 *                   types to call the reuested operation.
 * @return The value returned by the requested operation.
 */
private Object invokeOperationInternal(String onameStr,
                    String operation,
                    String[] parameters)
  throws OperationsException, MBeanException, ReflectionException {
  ObjectName oname=new ObjectName( onameStr );
  MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,operation);
  MBeanParameterInfo[] signature = methodInfo.getSignature();
  String[] signatureTypes = new String[signature.length];
  Object[] values = new Object[signature.length];
  for (int i = 0; i < signature.length; i++) {
    MBeanParameterInfo pi = signature[i];
    signatureTypes[i] = pi.getType();
    values[i] = registry.convertValue(pi.getType(), parameters[i] );
   }
  return mBeanServer.invoke(oname,operation,values,signatureTypes);
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/util

private void processAttribute(MBeanServer server,
               Node descN, String objectName ) {
  String attName=DomUtil.getAttribute(descN, "name");
  String value=DomUtil.getAttribute(descN, "value");
  String type=null; // DomUtil.getAttribute(descN, "type");
  if( value==null ) {
    // The value may be specified as CDATA
    value=DomUtil.getContent(descN);
  }
  try {
    if( log.isDebugEnabled())
      log.debug("Set attribute " + objectName + " " + attName +
          " " + value);
    ObjectName oname=new ObjectName(objectName);
    // find the type
    type=registry.getType(  oname, attName );
    if( type==null ) {
      log.info("Can't find attribute " + objectName + " " + attName );
    } else {
      Object valueO=registry.convertValue( type, value);
      server.setAttribute(oname, new Attribute(attName, valueO));
    }
  } catch( Exception ex) {
    log.error("Error processing attribute " + objectName + " " +
        attName + " " + value, ex);
  }
}

代码示例来源:origin: org.apache.coyote/com.springsource.org.apache.coyote

private void processAttribute(MBeanServer server,
               Node descN, String objectName ) {
  String attName=DomUtil.getAttribute(descN, "name");
  String value=DomUtil.getAttribute(descN, "value");
  String type=null; // DomUtil.getAttribute(descN, "type");
  if( value==null ) {
    // The value may be specified as CDATA
    value=DomUtil.getContent(descN);
  }
  try {
    if( log.isDebugEnabled())
      log.debug("Set attribute " + objectName + " " + attName +
          " " + value);
    ObjectName oname=new ObjectName(objectName);
    // find the type
    type=registry.getType(  oname, attName );
    if( type==null ) {
      log.info("Can't find attribute " + objectName + " " + attName );
    } else {
      Object valueO=registry.convertValue( type, value);
      server.setAttribute(oname, new Attribute(attName, valueO));
    }
  } catch( Exception ex) {
    log.error("Error processing attribute " + objectName + " " +
        attName + " " + value, ex);
  }
}

代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource

private void processAttribute(MBeanServer server,
               Node descN, String objectName ) {
  String attName=DomUtil.getAttribute(descN, "name");
  String value=DomUtil.getAttribute(descN, "value");
  String type=null; // DomUtil.getAttribute(descN, "type");
  if( value==null ) {
    // The value may be specified as CDATA
    value=DomUtil.getContent(descN);
  }
  try {
    if( log.isDebugEnabled())
      log.debug("Set attribute " + objectName + " " + attName +
          " " + value);
    ObjectName oname=new ObjectName(objectName);
    // find the type
    if( type==null )
      type=registry.getType(  oname, attName );
    if( type==null ) {
      log.info("Can't find attribute " + objectName + " " + attName );
    } else {
      Object valueO=registry.convertValue( type, value);
      server.setAttribute(oname, new Attribute(attName, valueO));
    }
  } catch( Exception ex) {
    log.error("Error processing attribute " + objectName + " " +
        attName + " " + value, ex);
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

private void processAttribute(MBeanServer server,
               Node descN, String objectName ) {
  String attName=DomUtil.getAttribute(descN, "name");
  String value=DomUtil.getAttribute(descN, "value");
  String type=null; // DomUtil.getAttribute(descN, "type");
  if( value==null ) {
    // The value may be specified as CDATA
    value=DomUtil.getContent(descN);
  }
  try {
    if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
      CoyoteLogger.MODELER_LOGGER.debug("Set attribute " + objectName + " " + attName +
          " " + value);
    ObjectName oname=new ObjectName(objectName);
    // find the type
    if( type==null )
      type=registry.getType(  oname, attName );
    if( type==null ) {
      CoyoteLogger.MODELER_LOGGER.attributeNotFound(attName, objectName);
    } else {
      Object valueO=registry.convertValue( type, value);
      server.setAttribute(oname, new Attribute(attName, valueO));
    }
  } catch( Exception ex) {
    CoyoteLogger.MODELER_LOGGER.errorProcessingAttribute(attName, value, objectName, ex);
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

private void processAttribute(MBeanServer server,
               Node descN, String objectName ) {
  String attName=DomUtil.getAttribute(descN, "name");
  String value=DomUtil.getAttribute(descN, "value");
  String type=null; // DomUtil.getAttribute(descN, "type");
  if( value==null ) {
    // The value may be specified as CDATA
    value=DomUtil.getContent(descN);
  }
  try {
    if( log.isDebugEnabled())
      log.debug("Set attribute " + objectName + " " + attName +
          " " + value);
    ObjectName oname=new ObjectName(objectName);
    // find the type
    if( type==null )
      type=registry.getType(  oname, attName );
    if( type==null ) {
      log.info("Can't find attribute " + objectName + " " + attName );
    } else {
      Object valueO=registry.convertValue( type, value);
      server.setAttribute(oname, new Attribute(attName, valueO));
    }
  } catch( Exception ex) {
    log.error("Error processing attribute " + objectName + " " +
        attName + " " + value, ex);
  }
}

相关文章