Ejemplo n.º 1
0
 /** Generates the code for the checker. */
 protected void addChecker(
     Context ctxt,
     MibNode node,
     String description,
     String syntax,
     String var,
     StringBuffer buff) {
   buff.append(
       Def.TAB
           + "/**\n"
           + Def.TAB
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment.checker", var)
           + "\n"
           + Def.TAB
           + " */\n");
   buff.append(
       Def.TAB + Def.PUBLIC + Def.VOID + Def.CHECK + var + "(" + syntax + "x) " + accessThrows);
   buff.append(
       Def.TAB2
           + "//\n"
           + Def.TAB2
           + "// "
           + MessageHandler.getMessage("generate.mbean.comment.checker.policy")
           + "\n"
           + Def.TAB2
           + "//\n");
   buff.append(Def.TAB + Def.RBRACE + "\n");
 }
Ejemplo n.º 2
0
 private void addRowStatusSetter(
     Context ctxt,
     MibNode node,
     String description,
     String syntax,
     String var,
     StringBuffer buff) {
   buff.append(
       Def.TAB
           + "/**\n"
           + Def.TAB
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment.setter", var)
           + "\n"
           + Def.TAB
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment." + "setter.rs.nochecker")
           + "\n"
           + Def.TAB
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment." + "checker.rs.override")
           + "\n"
           + Def.TAB
           + " */\n");
   buff.append(
       Def.TAB + Def.PUBLIC + Def.VOID + Def.SET + var + "(" + syntax + "x) " + accessThrows);
   buff.append(Def.TAB2 + var + " = x" + Def.SEMICOLON);
   buff.append(Def.TAB + Def.RBRACE + "\n");
 }
Ejemplo n.º 3
0
  protected void buildConstructorHeader() throws IOException {
    constructor1.append(
        "\n"
            + Def.TAB
            + "/**\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.constr", symboleName)
            + "\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.noRegistration")
            + "\n"
            + Def.TAB
            + " */\n");
    constructor1.append(Def.TAB + Def.PUBLIC + symboleName + "(SnmpMib myMib)" + Def.LBRACE);

    constructor2.append(
        "\n"
            + Def.TAB
            + "/**\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.constr", symboleName)
            + "\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.registration")
            + "\n"
            + Def.TAB
            + " */\n");
    constructor2.append(
        Def.TAB + Def.PUBLIC + symboleName + "(SnmpMib myMib, MBeanServer server)" + Def.LBRACE);
  }
Ejemplo n.º 4
0
  public MbeanGenerator(ResourceManager mgr, MibNode aGroup, Context ctxt) throws IOException {
    super(mgr, aGroup, ctxt);

    gentype = ctxt.gentype;

    // Specify oid of the current bean ...
    //
    oid = node.getComputedOid();

    // Try to find a symbol to associate to the group
    //
    varName = node.getSymbolName();
    if (varName == null) varName = getClassName(node.getComputedOid());
    symboleName = getNodeSymbolName(node);

    Trace.info(MessageHandler.getMessage("generate.info.var", varName));

    // Open the file which will represent the M-bean.
    //
    out = openFile(symboleName + Def.JAVA);

    // Write generic header ...
    //
    writeHeader();

    // write our own header ...
    //
    writeClassDeclaration();

    // write the beginning of the constructor
    //
    buildConstructorHeader();
  }
Ejemplo n.º 5
0
 private void addRowStatusChecker(
     Context ctxt,
     MibNode node,
     String description,
     String syntax,
     String var,
     StringBuffer buff) {
   buff.append(
       Def.TAB
           + "/**\n"
           + Def.TAB
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment.checker", var)
           + "\n"
           + Def.TAB
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment.checker.rs.deprecated")
           + "\n"
           + Def.TAB
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment.checker.rs.override")
           + "\n"
           + Def.TAB
           + " */\n");
   buff.append(
       Def.TAB
           + Def.PUBLIC
           + Def.VOID
           + Def.CHECK
           + var
           + "("
           + syntax
           + "x) "
           + BeanGenerator.accessThrows);
   buff.append(
       Def.TAB2
           + "//\n"
           + Def.TAB2
           + "// "
           + MessageHandler.getMessage("generate.mbean.comment.checker.rs.policy")
           + "\n"
           + Def.TAB2
           + "//\n");
   buff.append(Def.TAB + Def.RBRACE + "\n");
 }
