Пример #1
0
 // Construct configured dispatchers by reflection. Returns always
 // a list, an empty one if no request dispatcher should be created
 private List<RequestDispatcher> createRequestDispatchers(
     String pClasses, Converters pConverters, ServerHandle pServerHandle, Restrictor pRestrictor) {
   List<RequestDispatcher> ret = new ArrayList<RequestDispatcher>();
   if (pClasses != null && pClasses.length() > 0) {
     String[] names = pClasses.split("\\s*,\\s*");
     for (String name : names) {
       ret.add(createDispatcher(name, pConverters, pServerHandle, pRestrictor));
     }
   }
   return ret;
 }
Пример #2
0
 @Test
 public void multiPostRequests() {
   Map<String, Object> req1Map =
       createMap(
           "type", "read",
           "mbean", "java.lang:type=Memory",
           "attribute", "HeapMemoryUsage");
   Map<String, Object> req2Map = createMap("type", "list");
   List<JmxRequest> req =
       JmxRequestFactory.createPostRequests(Arrays.asList(req1Map, req2Map), null);
   assertEquals(req.get(0).getType(), RequestType.READ);
   assertEquals(req.get(1).getType(), RequestType.LIST);
 }
Пример #3
0
 @Test
 public void simplePostWithPath() {
   Map<String, Object> reqMap =
       createMap(
           "type", "read",
           "mbean", "java.lang:type=Memory",
           "attribute", "HeapMemoryUsage",
           "path", "blub!/bla/hello");
   JmxReadRequest req = JmxRequestFactory.createPostRequest(reqMap, null);
   List<String> path = req.getPathParts();
   assertEquals(path.size(), 2);
   assertEquals(path.get(0), "blub/bla");
   assertEquals(path.get(1), "hello");
   assertEquals(req.getPath(), "blub!/bla/hello");
 }
Пример #4
0
 @Test
 public void simpleGetWithPath() {
   JmxWriteRequest req =
       JmxRequestFactory.createGetRequest(
           "write/java.lang:type=Runtime/SystemProperties/7788/[com.sun.management.jmxremote.port]/value",
           null);
   assert req.getType() == RequestType.WRITE : "Type is write";
   assert req.getObjectName().getCanonicalName().equals("java.lang:type=Runtime")
       : "Name properly parsed";
   List<String> parts = req.getPathParts();
   assert parts.get(0).equals("[com.sun.management.jmxremote.port]")
       : "Path part 0:" + parts.get(0);
   assert parts.get(1).equals("value") : "Path part 1: " + parts.get(1);
   assert req.getPath().equals("[com.sun.management.jmxremote.port]/value");
 }
Пример #5
0
  // Initialize this object;
  private void init(Configuration pConfig) {
    // Central objects
    converters = new Converters();
    initLimits(pConfig);

    // Create and remember request dispatchers
    localDispatcher = new LocalRequestDispatcher(converters, restrictor, pConfig, logHandler);
    ServerHandle serverHandle = localDispatcher.getServerInfo();
    requestDispatchers =
        createRequestDispatchers(
            pConfig.get(DISPATCHER_CLASSES), converters, serverHandle, restrictor);
    requestDispatchers.add(localDispatcher);

    // Backendstore for remembering agent state
    initStores(pConfig);
  }