Skip to main content

Is it possible to configure idl2java to generate methods with Java Bean like naming conventions e.g. getX() and setX()

  • February 16, 2013
  • 0 replies
  • 0 views

Problem

  • Product Name: VisiBroker Edition
  • Product Version: All
  • Product Component: idl2java

Purpose of Document

To find out a workaround to use idl2java to generate getters starting with "get" and setters with "set" keywords so that their java representation follows the java bean convention.

Problem Description

Using "struct", "interface" and "attribute" keywords is not helpful to generate getters and setters that follow JavaBean conventions.

- Using "struct" keyword, the generated java class has no getter and setters.

- Using "interface" and "attribute" keywords, the generated java class has getters and setters but they don"t follow javabean conventions. E.g. the attribute "int myAttrib " has the associated methods: int myAttrib();void myAttrib(int a);

- As IDL mapping decides on the naming of the accessor/mutator pair, which may differ from the user"s preference or from conventions like the Java Beans getX() and setX() naming convention, so the "Attribute" keyword is also not useful.

Resolution

Java Bean like naming conventions e.g. getX() and setX() can be acheived by the use of "valuetype" objects. For instance, the following IDL defines an abstract valuetype Account that contains no state, but two methods, getName() and setName():

abstract valuetype Account {

string getName();

void setName(in string a);

}


Now, two valuetypes are defined that inherit the getName() and setName() methods from the abstract valuetype:

valuetype savingsAccount:Account {

private string name;

}

valuetype checkingAccount:Account {

private string name;

}

These two valuetypes contain a variable name, and they inherit the getName() and setName() methods from the abstract valuetype Account.

For more information please refer to following link: http://supportline.microfocus.com/Documentation/books/VisiBroker/85/obv.99.1.html#224882


#Security
#valuetypes
#VisiBroker
#JavaBean