Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6A6DB10A5B for ; Fri, 4 Oct 2013 09:17:16 +0000 (UTC) Received: (qmail 29185 invoked by uid 500); 4 Oct 2013 09:17:16 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 29114 invoked by uid 500); 4 Oct 2013 09:17:10 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 29081 invoked by uid 99); 4 Oct 2013 09:17:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Oct 2013 09:17:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Oct 2013 09:17:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D8EE523888E4; Fri, 4 Oct 2013 09:16:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1529107 - /openwebbeans/cms-site/trunk/content/cdi_explained.mdtext Date: Fri, 04 Oct 2013 09:16:42 -0000 To: commits@openwebbeans.apache.org From: struberg@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131004091642.D8EE523888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: struberg Date: Fri Oct 4 09:16:42 2013 New Revision: 1529107 URL: http://svn.apache.org/r1529107 Log: introduction chapter to CDI Modified: openwebbeans/cms-site/trunk/content/cdi_explained.mdtext Modified: openwebbeans/cms-site/trunk/content/cdi_explained.mdtext URL: http://svn.apache.org/viewvc/openwebbeans/cms-site/trunk/content/cdi_explained.mdtext?rev=1529107&r1=1529106&r2=1529107&view=diff ============================================================================== --- openwebbeans/cms-site/trunk/content/cdi_explained.mdtext (original) +++ openwebbeans/cms-site/trunk/content/cdi_explained.mdtext Fri Oct 4 09:16:42 2013 @@ -16,12 +16,85 @@ Notice: Licensed to the Apache Softwa specific language governing permissions and limitations under the License. -# OpenWebBeans FAQ +# What can OpenWebBeans as CDI container do for you? + + +## An introduction to CDI + +Contexts and Dependency Injection for Java a.k.a. CDI is a JavaEE specification with the number JSR-299. +Apache OpenWebBeans implements this standard. This page will give you an introduction to features of +CDI in general. We will add a special hint whenever a feature is ambiguous in the specification +and OpenWebBeans implements it in a certain way which might be different on other CDI containers. + +## What is CDI at all? + +Originally developed under the name ‘Web Beans’, the CDI specification was created +to fill the gaps which could not be filled by Enterprise Java Beans (EJB) on the back end, +and JavaServer Faces (JSF) in the view layer. The first draft targeted only +Java Enterprise Edition (Java EE), but during the creation of the specification +it became clear that most features were very useful for any Java environment, +including Java SE. + +Even if the full name of the specification is + +> Contexts and Dependency Injection for the Java Enterprise platform + +this does not mean that CDI applications can only run in JavaEE those days. +At least OpenWebBeans provides CDI functionality which also runs in pure Java SE apps like Swing, JavaFX +and even Eclipse RCP apps as well. + +### Relation to JSR-330 + +A half year before the CDI specification became final, other communities +(Spring and guice) had begun an effort to specify the basics of injection as + +> “JSR-330: Dependency Injection for Java” (nicknamed “AtInject”). + +Considering that it did not make sense to provide a new dependency injection container +without collaborating on the actual injection API, the AtInject and CDI expert groups +worked closely together to ensure a common solution across dependency injection frameworks. + +As a result, CDI uses the annotations from the AtInject specification, +meaning that every CDI implementation fully implements the AtInject specification, +just like Guice and Spring. + +CDI and AtInject are both included in Java Enterprise Edition 6 (JSR-316) +and thus nowadays an integral part of almost every Java Enterprise Edition server. + + +## CDI features + +Before we go on to dive into some code, let’s take a quick look at some key CDI features: + +- Type Safety: Instead of injecting objects by a (string) name, +CDI uses the Java type to resolve injections. When the type is not sufficient, +a Qualifier annotation can be used. This allows the compiler to easily detect errors, +and provides easy refactoring. + +- POJOs: Almost every Java object can be injected by CDI! +This includes EJBs, JNDI resources, Persistence Units and Persistence Contexts, +as well as any object which previously would have been created by a factory method. + +- Extensibility: Every CDI container can enhance its functionality +by using portable “Extensions”. The attribute “portable” means that +those CDI Extensions can run on every CDI container and Java EE 6 server, +no matter which vendor. This is accomplished by a well-specified +SPI (Service Provider Interface) which is part of the JSR-299 specification. + +- Interceptors: It has never been easier to write your own Interceptors. +Because of the portable behaviour of JSR-299, they now also run on every +EE 6-certified server and on all standalone CDI containers. + +- Decorators: These allow to dynamically extend existing interface +implementations with business aspects. + +- Events: CDI specifies a type-safe mechanism to send +and receive events with loose coupling. + +- Unified EL integration: EL-2.2 opens a new horizon +in regard of flexibility and functionality. +CDI provides out-of-the-box support for it! -TODO -- where does OWB differ from the CDI-1.0 spec -- what is the default EL version used in OWB -- how can I provide own plugins if there is a new spec part (e.g EL-3.0) I like to support