Register the JMX agent

@throws java.lang.Exception
513961
public synchronized void register() throws Exception {
        if (mbeanName != null) {
            throw new Exception("Agent already registered");
        }
        mbeanName = new ObjectName(getClass().getPackage().getName() + ":type=" + getClass().getSimpleName());
        logger.info("Registering JMX agent " + mbeanName);
        ManagementFactory.getPlatformMBeanServer().registerMBean(this, mbeanName);
        logger.info("JMX agent " + mbeanName + " registered");
    }
983914
public void register(ApplicationContext applicationContext) {
    applicationContext
        .getBeansOfType(TransactionExceptionTranslator.class)
        .values()
        .forEach(transactionExceptionTranslatorRegistry::register);
  }
355160
public static void premain(String agentArgs, Instrumentation inst) {
        System.out.println(STARTUP_NOTICE) ;
        JMXetricAgent a = null ;
        try {
            a = new JMXetricAgent();
            XMLConfigurationService.configure(a, agentArgs);
            a.start();
        } catch ( Exception ex ) {
            // log.severe("Exception starting JMXetricAgent");
            ex.printStackTrace();
        }
    }
823539
@Override
    public void start() throws Exception {

        String thisMethodName = CLASS_NAME + ".start()";

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            // SibTr.entry(tc, thisMethodName);
        }

        Enumeration meEnum = _messagingEngines.elements();

        while (meEnum.hasMoreElements()) {
            Object o = meEnum.nextElement();
            Object c = ((MessagingEngine) o).getRuntime();
            try {

                ((BaseMessagingEngineImpl) c).startConditional();
                Dictionary<String, Object> properties = new Hashtable<String, Object>();
                properties.put("service.vendor", "IBM");
                properties.put("jmx.objectname", "WebSphere:feature=wasJmsServer,type=MessagingEngine,name=" + ((BaseMessagingEngineImpl) c)._name);
                mbeanServiceReg = (ServiceRegistration<MessagingEngineMBean>) this.bContext.registerService(MessagingEngineMBean.class.getName(), c, properties);

            } catch (Exception w) {
                // Not serious enough to warrant server stop.
                FFDCFilter.processException(w, thisMethodName, "1:725:1.108",
                                            this);
                SibTr.exception(tc, w);
                SibTr.error(tc, "INTERNAL_ERROR_SIAS0003", w);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, thisMethodName);
        }
    }
1153737
public Application register(Object component, Class<?>... contracts) {
        config.register(component, contracts);
        return this;
    }
1113393
public final synchronized void start() throws IOException {
		LaunchingMessageKind.IJMX0001.format(this.host, this.port);
		this.mbs = ManagementFactory.getPlatformMBeanServer();

		final String oldRmiServerName = System
				.getProperty("java.rmi.server.hostname");
		System.setProperty("java.rmi.server.hostname", this.host);

		register = LocateRegistry.createRegistry(this.port);
		if (oldRmiServerName == null) {
			final Properties props = System.getProperties();
			for (Object key : props.keySet()) {
				if (key.equals("java.rmi.server.hostname")) {
					props.remove(key);
					break;
				}
			}
		} else {
			System.setProperty("java.rmi.server.hostname", oldRmiServerName);
		}

		final String serviceURL = String.format(serverUrlFormat, this.host,
				this.host, this.port);
		LaunchingMessageKind.IJMX0002.format(serviceURL);

		final JMXServiceURL url = new JMXServiceURL(serviceURL);
		this.jmxConnectorServer = JMXConnectorServerFactory
				.newJMXConnectorServer(url, null, mbs);
		this.jmxConnectorServer.start();
		registerMBeans();
	}
321181
public static void registerAgent(Agent agent, String serviceName, String serviceType) throws FIPAException{
        DFAgentDescription dfd = new DFAgentDescription();
        ServiceDescription sd = new ServiceDescription();
        
        sd.setType(serviceType);
        sd.setName(serviceName);
        
        //NOTE El serviceType es un string que define el tipo de servicio publicado en el DF por el Agente X. 
        //     He escogido crear nombres en clave en jade.common.Definitions para este campo. 
        //NOTE El serviceName es el nombre efectivo del servicio. 
        //     Esto es lo que el usuario va a definir en MockConfiguration.DFNameService y no el tipo como estaba puesto. 
        //        sd.setType(agentType);
        //        sd.setName(agent.getLocalName());
        
        //Add services??
        
        // Sets the agent description
        dfd.setName(agent.getAID());
        dfd.addServices(sd);
        
        // Register the agent
        DFService.register(agent, dfd);
    }
171382
public static void registerMbean(MBeanServer server, ModelMBean mbean, ObjectName name) {
        try {
            synchronized(LOCK) {
                if(server.isRegistered(name))
                    JmxUtils.unregisterMbean(server, name);
                server.registerMBean(mbean, name);
            }
        } catch(Exception e) {
            logger.error("Error registering mbean:", e);
        }
    }
