Where to find examples for parsing YANG files using opendaylight - opendaylight

I added the following dependency in my pom.xml
<dependencies>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-impl</artifactId>
<version>2.1.8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-api</artifactId>
<version>2.1.8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
<version>2.1.8</version>
<type>jar</type>
</dependency>
</dependencies>
Then I tried to find documentation on how to parse the .yang/.yi files to build Schema.
I found the following example here:
https://docs.opendaylight.org/en/stable-boron/developer-guide/yang-tools.html
StatementStreamSource yangModuleSource == new YangStatementSourceImpl("/example.yang", false);
StatementStreamSource yangModuleSource2 == new YangStatementSourceImpl("/example2.yang", false);
CrossSourceStatementReactor.BuildAction reactor == YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(yangModuleSource, yangModuleSource2);
SchemaContext schemaContext == reactor.buildEffective();
However I cannot find the class YangStatementSourceImpl or YinStatementSourceImpl in these jars.
So my question is:
Where can I find these classes, YangStatementSourceImpl or YinStatementSourceImpl ?
How is opendaylight versions like baron, oxygen ... matched to the maven module here: https://mvnrepository.com/artifact/org.opendaylight.yangtools ?
br,
//mike

These classes have been deprecated; their replacements are YangStatementStreamSource and YinStatementStreamSource. To initialise the first stream in the example, you should now write
YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.forFile(new File("/example.yang"));
StatementStreamSource yangModuleSource = YangStatementStreamSource.create(yangTextSchemaSource);
YANG Tools artifacts have only been published to Maven Central since Fluorine; you’ll find the corresponding versions in the platform versions table. Version 2.1.8, which you’re currently using, is targeted for Neon which is currently being released.

Related

Programmatically retrieve all Maven dependencies

How can I in an very easy way retrieve all direct and transitive dependencies for a given Maven POM in my own Java program?
I aware of the existing questions on Stackoverflow, especially the one using Ivy to resolve the dependencies. I am looking for a solution using Maven, which is able also to resolve the transitive dependencies.
If you need this during a Maven build, you can easily access it in a Maven plugin using project.getDependencies().
If you have a standalone Java program, you can use Maven resolver or the older Aether libraries to do the resolution.
I was now able to solve the problem by using JBoss Shrinkwrap.
Here is a code snipped similar to the one I now use in my tools:
MavenStrategyStage resolve =
Maven.configureResolver()
// do not consult Maven Central or any other repository
.workOffline()
// import the configuration of the given settings.xml
.fromFile(homeDir + "/jqa-release-environment/maven-settings.xml")
// load the POM you would like to analyse
.loadPomFromFile(pomFile)
.importCompileAndRuntimeDependencies()
.importRuntimeAndTestDependencies()
.resolve();
MavenWorkingSession mavenWorkingSession =
((MavenWorkingSessionContainer) resolve).getMavenWorkingSession();
List<MavenDependency> dependencies = new ArrayList<>();
dependencies.addAll(mavenWorkingSession.getDependenciesForResolution());
dependencies.addAll(mavenWorkingSession.getDependencyManagement());
To be able to use Shrinkwrap, I added the following dependencies to my POM.
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<type>pom</type>
<version>3.1.4</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<version>3.1.4</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-api-maven</artifactId>
<version>3.1.4</version>
</dependency>

Why Akka-Http still uses older Akka-Actor?

I have added the latest akka-http to my project but that includes the very old 2.4.19 version on akka-actor. Hence I also added akka-actor version 2.5.4 to the dependency. However, that results into following error:-
Detected java.lang.NoSuchMethodError error, which MAY be caused by incompatible Akka versions on the classpath.
My maven config is like below:-
<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http_2.11</artifactId>
<version>10.0.9</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.5.4</version>
</dependency>
</dependencies>
What am I missing? Is there any version of akka-http which uses the latest akka-actor?
Update: Added dependency graph
From the Compatibility Guidelines page in the documentation:
Akka HTTP 10.0.x is (binary) compatible with both Akka 2.4.x as well as Akka 2.5.x, however in order to facilitate this the build (and thus released artifacts) depend on the 2.4 series. Depending on how you structure your dependencies, you may encounter a situation where you depended on akka-actor of the 2.5 series, and you depend on akka-http from the 10.0 series, which in turn would transitively pull in the akka-streams dependency in version 2.4 which breaks the binary compatibility requirement that all Akka modules must be of the same version, so the akka-streams dependency MUST be the same version as akka-actor (so the exact version from the 2.5 series).
In order to resolve this dependency issue, you must depend on akka-streams explicitly, and make it the same version as the rest of your Akka environment....
Change your Maven dependencies to the following:
<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.5.4</version>
</dependency>
<!-- Explicitly depend on akka-streams in same version as akka-actor -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-stream_2.11</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http_2.11</artifactId>
<version>10.0.9</version>
</dependency>
</dependencies>

Maven dependency for javax.mail

What is the maven dependency i should add for
import javax.mail.*;
import javax.mail.internet.*;
Adding the maven dependency from here http://mvnrepository.com/artifact/javax.mail/mail/1.5.0-b01 makes some of the jersey dependencies unable to retrieve error. What do you think is going wrong?
The version 1.6.3 had been the last version of JavaMail; since 2019-07-03, the new name for it is "Jakarta Mail".
Together with the name change also the Maven coordinates got different:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>…</version>
</dependency>
The project homepage can be found here: https://eclipse-ee4j.github.io/mail/
We are using following dependency:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>

Is there a link between org.wildfly.bom and the version of the wildfly server used?

I'm currently developing some applications and I'm using wildfly 9.0.2.Final as the application server. Currently I'm using bom version 8.2.2.Final for the following artifacts:
jboss-javaee-7.0-with-tools
jboss-javaee-7.0-with-hibernate
jboss-javaee-7.0-with-security
I've started using these versions while following a tutorial. However I've seen that now wildfly 10 is out and probably some other dependencies also have dependencies. Maybe in the future javaee-8.0 will be available.
Is there some documentation on what the different artifacts include and maybe what should be kept in mind when upgrading the parent bom version?
With WildFly 9+ boms we changed structure a bit, so now we only have 2 boms.
Where most of them were merged into one.
wildfly-javaee7
wildfly-javaee7-with-tools
Where second one includes not only APIs but also tools that are useful for testing like arquillian, junit, etc...
so best for your needs would be to use this in your pom.xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-javaee7-with-tools</artifactId>
<scope>import</scope>
<type>pom</type>
<version>10.0.0.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
you can always find latest info and docs on how to use it at github at repository https://github.com/wildfly/boms
Your BOM version should match your deployment Wildfly version.
Assuming you use provided scope for dependencies that are provided by Wildfly, you want to ensure you're using the correct versions. If you use a wrong version, your application might not work as expected or even fail to start, because some API might be deprecated/removed, or because some features might not be available yet.
Side note: Wildfly BOMs lack some dependencies, so we're using parent as BOM:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-parent</artifactId>
<version>9.0.2.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Cannot find SerialAddress class in Apache Mina 2.0.2

I added the below dependencies in my project POM file and the SerialAddress class is no where to be found from the downloaded mina-core.2.0.2.jar.
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.0.2</version>
</dependency>
the package org.apache.mina.transport.serial doesnt even exist. Please advice me on the correct Dependency.
It looks like this class is not part of mina-core. Some exploration lead to the existence of Apache Mina Serial Communication Support.
So I guess you would want to add the dependency for mina-transport-serial.
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-transport-serial</artifactId>
<version>2.0.2</version>
</dependency>

Resources