You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 12 Members of 9401 |
| Forum: Weld Users |
03. Jan 2009, 22:36 America/New_York | Link |
Since WebBeans claims to be a standard for dependency injection, would we be able to use WebBeans in non-web environment if we are looking for the dependency injection only?
Regards
28 Replies: | |||
|---|---|---|---|
Gavin King wrote on Jan 04, 2009 01:08: Why would I need an embeddable EJB when I will only be using the WebBeans for injection? Doesn't that sound a bit too bloated? |
|||
Not to me, no. I can't imagine what the usefulness of dependency injection would be without support for things like JDBC datasources, transaction demarcation, JPA, etc. If you look at Spring for example, it also has all this functionanality. Is Spring therefore Learn more about Weld... |
|||
He may be asking only the IOC container to inject the object. You can use google guice as IOC right? If i am wrong correct me. |
|||
Krishna Srinivasan wrote on Jan 07, 2009 12:29: Yes Krishna. Guice or Pico would be a good example for this. :-) |
|||
Gavin King wrote on Jan 05, 2009 06:52: But Gavin, Spring won't force me to deploy the apps in a JEE environment. I can just use a servlet container. Infact I can use Spring in a non web environment. As for the JDBC datasource Spring can use Commons-DBCP or c3p0. What's the whole point using WebBeans in a full-blown appserver if I can use a servlet container? |
|||
Joshua Partogi wrote on Jan 08, 2009 02:28: Perhaps I'm being dense but I simply don't understand the difference here. Web Beans doesn't require an EE server in the traditional sense, just an EE6 web profile, or embeddable EJB lite. If I use Spring in Tomcat, I have a servlet engine, Spring's dependency injection engine, Spring interceptors, Spring's proprietary transaction management/demarcation stuff, DBCP or c3p0, Hibernate, Spring's persistence context management stuff. If I use the an EE 6 Web Profile, I have a servlet engine, web beans dependency injection, interceptors, EJB for transaction demarcation and persistence context management, a JDBC datasource, JPA. i.e. exactly the same list of stuff! But standards-compliant. Joshua, have you actually read up about the EE web profile and EJB Lite? It sounds like you're still stuck in thinking that EE implies the full list of technologies that are required in EE5. It doesn't. Learn more about Weld... |
|||
The precise list of technologies for the web profile is still under discussion, but it looks like will be something like:
where EJB Lite is defined as: The EJB Lite API is composed of the following subset of the EJB API : If anything, this is a smaller footprint than Tomcat+Spring today. Let me turn the question around: if you're a Web Beans user, why on earth would you not want one of the things in that list of technologies? (OK, some people may decide to use proprietary web frameworks instead of JSF and JAX-RS, but nothing stops them.) Learn more about Weld... |
|||
Gavin King wrote on Jan 08, 2009 03:53: Perhaps if I was implementing one of the above technologies, assuming I could use a Web Beans platform that only included Java SE stuff. Gavin King wrote on Jan 01, 2009 14:33: I could be very wrong here but: If they used it as their microcontainer then I'd imagine that they made heavy use of the pure SE dependency injection, interceptor, delegator and event frameworks in order to build a platform into which they then integrated their existing EE stuff to end up with a full Web Beans stack. Disclaimer: I have no irrational fear of the letters E, J and B, nor any phychological issues that I'm aware of :P. |
|||
In other words, I think what people are seeing is the future potential for JSR-299 to be split into a 2 parts: Part 1: is just those parts of the current JSR-299 which raise the semantic level of java and allow much easier integration of stuff with other stuff. Things like typesafe DI, interceptors, decorators, deployment types, the (synchronous) event model. Maybe contexts and/or Unified EL? Part 2: is Web Beans, with a dependency on Part 1. It will use part 1 to integrate all the Java EE stuff and also add the EE-specific extensions like session bean support, servlet integration, JPA, JMS endpoints, asynchronous event model etc. |
|||
Possibly the disconnect comes from what people mean by the term When I'm using the term, I mean the set of requirements an implementation has to fulfill in order to certify compliance with the JSR-299 TCK and use the brand "Web Beans" in its product marketing. Now, that doesn't constrain an actual implementation of JSR-299 from executing in some other environment without support for certain EE technologies. There's nothing in the specification to stop you from doing that. Hell, we even test the RI like that! However, that's not "Web Beans" as defined by the specification, it can't be tested by the TCK and it can't be certified compatible with the specification or other implementation of the specification. Would it be possible for the 299 specification to define what an implementation of JSR-299 should do in an environment that doesn't support the other EE technologies? Sure, anything's possible. But is there any value in doing that from the point of view of a user who is concerned about portability of their application between different vendors? Well, I don't see how there could be... Learn more about Weld... |
|||
Again, if you look at the definitions, embeddable EJB lite + Web Beans is really not very different from your It has interceptors/decorators, deployment types, synchronous events, 2 of the 4 contexts, datasources, JPA and declarative transaction demarcation. It doesn't have servlet integration, presentation, JMS, asynchronicity, session/conversation contexts or EL. Are you really going to get that upset by the fact that it has JPA in there? Learn more about Weld... |
|||
Gavin King wrote on Jan 08, 2009 18:06: Not very different still means different though. :-) It has interceptors/decorators, deployment types, synchronous events, 2 of the 4 contexts, datasources, JPA and declarative transaction demarcation. It doesn't have servlet integration, presentation, JMS, asynchronicity, session/conversation contexts or EL. Are you really going to get that upset by the fact that it has JPA in there? I for sure won't be upset. But would really like know what is the technical reason not doing separate Part 1. It seams obvious to me to take such approach from architectural point of view. One can come up with many usages for such scenario. For example using WebBeans as skeleton for Maven 5 mojo handling with unnecessary JPA dependencies. ;-) |
|||
Not very different still means different though. :-) Well, sure, but the point is if we line up 10 guys and ask them what features should be in the EE web profile, we get 10 different answers. Trust me, I've seen this happen. I for sure won't be upset. But would really like know what is the technical reason not doing separate Part 1
What does It seams obvious to me to take such approach from architectural point of view. Java specifications don't define the architecture of things that implement them. The only define how the implementation interacts with the application. An implementation can have whatever architecture it likes. Nothing stops you from implementing 299 in layers if that is what you prefer. Learn more about Weld... |
|||
Gavin King wrote on Jan 08, 2009 17:54: Agreed! Now, that doesn't constrain an actual implementation of JSR-299 from executing in some other environment without support for certain EE technologies. ... But is there any value in doing that from the point of view of a user who is concerned about portability of their application between different vendors?
No, definitely not from that point of view, but possibly from others. Take JME or applets for example. Outside my JEE day job, I like messing around with Processing applets now and then - something people far more talented than myself do for a living. I think it would be great to be able to use I'm not saying this justifies any modification to the spec today. I just hope that the ability to run Web Beans in this zero-EE way remains so as to give people the opportunity to see if it's useful or not. I suspect there may be some weird and wonderful use cases for it, but only time will tell. I totally understand that this is nowhere near the target audience of the Web Beans spec, and that the recurrence of this theme is probably slightly tedious for you JBoss guys! Thanks for bearing with us as we explore all the possible implications, intended or otherwise, of this great spec :). |
|||
OK, I've made a proof of concept. It a bit rough and ready. But it's here for now: http://screamingcoder.com/projects/plebeians/plebeians.tar.gz. There's a simple example with that. The main things to know are:
@Params String[] whatever
Known issues:
|
|||
Oh yeah, and you start your app with this main method: com.screamingcoder.plebeians.StarMain |
|||
One possibility would be to make it an event, and the public static void main(@Observes Start start) {
String param = start.getParameter(0);
...
}
Or you could inject the parameters separately (using a producer method): public static void main(@Observes Start start, @Parameters List<String> parameters) {
String param = parameters.get(0);
...
}
I love the events stuff :-) Learn more about Weld... |
|||
Hi Pete ;-) I took a quick look at your code - it looks exactly like I had envisioned doing an SE extension of the RI would look like (which is good :-). Nice! I'm not quite sure which version of the RI you are working with, but I've altered the SPI a little recently, which should make your life easier:
Finally, are you interested in contributing this as module? As we currently have no modules, quite what this means is open to speculation ;-), but at the very least:
and for this module:
Drop me an email if you are, Pete Read about how to report a bug. |
|||
Gavin King wrote on Jan 16, 2009 07:28: Of course! Good idea. I've implemented it this way now. Gavin King wrote on Jan 16, 2009 07:28: Yeah I chose this approach exclusively. I like the decoupling since you may want to pass the params through some kind of validation/transformation as I do in my simple example. Then by the time they get to your business logic they're being injected as something more meaningful. Or you can just pass them straight in if you like! |
|||
Pete, I'm working with TRUNK. I've made some changes as per your suggestions and updated the archive linked above (all versions are listed at http://screamingcoder.com/projects/plebeians/). I've also Mavenised the projects so they're easier to work with. Pete Muir wrote on Jan 18, 2009 01:28: I've extended the PropertiesBasedBootstrap class - not sure if there's anything else I need to do? Pete Muir wrote on Jan 18, 2009 01:28: I think I know what you mean, but probably could use a better understanding of how contexts work in multi-threaded environments before I try to tackle this.. Pete Muir wrote on Jan 18, 2009 01:28:
Luckily this issue goes away since I'm now using an event to fire off the Pete Muir wrote on Jan 18, 2009 01:28: Will probably check this out next. Pete Muir wrote on Jan 18, 2009 01:28: Sounds like fun. I'll do a bit more work on it (the URL scanning at least) then I'll swing you an email. Cheers, |
|||
Pete, I'll email you the code over the weekend, then I promise to leave this thread alone :). I just want to know what group, artifact and package name you think I should use? If I get that right now I can continue working with it while you merge it in to SVN and the changes should be relatively easy to track (no major refactorings). Cheers, Pete. |
|||
We sure did. We're using the existing @Initialized Manager and @Deployed Manager events as hooks for application/module configuration and startup respectively. I'll be writing some documentation for this soon. |
|||
Hi Pete / Pete, Can either of you point me to the latest version of this code please? Is it already in the Web Beans SVN? Also in what release do we plan to include this. (when is the GA due?) Cheers! Nirav |
|||
Yes, it's in SVN - look in extensions/trunk/se - and built nightly. We will include it in the next release - a preview release of 1.0.0 - the core is fairly stable at this point. The 1.0.0 release date is currently unknown, as the spec has not been finalised yet. Read about how to report a bug. |
Certified Scrum Master
http://blog.scrum8.com
http://twitter.com/scrum8