Package mx4j.tools.config

Examples of mx4j.tools.config.ConfigurationLoader


      /* Choice 2: as a created MBean */
      // server.createMBean(ConfigurationLoader.class.getName(), ObjectName.getInstance("config:service=loader"), null);

      /* Choice 3: as a registered MBean */
      ConfigurationLoader loader = new ConfigurationLoader();
      server.registerMBean(loader, ObjectName.getInstance("config:service=loader"));

      // The XML file

      /* Choice 1: read it from classpath using classloaders
         Note: the directory that contains the XML file must be in the classpath */
      // InputStream stream = ConfigurationStartup.class.getClassLoader().getResourceAsStream("config.xml");
      // Reader reader = new BufferedReader(new InputStreamReader(stream));

      /* Choice 2: read it from a file
         Note: requires file path to be passed as program argument */
      String path = args[0];
      Reader reader = new BufferedReader(new FileReader(path));

      // Read and execute the 'startup' section of the XML file
      loader.startup(reader);

      reader.close();

      System.out.println("Application configured successfully");
   }
View Full Code Here


              "  <shutdown>" +
              "    <unregister objectname=\"" + name + "\" />" +
              "  </shutdown>" +
              "</configuration>" +
              "";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      Reader reader = new BufferedReader(new StringReader(config));
      loader.startup(reader);
      sleep(1000);

      assertTrue(server.isRegistered(new ObjectName(name)));

      Socket socket = new Socket((String)null, port);
View Full Code Here

              "    <call refobjectid=\"" + id + "\" method=\"stop\" />" +
              "    <unregister objectname=\"" + name + "\" />" +
              "  </shutdown>" +
              "</configuration>" +
              "";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      Reader reader = new BufferedReader(new StringReader(config));
      loader.startup(reader);
      sleep(1000);

      assertTrue(server.isRegistered(new ObjectName(name)));
      Boolean active = (Boolean)server.getAttribute(new ObjectName(name), "Active");
      assertTrue(active.booleanValue());
View Full Code Here

   {
      MBeanServer server = newMBeanServer();
      String config =
              "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
              "<configuration>";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      try
      {
         loader.startup(new StringReader(config));
         fail();
      }
      catch (ConfigurationException x)
      {
      }
View Full Code Here

      String config =
              "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
              "<configuration>" +
              "   <dummy />" +
              "</configuration>";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      try
      {
         loader.startup(new StringReader(config));
         fail();
      }
      catch (ConfigurationException x)
      {
      }
View Full Code Here

   {
      MBeanServer server = newMBeanServer();
      String config =
              "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
              "<configuration />";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      loader.startup(new StringReader(config));
   }
View Full Code Here

      String config =
              "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
              "<configuration>" +
              "   <startup />" +
              "</configuration>";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      loader.startup(new StringReader(config));
   }
View Full Code Here

      String config =
              "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
              "<configuration>" +
              "   <shutdown />" +
              "</configuration>";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      loader.startup(new StringReader(config));
   }
View Full Code Here

      String config =
              "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
              "<configuration port=\"" + port + "\">" +
              "   <shutdown />" +
              "</configuration>";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      loader.startup(new StringReader(config));
      sleep(1000);

      // Be sure we can connect to the socket
      Socket socket = new Socket((String)null, port);
      socket.getOutputStream().write(DefaultConfigurationBuilder.SHUTDOWN_COMMAND.getBytes());
View Full Code Here

              "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
              "<configuration>" +
              "   <startup />" +
              "   <shutdown />" +
              "</configuration>";
      ConfigurationLoader loader = new ConfigurationLoader(server);
      loader.startup(new StringReader(config));
   }
View Full Code Here

TOP

Related Classes of mx4j.tools.config.ConfigurationLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.