...
YANG utils constructs support/plan
| YANG Construct | Supported/Planned version |
|---|---|
| anyxmlNo plan to support | Not planned |
| argumentNo plan to support | Not planned |
| augment | Goldeneye |
| base | Planned in Hummingbird |
| belongs-to | Goldeneye |
| bit | Goldeneye |
| case | Goldeneye |
| choice | Goldeneye |
| config | Falcon |
| contact | Goldeneye Enhancement Planned in Hummingbird |
| container | Falcon |
| default | Goldeneye Enhancement Planned in Humminbird |
| description | Goldeneye Enhancement Planned in Hummingbird |
| deviateNo plan to support | Not planned |
| deviationNo plan to support | Not planned |
| enum | Goldeneye |
| error-app-tag | Planned in HummingbirdNot planned |
| error-message | Planned in HummingbirdNot planned |
| extensionNo plan to support | Not planned |
| feature | Planned in Hummingbird |
| fraction-digits | Goldeneye |
| grouping | Goldeneye |
| identity | Planned in Hummingbird |
| if-feature | Planned in Hummingbird |
| import | Goldeneye Enhancement in Hummingbird |
| include | Goldeneye Enhancement in Hummingbird |
| input | Goldeneye |
| key | Goldeneye |
| leaf | Falcon |
| leaf-list | Falcon |
| length | Goldeneye |
| list | Falcon |
| mandatory | Falcon |
| max-elements | Falcon |
| min-elements | Falcon |
| module | Falcon |
| must | Planned in Hummingbird |
| namespace | Goldeneye |
| notification | Goldeneye |
| ordered-by | Planned in HummingbirdNot planned |
| organization | Goldeneye Enhancement Planned in Hummingbird |
| output | Goldeneye |
| path | Planned in Hummingbird |
| pattern | Goldeneye |
| position | Goldeneye |
| prefix | Goldeneye |
| presence | Goldeneye |
| range | Goldeneye |
| reference | Goldeneye Enhancement Planned in Hummingbird |
| refineNo plan to support | Not planned |
| require-instance | No plan to supportNot planned |
| revision | Goldeneye Enhancement in Hummingbird |
| revision-date | Goldeneye |
| rpc | Goldeneye |
| status | Goldeneye Enhancement Planned in Hummingbird |
| submodule | Goldeneye |
| type | Goldeneye |
| typedef | Goldeneye |
| unique | Not Planned in Hummingbird |
| units | Goldeneye Enhancement Planned in Hummingbird |
| uses | Goldeneye |
| value | Goldeneye |
| when | Planned in Hummingbird |
| yang-version | Goldeneye |
| yin-element | No plan to supportNot Planned |
Built-in YANG data types support/plan
| Binary | Goldeneye Enhancement planned in Hummingbird |
| Bits | Goldeneye Enhancement planned in Hummingbird |
| boolean | Goldeneye |
| decimal64 | Goldeneye Enhancement planned in Hummingbird |
| empty | Goldeneye |
| enumeration | Goldeneye |
| identityref | Planned in Hummingbird |
| instance-identifier | Planned in Hummingbird |
| int8 | Goldeneye |
| int16 | Goldeneye |
| int32 | Goldeneye |
| int64 | Goldeneye |
| leafref | Planned in Hummingbird |
| string | Falcon |
| uint8 | Goldeneye |
| uint16 | Goldeneye |
| uint32 | Goldeneye |
| uint64 | Goldeneye |
| union | Goldeneye |
Generated JAVA
...
Details
Common behavior
Identifier
The identifier name of yang constructs are taken, and are used in java by converting it to lower camel case. Identifier names are allowed to have three special characters such as “-”, ”_”, “.”. Whereas, in java, we cannot use these special characters. Hence, users are provided option to replace these characters by any word in config of pom.xml. If users don't set it, these characters These characters will be removed during conversion. Conversion takes place by following the below rules of lower camel case.
...
The package will have “org.onosproject.yang.gen.v1.” by default in it. The namespace will be added to the above and the folder structure will also be formed respectively. This becomes the parent package.
When a node occurs in yang, a new package will be generated under the parent package. The new package name is the node name and class for that node will be placed under this newly created package. The conversion from yang namespace to the java package will take place as below.
The complete namespace will be changed to lowercase letters. When special characters or a group of special characters are found, it replaces those characters by dot.
"http://acme.example.com/system" will be mapped as org.onosproject.yang.gen.v1.http.acme.example.com.system.rev20160427
In java the package cannot have folder name which begins with digits or java keyword. Incase if found in YANG file these will be converted by adding prefix “yangautoprefix”.
http://acme.123example.com/try" will be mapped as org.onosproject.yang.gen.v1.http.acme.yangautoprefix123example.com.yangautoprefixtry.rev20160427
- At the end of the package the revision in module will be added by the string rev<yyyymmdd>.If the revision does not exist in the yang file current date will be appended to the package.
Javadocs
Currently Java doc will be generated as per Onos ONOS javadoc guidelines for class, interface, enum etc. i.e “Represents ....”.
Note: Here in wiki for the given examples for each YANG construct we have removed generated javadocs for documentation purpose . Code will contain all the default javadoc which we are providing in golden-eye release. Javadocs support will be enhanced in hummingbird release.
...
- Service interface
It includes:
a) java methods corresponding to the YANG RPC (Refer RPC section for more details)
b) If module contains notification, generated service interface will extend listener service (refer notification for more details) - Manager class
It includes:
a ) Activate/Deactivate methods
b) If module contains child data nodes, empty getters and setters for those nodes will be generated for app designer developers to implement.
c)If module contains notification, generated manager class will extend ListenerRegistry(refer notification for more details) .
The manager class implements the service interface. The name of service interface and manager class is <module_name>Service.java and <module_name>Manager.java.
...
| Code Block |
|---|
File : ospf.yang
module ospf {
namespace "http://example.com/ospf";
prefix "ospf";
notification test {
leaf event-class {
type string;
}
leaf severity {
type string;
}
}
}
File : OspfManager.java
package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.event.ListenerRegistry;
import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfEvent;
import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfListener;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
@Component (immediate = true)
@Service
public class OspfManager
extends ListenerRegistry<OspfEvent, OspfListener>
implements OspfService {
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
//TODO: YANG utils generated code
log.info("Started");
}
@Deactivate
public void deactivate() {
//TODO: YANG utils generated code
log.info("Stopped");
}
}
File : OspfService.java
package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519;
import org.onosproject.event.ListenerService;
import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfEvent;
import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfListener;
public interface OspfService
extends ListenerService<OspfEvent, OspfListener> {
}
File : OspfEvent.java
package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160527.ospf;
import org.onosproject.event.AbstractEvent;
public class OspfEvent extends AbstractEvent<OspfEvent.Type, OspfEventSubject> {
public enum Type {
TEST
}
public OspfEvent(Type type, OspfEventSubject subject) {
super(type, subject);
}
public OspfEvent(Type type, OspfEventSubject subject, long time) {
super(type, subject, time);
}
}
File : OspfEventSubject.java
package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf;
public class OspfEventSubject {
private Test test;
public Test test() {
return test;
}
public void test(Test test) {
this.test = test;
}
}
File : OspfListener.java
package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf;
import org.onosproject.event.EventListener;
public interface OspfListener extends EventListener<OspfEvent> {
}
File : Test.java
package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf;
import org.onosproject.yangutils.translator.tojava.AugmentationHolder;
public interface Test extends AugmentationHolder {
String eventClass();
String severity();
interface TestBuilder {
String eventClass();
String severity();
TestBuilder eventClass(String eventClass);
TestBuilder severity(String severity);
Test build();
}
}
File : TestBuilder.java
package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf;
import com.google.common.base.MoreObjects;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.onosproject.yangutils.translator.tojava.AugmentedInfo;
public class TestBuilder implements Test.TestBuilder {
private String eventClass;
private String severity;
@Override
public String eventClass() {
return eventClass;
}
@Override
public String severity() {
return severity;
}
@Override
public TestBuilder eventClass(String eventClass) {
this.eventClass = eventClass;
return this;
}
@Override
public TestBuilder severity(String severity) {
this.severity = severity;
return this;
}
@Override
public Test build() {
return new TestImpl(this);
}
public TestBuilder() {
}
public final class TestImpl implements Test {
private List<AugmentedInfo> augmentedInfoList = new ArrayList<>();
private String eventClass;
private String severity;
@Override
public String eventClass() {
return eventClass;
}
@Override
public String severity() {
return severity;
}
@Override
public int hashCode() {
return Objects.hash(eventClass, severity);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof TestImpl) {
TestImpl other = (TestImpl) obj;
return
Objects.equals(eventClass, other.eventClass) &&
Objects.equals(severity, other.severity);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("eventClass", eventClass)
.add("severity", severity)
.toString();
}
public TestImpl(TestBuilder builderObject) {
this.eventClass = builderObject.eventClass();
this.severity = builderObject.severity();
}
@Override
public void addAugmentation(AugmentedInfo value) {
getAugmentedInfoList().add(value);
}
@Override
public List<AugmentedInfo> getAugmentedInfoList() {
return augmentedInfoList;
}
@Override
public void removeAugmentation() {
getAugmentedInfoList().clear();
}
}
} |
Goldeneye
Enhancement in Hummingbird