Ejemplo n.º 6
0
  protected void addCacheVar(MibNode node, String syntax, long fixed, String init, String var)
      throws IOException {
    // Put some comments ...
    //
    var_list.append(
        Def.TAB
            + "/**\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.varUse", var)
            + "\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.varOid", node.getOid())
            + "\n"
            + Def.TAB);
    if (fixed != -1) {
      var_list.append(
          " * "
              + MessageHandler.getMessage("generate.mbean.comment.varFix", String.valueOf(fixed))
              + "\n"
              + Def.TAB);
    }

    // Shall we put the description in the generated code ?
    // if yes call the formatDescription method ...
    // The answer is yes if requested !
    if (mib.isDescriptionOn()) {
      // Get the object definition associated to the node
      //
      ASTObjectTypeDefinition definition = node.getObjectType();
      String description = definition.getDefinition().getDescription();
      var_list.append(formatDescription(description));
    }
    var_list.append(" */\n");

    if (init == null) init = "";

    // Declare the variable
    //
    var_list.append(Def.TAB + Def.PROTECTED + syntax + var + init + Def.SEMICOLON + "\n");
  }
Ejemplo n.º 7
0
 protected void writeClassDeclaration() throws IOException {
   // Add some comments
   //
   write(
       "/**\n"
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment.desc", varName)
           + "\n"
           + " * "
           + MessageHandler.getMessage("generate.mbean.comment.oid", oid)
           + "\n"
           + " */\n");
   write(
       Def.PUBLIC
           + Def.CLASS
           + symboleName
           + Def.IMPLEMENT
           + symboleName
           + Def.MBEANSUFFIX
           + ", "
           + Def.SERIALIZABLE
           + Def.LBRACE
           + "\n");
 }
Ejemplo n.º 8
0
  /** Generates the code for the getter. */
  protected void addGetter(
      Context ctxt,
      MibNode node,
      String description,
      String syntax,
      String var,
      StringBuffer buff) {

    buff.append(
        Def.TAB
            + "/**\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.getter", var)
            + "\n"
            + Def.TAB
            + " */\n");
    buff.append(Def.TAB + Def.PUBLIC + syntax + Def.GET + var + "() " + accessThrows);
    buff.append(Def.TAB2 + Def.RETURN + var + Def.SEMICOLON);
    buff.append(Def.TAB + Def.RBRACE + "\n");
  }
Ejemplo n.º 9
0
  /** Process table. */
  protected void handleTable(MibNode node) throws IOException {
    // create a table generator
    //
    TableBeanGenerator table = new TableBeanGenerator(manager, node, context);

    // The meta table generator is now created by the
    // MetaBeanGenerator, which is more logic.
    //
    // // MetaTableGenerator metatable=
    // //   new MetaTableGenerator(manager, node, context);

    // create a table generator interface
    //
    // TableBeanIfGenerator tableIf= new TableBeanIfGenerator(manager, packageName, prefix,
    // targetDir, node, mib);

    // Get the entry name
    //
    String entry = table.getEntryName();

    // Get the table name
    //
    String tableName = table.getTableClassName();

    // Name of the symbol
    //
    String variable = table.getSymbolName();

    // Add cache variable for storing table
    //
    addCacheVar(node, tableName, (long) -1, null, variable);

    // Initialize the table in the constructor
    //
    constructor1.append(
        Def.TAB2 + variable + " = " + Def.NEW + tableName + "(myMib)" + Def.SEMICOLON);
    constructor2.append(
        Def.TAB2 + variable + " = " + Def.NEW + tableName + "(myMib, server)" + Def.SEMICOLON);

    // Add access method on the table
    //
    accessors.append(
        Def.TAB
            + "/**\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.table.access", variable)
            + "\n"
            + Def.TAB
            + " */\n");
    accessors.append(
        Def.TAB + Def.PUBLIC + tableName + Def.ACCESS + variable + "() " + accessThrows);
    accessors.append(
        Def.TAB2 + Def.RETURN + variable + Def.SEMICOLON + Def.TAB + Def.RBRACE + "\n");

    // Show the table as an indexed property...
    //
    accessors.append(
        Def.TAB
            + "/**\n"
            + Def.TAB
            + " * "
            + MessageHandler.getMessage("generate.mbean.comment.table.entry", variable)
            + "\n"
            + Def.TAB
            + " */\n");
    accessors.append(
        Def.TAB
            + Def.PUBLIC
            + entry
            + Def.MBEANSUFFIX
            + "[] "
            + Def.GET
            + variable
            + "() "
            + accessThrows);
    accessors.append(
        Def.TAB2
            + Def.RETURN
            + variable
            + ".getEntries()"
            + Def.SEMICOLON
            + Def.TAB
            + Def.RBRACE
            + "\n");
  }
Ejemplo n.º 10
0
  // Specify the version of mibgen used for generating the code
  //
  protected void writeVersion() throws IOException {
    String msgid = "generate.version";

    write("\n//\n// " + MessageHandler.getMessage(msgid, mib.getModuleName()) + "\n//\n\n");
  }