org.apache.tomcat.util.modeler.Registry类的使用及代码示例

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

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

Registry介绍

[英]Registry for modeler MBeans. This is the main entry point into modeler. It provides methods to create and manipulate model mbeans and simplify their use. Starting with version 1.1, this is no longer a singleton and the static methods are strongly deprecated. In a container environment we can expect different applications to use different registries. This class is itself an mbean. IMPORTANT: public methods not marked with @since x.x are experimental or internal. Should not be used.
[中]建模者MBean的注册表。这是进入modeler的主要入口。它提供了创建和操作模型MBean并简化其使用的方法。从1.1版开始,它不再是单一的,静态方法被强烈反对。在容器环境中,我们可以期望不同的应用程序使用不同的注册表。这个类本身就是mbean。重要提示:由于x.x是实验性的或内部的,所以未标记为@的公共方法。不应使用。

代码示例

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6

public ConnectorStats() {
  // Retrieve the MBean server
  registry = Registry.getRegistry(null, null);
  mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
  try {
    grpName = new ObjectName("*:type=GlobalRequestProcessor,*");
    tpName = new ObjectName("*:type=ThreadPool,*");
  } catch (Exception ex) {
    log.error("Error - " + ex.toString());
  }
}

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

@Override
  public Void run() {
    try {
      Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
    } catch (Exception e) {
      log.warn("Error registering request");
    }
    return null;
  }
});

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

/** Unregister a component. We'll first check if it is registered,
 * and mask all errors. This is mostly a helper.
 * 
 * @param oname
 * 
 * @since 1.1
 */ 
public void unregisterComponent( String oname ) {
  try {
    unregisterComponent(new ObjectName(oname));
  } catch (MalformedObjectNameException e) {
    log.info("Error creating object name " + e );
  }
}

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

/**
 * Create and configure (if necessary) and return the
 * <code>MBeanServer</code> with which we will be
 * registering our <code>DynamicMBean</code> implementations.
 * @return the singleton MBean server
 */
public static synchronized MBeanServer createServer() {
  if (mserver == null) {
    mserver = Registry.getRegistry(null, null).getMBeanServer();
  }
  return mserver;
}

代码示例来源:origin: stackoverflow.com

public class TestArrayList {

  public static void main(String[] args){

    Registry reg = new Registry();
    reg.addNum(11);
    reg.addNum(22);
  }
}

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

/**
 * Create, register, and return an MBean for this
 * <code>ContextResourceLink</code> object.
 *
 * @param resourceLink The ContextResourceLink to be managed
 * @return a new MBean
 * @exception Exception if an MBean cannot be created or registered
 */
public static DynamicMBean createMBean(ContextResourceLink resourceLink)
  throws Exception {
  String mname = createManagedName(resourceLink);
  ManagedBean managed = registry.findManagedBean(mname);
  if (managed == null) {
    Exception e = new Exception("ManagedBean is not found with "+mname);
    throw new MBeanException(e);
  }
  String domain = managed.getDomain();
  if (domain == null)
    domain = mserver.getDefaultDomain();
  DynamicMBean mbean = managed.createMBean(resourceLink);
  ObjectName oname = createObjectName(domain, resourceLink);
  if( mserver.isRegistered( oname ))  {
    mserver.unregisterMBean(oname);
  }
  mserver.registerMBean(mbean, oname);
  return mbean;
}

代码示例来源: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.coyote.springsource/com.springsource.org.apache.coyote.springsource

public void start() throws Exception {
  if (this.domain != null ) {
    try {
      tpOname = new ObjectName
        (domain + ":" + "type=ThreadPool,name=" + getName());
      Registry.getRegistry(null, null)
        .registerComponent(endpoint, tpOname, null );
    } catch (Exception e) {
      log.error("Can't register threadpool" );
    }
    rgOname = new ObjectName
      (domain + ":type=GlobalRequestProcessor,name=" + getName());
    Registry.getRegistry(null, null).registerComponent
      (cHandler.global, rgOname, null);
  }
  try {
    endpoint.start();
  } catch (Exception ex) {
    log.error(sm.getString("ajpprotocol.endpoint.starterror"), ex);
    throw ex;
  }
  if (log.isInfoEnabled())
    log.info(sm.getString("ajpprotocol.start", getName()));
}

代码示例来源: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

public void unregisterComponent( String domain, String name ) {
  try {
    ObjectName oname=new ObjectName( domain + ":" + name );
    // XXX remove from our tables.
    getMBeanServer().unregisterMBean( oname );
  } catch( Throwable t ) {
    log.error( "Error unregistering mbean ", t );
  }
}

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

