I would like to use Google Guice (2.0 or 3.0, does not matter) for my Netbeans Platform Project. My Project has several Netbeans Modules. I managed to use Guice in a single Netbeans Module, but now I want to Inject a Dependency from one NBModule to another. Is this possible? I googled a lot and searched the mailing lists of netbeans and guice, but it seems like noone ever tried this.
I do not want to use the Lookup API for this, because I really need Dependency Injection for better testing.
Has anyone experiences with that?
Edit: To be more specific: Can i Use the same Injector for all NBModules or do I have to create an Injector for every Module?
I realize that this question is old, but since the subject is still relevant I decided to share my findings.
We successfully use Google Guice 3.0 in our Netbeans Platform project. This includes injecting dependencies across NBMs using one injector. The only issue we encountered was that Guice didn't recognize annotations in other NBMs, because they were loaded through other classloaders. See http://tkills.blogspot.com/2014/08/using-google-guice-in-netbeans-rcp.html for details.
I have not worked with Netbeans RCP, only with Eclipse RCP and with integration with Spring. We had to have separate Springs application context for every plugin, with one root context that was shared between all other plugins. So you would need similar thing, separate injectors for every modul. I am not sure but i thing Guice does not support concept of including one injector to another as parent injector.
Related
We have a J2EE application that we deploy to eg. tomcat. We use MagicDraw to model and generate our modelcode. We are currently looking at alternatives to MagicDraw.
I have previously used EMF:
http://www.eclipse.org/modeling/emf/
but that was inside an RCP application (handling dependencies through P2, maven/tycho).
Just a quick glance at the mvnrepository does not give too many results (of course we could upload necessary dependencies manually to our own )
http://mvnrepository.com/search.html?query=emf
How well does EMF work in a non RCP/OSGi application and are there any examples out there to get started?
A few resources I found:
http://www.fosslc.org/drupal/content/emf-large-scale-modeling-outside-eclipse
http://www.eclipsezone.com/eclipse/forums/t57389.html
It's not entirely clear if you are asking for a way to define models outside of an RCP app or if you simply want to work with the generated models.
It's relatively easy to work with emf from a regular Java or Java EE application. If you look for the keyword 'standalone' in the EMF FAQ you will find some useful information.
I got a little problem. I want to use hibernate in an eclipse rcp. (i'm new to osgi and eclipse rcp). So I added the jar into the plugin-project folder and the build path and the bundle build path, but when I try to use hibernate from my bundle, it crashes with a ClassNotFoundException.
What is the proper way to do this?
Pls look at eclipse buddy policy. This might help you if you are facing class not getting loaded because of osgi classloading.
Hibernate, and many other classic Java programs (ab)use dynamic class loading to to connect the different parts. They classes they use are read from a file and then loaded with Class.forName. This is fundamentally not-modular since these classes are by definition implementation classes, which should be hidden.
Since OSGi is a modularity framework it puts fences around a module (a bundle) and refuses to load anything that is not properly exported and imported. So if Hibernate does its Class.forName it will run right into this fence, as it should be to get the advantages of modularity.
Eclipse Buddy policy is like a huge hole in this fence, moving things back tot he bad old classpath: linear search. With a buddy policy, Eclipse will just start searching if there is a class somewhere that has that name. Since this ignores versions, you can no longer rely on proper version handling. The good news is that it works most of the time. The bad news is that you loose privacy and when it does not work you get weird errors.
With Hibernate, only solution is to not use the text file setup but use the API and give Hibernate the actual classes. In those cases Hibernate will use the class loader of those classes and that works. In OSGi, as long as you follow the Java language rules there are no problems.
To handle the kind of problems that class loading hacks address OSGi uses services.
How can I use the profiler from NetBeans 6.8 or 6.9 (choosing 'entire application') with guice enhanced classes?
I am using google guice 2.0 (with warp persist 2.0-20090214) for some classes and wanted to profile those classes. But I cannot see a result for those classes. The only result I can see is for one method 'EnhancedClass.access$000' which is not very helpful. Other classes are working.
Does somebody know a workaround? Or know what I am doing wrong?
The profiler produces these ugly results because there is no source code available to NetBeans for the enhanced classes. So you need to avoid that Guice needs to produce these classes in the first place by
breaking the circular dependency (-ies) that cause them,
or if you are using the AOP features of Guice I think you're out of luck
I work on a fairly simple but large two-tier application that consists approximately 40 Eclipse RCP plugins. We have a new use case that is taking us to the web for a very small portion of this functionality. I'd like to prototype this using Lift. Clearly, I'm facing a few challenges.
Lift + OSGi. Can Lift get at OSGi bundles? Can it be packaged as an OSGi bundle itself and integrated into a web container?
Build System. We use the archaic Eclipse PDE build (read: Eclipse has no build system) with Cruise Control. Lift uses Maven.
Development Environment. This one I'm not sure anyone can help me with. I've tried to use the Scala plugin with Eclipse and it's still not ready. There are just too many impediments to make it useful. Saying that, I don't see this as a major issue because I can keep all the Lift code in one module, only referencing the Java code a very specific areas.
I'm wondering if anyone has tried anything similar to this and has any advice. Note that I won't be using any of the ORM stuff in Lift because all persistence is managed in the existing plugins behind an API. So, am I barking up the wrong tree? Is there something else I need to be aware of?
I could revert to simply using these instructions but I'd really like to take Lift for a spin because Java is... well... it's Java. :-(
There's thread in google groups about using lift as an OSGi bundle.
For the build system as far as I remember PDE sit's on top of ant, so you can use maven for building lift related stuff first and then call PDE's build.xml
Is there any documentation about introducing jBoss seam to an old Hibernate/JSF project?
Have tried google, and what I found was: Start new seam project, copy&paste existing code into new project. Would be nice to know a little bit more before starting.
The best approach is probably to add the Seam library to your existing project, and then gradually refactor your code to take advantage of Seam's features. To do this, work through the Seam manual and refactor your code for each Seam feature that simplifies the JSF approach. This includes things like:
make your JSF action listener classes into Seam components (i.e. add one annotation)
merge action listener and EJB classes (action listeners can be EJBs in Seam)
inject a Seam managed persistence context instead of your existing Hibernate session
simplify page navigation rules using Seam navigation syntax
migrate views to Facelets, if you are still using JSP.
Basically, Seam will probably give you lots of ways to simplify your existing code, so apply them one at a time to see how they work.
This seems to be part of the solution:
http://www.mastertheboss.com/en/seam/63-jboss-seam-tutorial-1.html