Refine search
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()); } }
@Override public Void run() { try { Registry.getRegistry(null, null).registerComponent(rp, rpName, null); } catch (Exception e) { log.warn("Error registering request"); } return null; } });
/** 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 ); } }
/** * 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; }
/** * 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; }
/** * 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)); }
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())); }
/** * 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); }
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 ); } }
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 ); } }
/** * 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(); }
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"); } } }
/** @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 ); }
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); } }
/** * 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); } }
/** * 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); }
continue; if (getMethodInfo(current, operation) == null) { continue; getMBeanServer().invoke(current, operation, new Object[] {}, new String[] {}); log.info("Error initializing " + current + " " + t.toString());
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); }
/** * 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; }