417175
@Setup(Level.Trial)
  public void setup() throws Exception {
    registry = new MutableHandlerRegistry();
    fullMethodNames = new ArrayList<>(serviceCount * methodCountPerService);
    for (int serviceIndex = 0; serviceIndex < serviceCount; ++serviceIndex) {
      String serviceName = randomString();
      ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition.builder(serviceName);
      for (int methodIndex = 0; methodIndex < methodCountPerService; ++methodIndex) {
        String methodName = randomString();

        MethodDescriptor<Void, Void> methodDescriptor = MethodDescriptor.<Void, Void>newBuilder()
            .setType(MethodDescriptor.MethodType.UNKNOWN)
            .setFullMethodName(MethodDescriptor.generateFullMethodName(serviceName, methodName))
            .setRequestMarshaller(TestMethodDescriptors.voidMarshaller())
            .setResponseMarshaller(TestMethodDescriptors.voidMarshaller())
            .build();
        serviceBuilder.addMethod(methodDescriptor,
            new ServerCallHandler<Void, Void>() {
              @Override
              public Listener<Void> startCall(ServerCall<Void, Void> call,
                  Metadata headers) {
                return null;
              }
            });
        fullMethodNames.add(methodDescriptor.getFullMethodName());
      }
      registry.addService(serviceBuilder.build());
    }
  }
1143199
public final void register() {
        synchronized (this) {
            if (filterFactoryServiceRegistration != null) {
                throw new IllegalStateException(String.format("%s [%s] has been registered.", getClass()
                    .getSimpleName(), this));
            }
            filterFactoryServiceRegistration = bundleContext.registerService(SERVICE_CLASSES, this, properties);
            LOGGER.info("Registered filterFactory for application {} with priority {}", getApplicationName(),
                getPriority());
        }
    }
219581
public void setup() {
		this.myIntrospector = JadeAgentIntrospector.getMyInstance((Agent) this);
		LogActivator.logToFile(logger, this.getName(), Level.ALL);
		// Register the service
		try {
			DFAgentDescription dfd = new DFAgentDescription();
			ServiceDescription sd = new ServiceDescription();
	        
	        sd.setType("server");
	        sd.setName("report-service");
	        // Sets the agent description
	        dfd.setName(this.getAID());
	        dfd.addServices(sd);
	        
	        // Register the agent
	        DFService.register(this, dfd);
			
		} catch (Exception e) {
			logger.severe("Exception registering agent in DF. Agent: " + this.getName());
		}

		MessageTemplate t = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
		addBehaviour(new ReportServer(this,t));
	}
1088786
private void configureJMXetricAgent() throws XPathExpressionException,
			Exception {
		// Gets the config for the samplers
		NodeList samples = getXmlNodeList("/jmxetric-config/sample",
				inputSource);
		for (int i = 0; i < samples.getLength(); i++) {
			Node sample = samples.item(i);
			MBeanSampler mbSampler = makeMBeanSampler(sample);
			agent.addSampler(mbSampler);
		}
	}
236604
public void register() {
		try {
			objectName = consObjectName(domain, type, keysString);
			MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
			mbs.registerMBean(this, objectName);
		} catch (Exception e) {
			objectName = null;
			throw new RuntimeException(e);
		}
	}
311255
public void registerAspectComponents() throws Exception {
		Debug.logVerbose("[JdonFramework] note: registe aspect components ", module);
		try {
			InterceptorsChain existedInterceptorsChain = (InterceptorsChain) containerWrapper.lookup(ComponentKeys.INTERCEPTOR_CHAIN);

			Iterator iter = aspectConfigComponents.iterator();
			Debug.logVerbose("[JdonFramework] 3 aspectConfigComponents size:" + aspectConfigComponents.size(), module);
			while (iter.hasNext()) {
				String name = (String) iter.next();
				AspectComponentsMetaDef componentMetaDef = (AspectComponentsMetaDef) aspectConfigComponents.getComponentMetaDef(name);
				// registe into container
				xmlcontainerRegistry.registerAspectComponentMetaDef(componentMetaDef);
				// got the interceptor instance;
				// add interceptor instance into InterceptorsChain object
				existedInterceptorsChain.addInterceptor(componentMetaDef.getPointcut(), name);
			}
		} catch (Exception ex) {
			Debug.logError("[JdonFramework] registerAspectComponents error:" + ex, module);
			throw new Exception(ex);
		}

	}
270844
public static void createAndRegister() {
    synchronized (monitor) {
      checkState(handler == null, "OC-Agent exporter is already registered.");
      OcAgentTraceExporterHandler newHandler = new OcAgentTraceExporterHandler();
      registerInternal(newHandler);
    }
  }
274405
public void register(BundleContext bndCtx) {
        final String methodName = "register()";
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(tc, methodName, this);
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put("jmx.objectname", this.obn.toString());

        if (IS_DEBUGGING)
            // Extra Check: Does this MBean exist already?
            MBeanHelper.isMbeanExist(objectName.toString() + "*", className, methodName);

        // Register the MBean
        if (trace && tc.isDebugEnabled())
            Tr.debug(tc, "activateMBean started for " + this.obn.toString());
        this.reg = bndCtx.registerService(JCAConnectionFactoryMBeanImpl.class.getName(), this, props);
        if (trace && tc.isEntryEnabled())
            Tr.exit(tc, methodName, this);
    }
772064
protected void registerForMBeanNotifications() {
        Set<MBeanServerConnection> servers = getMBeanServers();
        Exception lastExp = null;
        StringBuilder errors = new StringBuilder();
        for (MBeanServerConnection server : servers) {
            try {
                JmxUtil.addMBeanRegistrationListener(server,this,null);
            } catch (IllegalStateException e) {
                lastExp = updateErrorMsg(errors,e);
            }
        }
        if (lastExp != null) {
            throw new IllegalStateException(errors.substring(0,errors.length()-1),lastExp);
        }
    }