6 Replies Latest reply on Jan 26, 2017 5:33 AM by melo.d

    Mongodb addon request

    melo.d

      Can I request mongodb driver addon? I prefer asynchronous mongodb driver since it promising fast performance . At least for compile scope, I think what we need is Mongodb driver and netty. Then we may connect via ssl. For synchronous mongodb driver we may connect via jndi. Only mongodb enterprise may connect authentication.

      I tried to authoring add-on but still can't find out how. It will be nice if somebody may help me. At least tell me a bit to create a compile scope add-on for installing asynchronous mongodb driver. 

        • 1. Re: Mongodb addon request
          gastaldi

          Hi Melo,

           

          You can create a new addon by running the following command:

           

          project-new --named mongodb --type forge-addon

           

          Then create a command by creating a class implementing the UICommand

          interface. There is a hands-on-lab that illustrates that:

          http://forge.jboss.org/document/hands-on-lab

           

          Have a look at how the core addons are implemented to get an idea of how to

          implement addons: https://github.com/forge/core

           

          There are some videos that may help you too:

          https://www.youtube.com/c/JBossForgeVideos

           

          Anyway let me know if you need more help, I'd be glad to help you set this

          up.

           

          Best regards,

           

          George Gastaldi

           

          Em 21 de jan de 2017 11:13, "melo.d" <do-not-reply@jboss.com> escreveu:

           

          JBoss Developer <https://developer.jboss.org/?et=watches.email.thread>

          Mongodb addon request

           

          created by melo d'ramatis

          <https://developer.jboss.org/people/melo.d?et=watches.email.thread> in

          Forge - View the full discussion

          <https://developer.jboss.org/message/967814?et=watches.email.thread#967814>

          1 of 1 people found this helpful
          • 2. Re: Mongodb addon request
            melo.d

            I think I have problem with gradle. I tried

            project-new --named mongodb --type forge-addon

            But I got this error

             

            ***ERROR*** Project location 'F:\kontener\tempat\jdepot\jwork\mongodb' is not empty.

            [jwork]$ project-new --named mongodb --type forge-addon

            ***ERROR*** Error while executing 'Furnace Addon Setup'

            ***INFO*** (type "export VERBOSE=true" to enable stack traces)

            ***ERROR*** Cannot resolve ambiguous facet type [org.jboss.forge.addon.parser.java.facets.JavaSourceFacet] because multiple matching types were found:

            [org.jboss.forge.addon.maven.projects.facets.MavenJavaSourceFacet from addon org.jboss.forge.addon:maven,3.4.0.Final,

            org.jboss.forge.addon.gradle.projects.facets.GradleJavaSourceFacet from addon org.jboss.forge.addon:gradle,3.0.0-SNAPSHOT]

             

            Seems I got this error after installing gradle addon. Is it possible create addon with gradle? Should I remove gradle addon or something and how?

            • 3. Re: Mongodb addon request
              gastaldi

              Yeah, looks like the Gradle addon is causing this. Type addon-remove  escreveu:

               

              JBoss Developer <https://developer.jboss.org/?et=watches.email.thread>

              Mongodb addon request

               

              reply from melo d'ramatis

              <https://developer.jboss.org/people/melo.d?et=watches.email.thread> in

              Forge - View the full discussion

              <https://developer.jboss.org/message/967817?et=watches.email.thread#967817>

               

              • 4. Re: Mongodb addon request
                melo.d

                Sorry if this a newbie question. I want the addon install mongodb-driver-async to the project, so I just modify the pom.xml like this:

                 

                <?xml version="1.0" encoding="UTF-8"?>

                <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

                  <modelVersion>4.0.0</modelVersion>

                  <groupId>org.mongodb</groupId>

                  <artifactId>mongodb</artifactId>

                  <version>1.0.0-SNAPSHOT</version>

                  <build>

                    <finalName>mongodb</finalName>

                    <plugins>

                      <plugin>

                        <artifactId>maven-jar-plugin</artifactId>

                        <version>2.6</version>

                        <executions>

                          <execution>

                            <id>create-forge-addon</id>

                            <phase>package</phase>

                            <goals>

                              <goal>jar</goal>

                            </goals>

                            <configuration>

                              <classifier>forge-addon</classifier>

                            </configuration>

                          </execution>

                        </executions>

                      </plugin>

                    </plugins>

                  </build>

                  <properties>

                    <version.furnace>2.24.3.Final</version.furnace>

                    <maven.compiler.source>1.8</maven.compiler.source>

                    <maven.compiler.target>1.8</maven.compiler.target>

                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                    <version.forge>3.4.0.Final</version.forge>

                  </properties>

                  <profiles>

                    <profile>

                      <id>release</id>

                      <activation />

                      <build>

                        <plugins>

                          <plugin>

                            <groupId>org.jboss.forge.furnace</groupId>

                            <artifactId>furnace-maven-plugin</artifactId>

                            <version>${version.furnace}</version>

                            <executions>

                              <execution>

                                <id>generate-dot</id>

                                <phase>prepare-package</phase>

                                <goals>

                                  <goal>generate-dot</goal>

                                </goals>

                                <configuration>

                                  <attach>true</attach>

                                </configuration>

                              </execution>

                            </executions>

                          </plugin>

                        </plugins>

                      </build>

                    </profile>

                  </profiles>

                  <dependencies>

                    <dependency>

                      <groupId>org.jboss.forge.furnace.container</groupId>

                      <artifactId>cdi</artifactId>

                      <classifier>forge-addon</classifier>

                      <scope>provided</scope>

                    </dependency>

                    <dependency>

                      <groupId>org.jboss.forge.furnace.test</groupId>

                      <artifactId>furnace-test-harness</artifactId>

                      <scope>test</scope>

                    </dependency>

                    <dependency>

                      <groupId>org.jboss.forge.furnace.test</groupId>

                      <artifactId>arquillian-furnace-classpath</artifactId>

                      <scope>test</scope>

                    </dependency>

                    <dependency>

                      <groupId>org.jboss.forge.addon</groupId>

                      <artifactId>core</artifactId>

                      <classifier>forge-addon</classifier>

                    </dependency>

                        <dependency>

                        <groupId>org.mongodb</groupId>

                        <artifactId>mongodb-driver-async</artifactId>

                        <version>3.4.1</version>

                    </dependency>

                    <dependency>

                        <groupId>org.mongotest</groupId>

                        <artifactId>mongotest</artifactId>

                        <classifier>forge-addon</classifier>

                        <version>1.0.0-SNAPSHOT</version>

                        <scope>test</scope>

                    </dependency>

                  </dependencies>

                  <dependencyManagement>

                    <dependencies>

                      <dependency>

                        <groupId>org.jboss.forge</groupId>

                        <artifactId>forge-bom</artifactId>

                        <version>${version.forge}</version>

                        <type>pom</type>

                        <scope>import</scope>

                      </dependency>

                      <dependency>

                        <groupId>org.jboss.spec</groupId>

                        <artifactId>jboss-javaee-6.0</artifactId>

                        <version>3.0.3.Final</version>

                        <type>pom</type>

                        <scope>import</scope>

                      </dependency>

                    </dependencies>

                  </dependencyManagement>

                </project>

                 

                Do I do this right? And I want to test the addon with mongotest project. What is the type of this project should be? Is it forge-addon or may something else?

                • 5. Re: Mongodb addon request
                  gastaldi

                  Not really. If all you want is to install a dependency, you don't really

                  need to create an addon for that. You can use the project-add-dependencies

                  command in your project, like:

                   

                  1) Start Forge

                  2) cd to your project root (or create one using project-new --named

                  mongotest if you want a Web app)

                  3) project-add-dependencies org.mongodb:mongodb-driver-async:3.4.1

                   

                   

                  Em 23 de jan de 2017 00:32, "melo.d" <do-not-reply@jboss.com> escreveu:

                   

                  JBoss Developer <https://developer.jboss.org/?et=watches.email.thread>

                  Mongodb addon request

                   

                  reply from melo d'ramatis

                  <https://developer.jboss.org/people/melo.d?et=watches.email.thread> in

                  Forge - View the full discussion

                  <https://developer.jboss.org/message/967830?et=watches.email.thread#967830>

                  • 6. Re: Mongodb addon request
                    melo.d

                    That's much simpler than I expected. However, another noob questions:

                    1. I install mongodb addon I created to maven local repo by mistake. How to remove it?

                    2. I want to do a test by creating project like above. Add Netty from maven central as dependency. And add like from this QuickTour , something like:

                     

                    package mongotest;

                     

                    import com.mongodb.Block;

                    import com.mongodb.async.SingleResultCallback;

                    import com.mongodb.async.client.MongoClient;

                    import com.mongodb.async.client.MongoClients;

                    import com.mongodb.async.client.MongoCollection;

                    import com.mongodb.async.client.MongoDatabase;

                    import com.mongodb.bulk.BulkWriteResult;

                    import com.mongodb.client.model.BulkWriteOptions;

                    import com.mongodb.client.model.DeleteOneModel;

                    import com.mongodb.client.model.InsertOneModel;

                    import com.mongodb.client.model.ReplaceOneModel;

                    import com.mongodb.client.model.UpdateOneModel;

                    import com.mongodb.client.model.WriteModel;

                    import com.mongodb.client.result.DeleteResult;

                    import com.mongodb.client.result.UpdateResult;

                    import org.bson.Document;

                     

                    import java.util.ArrayList;

                    import java.util.List;

                    import java.util.concurrent.CountDownLatch;

                     

                    import static com.mongodb.client.model.Accumulators.sum;

                    import static com.mongodb.client.model.Aggregates.group;

                    import static com.mongodb.client.model.Aggregates.match;

                    import static com.mongodb.client.model.Aggregates.project;

                    import static com.mongodb.client.model.Filters.and;

                    import static com.mongodb.client.model.Filters.eq;

                    import static com.mongodb.client.model.Filters.exists;

                    import static com.mongodb.client.model.Filters.gt;

                    import static com.mongodb.client.model.Filters.gte;

                    import static com.mongodb.client.model.Filters.lt;

                    import static com.mongodb.client.model.Filters.lte;

                    import static com.mongodb.client.model.Projections.excludeId;

                    import static com.mongodb.client.model.Sorts.descending;

                    import static com.mongodb.client.model.Updates.inc;

                    import static com.mongodb.client.model.Updates.set;

                    import static java.util.Arrays.asList;

                    import static java.util.Collections.singletonList;

                     

                    /**

                    * The QuickTour code example see: https://mongodb.github.io/mongo-java-driver/3.0/getting-started

                    */

                    public class QuickTour {

                        /**

                         * Run this main method to see the output of this quick example.

                         *

                         * @param args takes an optional single argument for the connection string

                         * @throws InterruptedException if a latch is interrupted

                         */

                        public static void main(final String[] args) throws InterruptedException {

                            MongoClient mongoClient;

                     

                            if (args.length == 0) {

                                // connect to the local database server

                                mongoClient = MongoClients.create("mongodb://localhost/?streamType=netty&ssl=true");

                            } else {

                                mongoClient = MongoClients.create(args[0]);

                            }

                     

                            // get handle to "mydb" database

                            MongoDatabase database = mongoClient.getDatabase("mydb");

                     

                     

                            // get a handle to the "test" collection

                            final MongoCollection<Document> collection = database.getCollection("test");

                     

                            // drop all the data in it

                            final CountDownLatch dropLatch = new CountDownLatch(1);

                            collection.drop(new SingleResultCallback<Void>() {

                                @Override

                                public void onResult(final Void result, final Throwable t) {

                                    dropLatch.countDown();

                                }

                            });

                            dropLatch.await();

                     

                            // make a document and insert it

                            Document doc = new Document("name", "MongoDB")

                                    .append("type", "database")

                                    .append("count", 1)

                                    .append("info", new Document("x", 203).append("y", 102));

                     

                            collection.insertOne(doc, new SingleResultCallback<Void>() {

                                @Override

                                public void onResult(final Void result, final Throwable t) {

                                    System.out.println("Inserted!");

                                }

                            });

                     

                     

                            // release resources

                            mongoClient.close();

                        }

                    }

                     

                    How to do the test. Maybe using Arquillian or something?

                     

                    Edit: Sorry for the noob question. I think I need to look the hands-on lab tutorial first. And mongodb. Edit again: I think I forgot the persistence. I just want to add a name to the mongodb and see if its added.