@ScriptUsage( description = "create a module instance", arguments = { @ScriptArgument(name = "module type", type = "string", description = "module type "), @ScriptArgument(name = "factory name", type = "string", description = "factory name"), @ScriptArgument(name = "instance name", type = "string", description = "instance name") }) public void createInstance(String[] args) { RadiusModuleType type = RadiusModuleType.parse(args[0]); if (type == null) { context.println("unknown module type"); return; } String factoryName = args[1]; String instanceName = args[2]; RadiusModule module = server.getModule(type); RadiusFactory<?> factory = module.getFactory(factoryName); if (factory == null) { context.println("factory not found"); return; } try { Map<String, Object> configs = config(factory.getConfigMetadatas()); RadiusInstance instance = module.createInstance(instanceName, factoryName, configs); context.println("created " + instance); } catch (InterruptedException e) { context.println(""); context.println("interrupted"); } catch (Throwable t) { context.println(t.getMessage()); } }
@ScriptUsage( description = "list all module factories", arguments = { @ScriptArgument(name = "module type", type = "string", description = "module type ") }) public void factories(String[] args) { context.println("Factories"); context.println("------------"); RadiusModuleType type = RadiusModuleType.parse(args[0]); if (type == null) { context.println("unknown module type"); return; } RadiusModule module = server.getModule(type); for (RadiusFactory<?> factory : module.getFactories()) { context.println("[" + factory.getName() + "] " + factory); } }