public void unregisterComponent( String domain, String name ) {
  try {
    ObjectName oname=new ObjectName( domain + ":" + name );
    // XXX remove from our tables.
    getMBeanServer().unregisterMBean( oname );
  } catch( Throwable t ) {
    log.error( "Error unregistering mbean ", t );
  }
}

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

/**
 * Process a "start" event for this Host.
 */
public void start() {
  if (log.isDebugEnabled())
    log.debug(sm.getString("hostConfig.start"));
  try {
    ObjectName hostON = host.getObjectName();
    oname = new ObjectName
      (hostON.getDomain() + ":type=Deployer,host=" + host.getName());
    Registry.getRegistry(null, null).registerComponent
      (this, oname, this.getClass().getName());
  } catch (Exception e) {
    log.error(sm.getString("hostConfig.jmx.register", oname), e);
  }
  if (!host.getAppBaseFile().isDirectory()) {
    log.error(sm.getString("hostConfig.appBase", host.getName(),
        host.getAppBaseFile().getPath()));
    host.setDeployOnStartup(false);
    host.setAutoDeploy(false);
  }
  if (host.getDeployOnStartup())
    deployApps();
}

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

public void registerRequest(Request req, MsgContext ep, int count) {
  if(this.domain != null) {
    try {
      RequestInfo rp=req.getRequestProcessor();
      rp.setGlobalProcessor(global);
      ObjectName roname = new ObjectName
        (getDomain() + ":type=RequestProcessor,worker="+
         getChannelName()+",name=JkRequest" +count);
      ep.setNote(JMXRequestNote, roname);
          
      Registry.getRegistry(null, null).registerComponent( rp, roname, null);
    } catch( Exception ex ) {
      log.warn("Error registering request");
    }
  }
}

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

/** @deprecated - may still be used in code using pre-1.1 builds
 */
public void registerComponent(Object bean, String domain, String type,
               String name)
    throws Exception
{
  StringBuffer sb=new StringBuffer();
  sb.append( domain ).append(":");
  sb.append( name );
  String nameStr=sb.toString();
  ObjectName oname=new ObjectName( nameStr );
  registerComponent(bean, oname, type );
}

代码示例来源: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.tomcat/tomcat-catalina

/**
 * Utility method to enable sub-classes to easily unregister additional
 * components that don't implement {@link JmxEnabled} with an MBean server.
 * <br>
 * Note: This method should only be used once {@link #initInternal()} has
 * been called and before {@link #destroyInternal()} has been called.
 *
 * @param objectNameKeyProperties   The key properties component of the
 *                                  object name to use to unregister the
 *                                  object
 */
protected final void unregister(String objectNameKeyProperties) {
  // Construct an object name with the right domain
  StringBuilder name = new StringBuilder(getDomain());
  name.append(':');
  name.append(objectNameKeyProperties);
  ObjectName on = null;
  try {
    on = new ObjectName(name.toString());
    Registry.getRegistry(null, null).unregisterComponent(on);
  } catch (MalformedObjectNameException e) {
    log.warn(sm.getString("lifecycleMBeanBase.unregisterFail", name), e);
  } catch (Exception e) {
    log.warn(sm.getString("lifecycleMBeanBase.unregisterFail", name), e);
  }
}

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

/**
 * Deregister the MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
static void destroyMBean(Group group)
  throws Exception {
  String mname = createManagedName(group);
  ManagedBean managed = registry.findManagedBean(mname);
  if (managed == null) {
    return;
  }
  String domain = managed.getDomain();
  if (domain == null)
    domain = mserver.getDefaultDomain();
  ObjectName oname = createObjectName(domain, group);
  if( mserver.isRegistered(oname) )
    mserver.unregisterMBean(oname);
}

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

continue;
if (getMethodInfo(current, operation) == null) {
  continue;
getMBeanServer().invoke(current, operation, new Object[] {}, new String[] {});
log.info("Error initializing " + current + " " + t.toString());

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

public void destroy() throws Exception {
  if (log.isInfoEnabled())
    log.info(sm.getString("ajpprotocol.stop", getName()));
  endpoint.destroy();
  if (tpOname!=null)
    Registry.getRegistry(null, null).unregisterComponent(tpOname);
  if (rgOname != null)
    Registry.getRegistry(null, null).unregisterComponent(rgOname);
}

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

/**
 * Process a "stop" event for this Host.
 */
public void stop() {
  if (log.isDebugEnabled())
    log.debug(sm.getString("hostConfig.stop"));
  if (oname != null) {
    try {
      Registry.getRegistry(null, null).unregisterComponent(oname);
    } catch (Exception e) {
      log.error(sm.getString("hostConfig.jmx.unregister", oname), e);
    }
  }
  oname = null;
}

相关文章