<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:54 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-715] Web support for MongoDB</title>
                <link>https://jira.mongodb.org/browse/JAVA-715</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;It doesn&apos;t exist &quot;official&quot; support for using MongoDB in Web Apps. I attach my Java code with my idea to help support for Web. To use it, declare the Servlet Context Listener in the web.xml like this : &lt;/p&gt;

&lt;p&gt;----------------------------------------------&lt;br/&gt;
&amp;lt;listener&amp;gt;&lt;br/&gt;
	&amp;lt;listener-class&amp;gt;com.mongodb.web.MongoServletContextListener&lt;br/&gt;
	&amp;lt;/listener-class&amp;gt;&lt;br/&gt;
&amp;lt;/listener&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;context-param&amp;gt;&lt;br/&gt;
	&amp;lt;param-name&amp;gt;mongoURI&amp;lt;/param-name&amp;gt;&lt;br/&gt;
	&amp;lt;param-value&amp;gt;mongodb://localhost:27017&amp;lt;/param-value&amp;gt;&lt;br/&gt;
&amp;lt;/context-param&amp;gt;&lt;br/&gt;
----------------------------------------------&lt;/p&gt;

&lt;p&gt;This listener :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;on the contextInitialized : initialize the static variable Mongo of the MongoProvider with the &quot;mongoURI&quot; param-value.&lt;/li&gt;
	&lt;li&gt;on the contextDestroyed : close the connection of the static variable Mongo&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Once this listener is started, you can use MongoProvider.getMongo() in any code (Servlet, Filter, Services, etc) to use Mongo.&lt;/p&gt;</description>
                <environment></environment>
        <key id="59391">JAVA-715</key>
            <summary>Web support for MongoDB</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="angelozerr">Angelo</reporter>
                        <labels>
                    </labels>
                <created>Fri, 14 Dec 2012 09:47:29 +0000</created>
                <updated>Sat, 15 Dec 2012 17:59:50 +0000</updated>
                            <resolved>Sat, 15 Dec 2012 03:03:59 +0000</resolved>
                                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="215945" author="angelozerr" created="Sat, 15 Dec 2012 17:59:50 +0000"  >&lt;p&gt;Thank&apos;s Scott for this information. I could replace my MongoProvider with your Holder.&lt;/p&gt;

&lt;p&gt;My goal is to use MongoDB in a WebApp with JEE feature with &quot;official&quot; classes. I thought that ServletContextListener was the best mean to initialize MongoDB and that Driver could host those classes.&lt;/p&gt;

&lt;p&gt;But if I have understood you prefer not to have dependencies to JEE. Perhaps we could create a new project &quot;JEE support for MongoDB&quot; for Web and JAX-RS.&lt;/p&gt;
</comment>
                            <comment id="215849" author="scotthernandez" created="Sat, 15 Dec 2012 14:59:17 +0000"  >&lt;p&gt;If your goal is just to use a singleton Mongo then you can use the Mongo.Holder class: &lt;a href=&quot;http://api.mongodb.org/java/current/com/mongodb/Mongo.Holder.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://api.mongodb.org/java/current/com/mongodb/Mongo.Holder.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the class-loader gets destroyed then all held instanced will be cleaned up.&lt;/p&gt;</comment>
                            <comment id="215810" author="angelozerr" created="Sat, 15 Dec 2012 13:50:51 +0000"  >&lt;p&gt;OK I understand. But I think it should be very cool if it exists an &quot;official&quot; javax.* support for MongoDB. I mean : &lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Web support like this issue.&lt;/li&gt;
	&lt;li&gt;JAX-RS support that I have done (I will explain you if you are interested).&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Perhaps the &quot;official&quot; javax.* support for MongoDB should be created in other project than the driver?&lt;/p&gt;</comment>
                            <comment id="215773" author="jeff.yemin" created="Sat, 15 Dec 2012 12:26:07 +0000"  >&lt;p&gt;Lots of users run mongo in a non-J2EE environment.&lt;/p&gt;

&lt;p&gt;Also, lots of users create Mongo instances in different ways, like via an IOC container like Guice or Spring, so the code here would not be generically useful enough to warrant inclusion.&lt;/p&gt;</comment>
                            <comment id="215744" author="angelozerr" created="Sat, 15 Dec 2012 11:09:08 +0000"  >&lt;p&gt;Thank  a lot Jeff for your answer.&lt;/p&gt;

&lt;p&gt;What is the problem with a dependency on non-JAVA SE packages? I tell me that you must just add dependency servlet-api to your pom just to &quot;compile&quot; the driver.&lt;/p&gt;

&lt;p&gt;For OSGi, you must just import package &quot;javax.servlet&quot; as &quot;optionnal&quot;.&lt;/p&gt;

&lt;p&gt;I had intention to create a new issue for JAX-RS support for MongoDB, but if you don&apos;t want add some dependencies, I will not create it. I&apos;m writing articles in my blog to explain that.&lt;/p&gt;</comment>
                            <comment id="215550" author="jeff.yemin" created="Sat, 15 Dec 2012 03:03:59 +0000"  >&lt;p&gt;Thank you for this contribution, and let us know if there is anything else you&apos;d like to see in the driver.&lt;/p&gt;</comment>
                            <comment id="215549" author="jeff.yemin" created="Sat, 15 Dec 2012 03:03:01 +0000"  >&lt;p&gt;I don&apos;t think we will add this to the driver, as it will create a dependency on non-JAVA SE packages.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="22505" name="MongoProvider.java" size="563" author="angelozerr" created="Fri, 14 Dec 2012 09:47:29 +0000"/>
                            <attachment id="22504" name="MongoServletContextListener.java" size="1095" author="angelozerr" created="Fri, 14 Dec 2012 09:47:29 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrl37r:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>36852</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>