No, that's wrong. To create ( and shut down GraphDatabaseService in
your bean, you should:
1) create @Singleton session bean. In its @PostConstruct method,
create appropriate GraphDataBase service object, and stop it in
@PreDestroy method. You can mark that bean as created on startup, if
you wish to get possible database errors on deployment instead of the
first use.
2) create producer method for GraphDataBaseService :
    @Produces public GraphDataBaseService getDatabase() { return db; }
3) inject GraphDataBaseService wherever you need it:
    @Inject private GraphDataBaseService db;
The most tricky part is Transaction synchronization. There are two options:
- manage transactions in your code by GraphDataBaseService , if you
don't need to synchronize it with other resources.
- create custom TransactionManagerProvider that enforces Neo4j to use
TransactionManager provided by server instead of built-in. You can
grab such code from Spring Data Graph project or my Neo4j connector.
Spring implementation injects TransactionManager from framework, so
you will need at least spring core while my code gets
TransactionManager from JNDI, that works in some servers only. All
other resources participated the same transaction with Neo4j should
also use XA Transactions.

On Fri, Jul 22, 2011 at 12:02 PM, eialbur <ronalb...@gmail.com> wrote:
> Sorry for the quantity of my questions, and I apologize in advance if any of
> them are trivial or stupid.
>
>
> ok - so I guess that in my Session Bean I would use the regular old
> @Resource annotation:
> @Resource
> GraphDatabaseService graphDb;
>
>
> Or do I need to declare Neo to jndi and then reference it?
> @Resource(name="neo/myGraphDb")
> GraphDatabaseService graphDb;
>
>
> Do I have to update the server.xml file so graphDb knows what to open?  I am
> assuming that there is no connection pooling.  I am assuming that my Session
> Bean does not need to be a Singleton.
>
> Is an alternative for me to actually open in ejbCreate?
> As you stated, it is important to release everything when I'm done ... would
> that be done thru ejbRemove?
>
>
> OK - so now I'll need XA transaction support.  I have never done anything
> with XA.  I am trying to look up articles on Google for Glassfish ... so far
> I have found very little.  I'm not sure yet if Glassfish has built-in
> support for XA (I'm assuming it does) and I can just use the
> javax.transaction package, or if I have to do special app server
> configuration ... and not yet sure if/how to set it all up as a container
> managed transaction.  Can you tell I am not yet comfortable with J2EE?  :-)
>
> Frankly, I am evaluating the use cases to see if I ever need to share a
> transaction with the database or if they are always separate (or if I can
> design so they are always separate).  I am essentially using Neo4j as a
> hierarchic index against a mysql table ..  lots of queries but very very few
> inserts or updates.
>
>
>
>
> --
> View this message in context: 
> http://neo4j-community-discussions.438527.n3.nabble.com/Officially-supported-mechanism-for-J2EE-tp3176938p3192177.html
> Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
_________________
entia non sunt multiplicanda praeter necessitatem,
(entities should not be multiplied beyond necessity.)
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to