Skip to main content

Home/ SoftwareEngineering/ Group items tagged cdi

Rss Feed Group items tagged

kuni katsuya

Comparing JSF Beans, CDI Beans and EJBs | Andy Gibson - 0 views

  • differences between CDI beans and EJBs is that EJBs are : Transactional Remote or local Able to passivate stateful beans freeing up resources Able to make use of timers Can be asynchronous
  • Stateless EJBs can be thought of as thread safe single-use beans that don’t maintain any state between two web requests
  • Stateful EJBs do hold state and can be created and sit around for as long as they are needed until they are disposed of
  • ...15 more annotations...
  • Stateless beans must have a dependent scope while a stateful session bean can have any scope. By default they are transactional, but you can use the transaction attribute annotation.
  • CDI beans can be injected into EJBs and EJBs can be injected into CDI beans
  • When to use which bean How do you know when to use which bean? Simple.
  • In general, you should use CDI beans unless you need the advanced functionality available in the EJBs such as transactional functions. You can write your own interceptor to make CDI beans transactional, but for now, its simpler to use an EJB until CDI gets transactional CDI beans which is just around the corner
  • Comparing JSF Beans, CDI Beans and EJBs
  • JSF Managed Beans
  • In short, don’t use them if you are developing for Java EE 6 and using CDI. They provide a simple mechanism for dependency injection and defining backing beans for web pages, but they are far less powerful than CDI beans.
  • JSF beans cannot be mixed with other kinds of beans without some kind of manual coding.
  • CDI Beans
  • includes a complete, comprehensive managed bean facility
  • interceptors, conversation scope, Events, type safe injection, decorators, stereotypes and producer methods
  • JSF-like features, you can define the scope of the CDI bean using one of the scopes defined in the javax.enterprise.context package (namely, request, conversation, session and application scopes). If you want to use the CDI bean from a JSF page, you can give it a name using the javax.inject.Named annotation
  • Comparing JSF Beans, CDI Beans and EJBs
  • Comparing JSF Beans, CDI Beans and EJBs
  • JSF Managed Beans
kuni katsuya

JBoss Developer Framework - 0 views

  • jta-crash-rec Crash Recovery, JTA Uses Java Transaction API and JBoss Transactions to demonstrate recovery of a crashed transaction
  • jts-distributed-crash-rec JTS Demonstrates recovery of distributed crashed components
  • cdi-injection CDI Demonstrates the use of CDI 1.0 Injection and Qualifiers with JSF as the front-end client.
  • ...13 more annotations...
  • bean-validation JPA, Bean Validation Shows how to use Arquillian to test Bean Validation
  • ejb-security Security, EJB Shows how to use Java EE Declarative Security to Control Access to EJB 3
  • payment-cdi-event CDI Demonstrates how to use CDI 1.0 Events
  • richfaces-validation RichFaces Demonstrates RichFaces and bean validation
  • ejb-in-war JSF, WAR, EJB Packages an EJB JAR in a WAR
  • greeter EJB, JPA, JSF, JTA, CDI Demonstrates the use of CDI 1.0, JPA 2.0, JTA 1.1, EJB 3.1 and JSF 2.0
  • helloworld-mdb EJB, MDB, JMS Demonstrates the use of JMS 1.1 and EJB 3.1 Message-Driven Bean
  • helloworld-rs JAX-RS, CDI Demonstrates the use of CDI 1.0 and JAX-RS
  • kitchensink BV, EJB, JAX-RS, JPA, JPA, JSF, CDI
  • servlet-async CDI, EJB, Servlet Demonstrates CDI, plus asynchronous Servlets and EJBs
  • servlet-security Security, Servlet Demonstrates how to use Java EE declarative security to control access to Servlet 3
  • shopping-cart EJB Demonstrates a stateful session bean
  • tasks Arquillian, JPA Demonstrates testing JPA using Arquillian
kuni katsuya

4. Configuration for CDI - Confluence - 0 views

  • In order to initialize GDS/Tide for CDI and Hibernate, you must add granite.jar, granite-hibernate.jar and granite-cdi.jar to your WEB-INF/lib
  • The easiest way to add GraniteDS support to a CDI project in a Servlet 3 compliant container (currently only GlassFish v3) is by adding a configuration class in your project. This class will be scanned by the servlet 3 container and GraniteDS will use the annotation parameters to determine the application configuration
  • GraniteConfig.java import org.granite.config.servlet3.FlexFilter; import org.granite.gravity.config.AbstractMessagingDestination; import org.granite.gravity.config.servlet3.MessagingDestination; import org.granite.tide.cdi.CDIServiceFactory; import org.granite.tide.cdi.Identity; @FlexFilter( tide=true, type="cdi", factoryClass=CDIServiceFactory.class, tideInterfaces={Identity.class} ) public class GraniteConfig { }
  • ...6 more annotations...
  • services-config.xml
  • define manually the endpoint for remote services
  • service initializer in a static block of the main mxml file
  • Cdi.getInstance().addComponentWithFactory("serviceInitializer", DefaultServiceInitializer, { contextRoot: "/my-cdi-app" } );
  • tideAnnotations
  • list of annotation names that enable remote access to CDI beans
kuni katsuya

Chapter 10. Integration with CDI - 0 views

  • Chapter 10. Integration with CDI
  • GraniteDS provides out-of-the-box integration with CDI via the Tide API
  • GraniteDS also integrates with container security for authentication and role-based authorization
  • ...37 more annotations...
  • always have to include this library in either WEB-INF/lib
  • support for CDI is included in the library granite-cdi.jar
  • 10.1. Configuration with Servlet 3 On Servlet 3 compliant containers, GraniteDS can use the new APIs to automatically register its own servlets and filters and thus does not need any particular configuration in web.xml. This automatic setup is triggered when GraniteDS finds a class annotated with @FlexFilter in one of the application archives:
  • @FlexFilter(configProvider=CDIConfigProvider.class) public class GraniteConfig { }  
  • list of annotation names that enable remote access to CDI beans
  • ConfigProvider
  • override these values by setting them in the annotation properties
  • tide=true,         type="cdi",         factoryClass=CDIServiceFactory.class,         tideInterfaces={Identity.class}
  • @FlexFilter declaration will setup an AMF processor for the specified url pattern
  • tideAnnotations
  • defines suitable default values
  • @TideEnabled
  • @RemoteDestination
  • always declared by default
  • tideInterfaces
  • tideRoles
  • exceptionConverters
  • amf3MessageInterceptor
  • 10.3.2. Typesafe Remoting with Dependency Injection
  • It is possible to benefit from even more type safety by using the annotation [Inject] instead of In. When using this annotation, the full class name is used to find the target bean in the CDI context instead of the bean name.
  • Security
  • integration between the client RemoteObject credentials and the server-side container security
  • client-side component named
  • identity
  • API to define runtime authorization checks on the Flex UI
  • login()
  • logout()
  • login(username, password, loginResult, loginFault)
  • logout()
  • bindable property
  • represents the current authentication state
  • loggedIn
  • identity.loggedIn 
  • integrated with server-side role-based security
  • identity.hasRole('admin')
  • clear the security cache manually with
  • identity.clearSecurityCache()
kuni katsuya

Dependency Injection in Java EE 6 - Part 1 - 0 views

  • Dependency Injection in Java EE 6 - Part 1
  • high-level look at CDI, see how it fits with Java EE overall and discuss basic dependency management as well as scoping.
  • CDI is designed to solve
  • ...21 more annotations...
  • highly type-safe
  • consistent
  • portable
  • CDI enhances the Java EE programming model in two more important ways
  • allows you to use EJBs directly as JSF backing beans
  • CDI allows you to manage the scope, state, life-cycle and context for objects in a much more declarative fashion, rather than the programmatic way
  • CDI has no component model of its own
  • set of services that are consumed by Java EE components such as managed beans, Servlets and EJBs.
  • well-defined create/destroy life-cycle that you can get callbacks for via the @PostConstruct and @PreDestroy annotations.
  • Managed beans
  • @ManagedBean
  • annotation
  • CDI also integrates with JSF via EL bean name resolution
  • CDI does not directly support business component services such as transactions, security, remoting, messaging
  • Dependency Injection for Java
  • JSR 330
  • JSR 330 defines a minimalistic API for dependency injection solutions and is primarily geared towards non-Java EE environments.
  • Figure 1 shows how CDI fits with the major APIs in the Java EE platform.
  • none of this uses string names that can be mistyped and all the code is in Java and so is checked at compile time
  • Qualifiers
  • are additional pieces of meta-data that narrow down a particular class when more than one candidate for injection exists
kuni katsuya

Enterprise JavaBeans 3.1 with Contexts and Dependency Injection: The Perfect Synergy - 0 views

  • stateless EJB 3.1 bean as boundary (Facade)
  • injected managed beans (controls)
  • @Inject
  • ...22 more annotations...
  • @Inject
  • CDI managed beans. The @EJB annotation is removed and @Inject is used instead
  • Annotating the boundary (Cart) with the @Named annotation makes the Cart immediately visible for expression language (EL) expressions in JSP and JSF
  • @Named annotation takes the simple name of the annotated class, puts the first character in lowercase, and exposes it directly to the JSF pages (or JSP). The Cart bean can be accessed directly, without any backed or managed beans, by the JSF pages: <h:commandButton value="Check out!" action="#{cart.checkout}" />
  • If there is a need for abstraction, the class can be turned into an interface (or abstract class)
  • local implementation (with CDI events
  • @Inject Event<String> event;
  • event.fire("Order proceeded!");
  • remote implementation:
  • javax.enterprise.event.Event belongs to the CDI-implementation
  • class Event can be considered to be a lightweight alternative to the java.beans.PropertyChangeSupport class
  • @Inject Event<String> event;
  • event.fire("Order proceeded!");
  • event can be received by any managed bean and also by EJB beans
  • provide a method with a single @Observes annotated parameter
  • @Observes String event
  • there is no real event, just the payload:
  • The during attribute in the @Observes annotation allows you to select in which transactional phase the event gets delivered. The default setting is IN_PROGRESS, which causes an immediate event delivery regardless of the transaction outcome. The AFTER_SUCCESS configuration causes the delivery to occur only after successful transaction completion
  • Although CDI events work only inside a single process (in the default case, CDI is extensible), they are perfectly suitable for decoupling packages from modules
  • The method checkout() starts a transaction that gets "reused" by the OrderSystem and CustomerNotification session beans
  • ordering.placeOrder(); notifier.sendNotification();
    • kuni katsuya
       
      both run within same transaction
  • EJB beans cannot be directly exposed to JSF or JSP without a little help from CDI
kuni katsuya

Chapter 10. Integration with CDI - 0 views

  • 10.3.5. Security GraniteDS provides a client-side component named identity that ensures the integration between the client RemoteObject credentials and the server-side container security. It additionally includes an easy-to-use API to define runtime authorization checks on the Flex UI.
  • CDI identity component (of class org.granite.tide.cdi.Identity) predictably provides two methods login() and logout()
  • identity component is integrated with server-side role-based security and can be used to get information or show/hide UI depending on the user access rights:
  • ...2 more annotations...
  •  enabled="{identity.hasRole('admin')}"
  • button labeled Delete will be enabled only if the user has the role admin
kuni katsuya

symbiont/cdiqi · GitHub - 0 views

  • CDI Quartz Scheduler integration
  • simple integration of Quartz Scheduler into CDI application
  • it is not a real CDI extension and doesn't try to fit quartz classes into CDI programming model
  • ...2 more annotations...
  • cdiqi just forces Quartz to use CDI beans as its jobs
  • bounds request context to every job execution so that it's possible to use @RequestScoped, @Dependent and @ApplicationScoped jobs and especially beans
kuni katsuya

Dependency Injection in Java EE 6 (Part 6) - 0 views

  • one of the most important value propositions for frameworks like Spring has been the ability to easily extend the framework or integrate third-party solutions
  • SPI allows you to register your own beans, custom scopes, stereotypes, interceptors and decorators with CDI even if is it not included in the automatic scanning process (such as perhaps registering Spring beans as CDI beans), programmatically looking up CDI beans and injecting them into your own objects (such as injecting CDI beans into Spring beans) and adding/overriding annotation-metadata from other sources (such as from a database or property file)
  • SPI can be segmented into three parts. Interfaces like Bean, Interceptor and Decorator model container meta-data (there are a few other meta-data interfaces such as ObserverMethod, Producer, InjectionTarget, InjectionPoint, AnnotatedType, AnnotatedMethod, etc). Each meta-data object encapsulates everything that the CDI container needs to know about the meta-data type
kuni katsuya

Spring vs Java EE Web Dev: Using Shiro for Authorization via CDI Interceptors then Easi... - 1 views

  • Using Shiro for Authorization via CDI Interceptors then Easily Test with Arquillian Did you know Apache Shiro is an easy-to-use security
  • @Secured @NamedResource("contact")
  • Interceptors will be ignored by CDI container unless it is listed in beans.xml
  • ...2 more annotations...
  • Tells the security interceptor to check the permission using "contact" as the resource name, not "contactmanager" inflected from the class name ContactManager
  • @NamedResource("contact")
kuni katsuya

Niklas' Blog: CDI 1.0 vs. Spring 3.1 feature comparsion: bean definition & dependency i... - 0 views

  • CDI 1.0 vs. Spring 3.1 feature comparsion: bean definition & dependency injection
  • Spring offers three different approaches to do dependency injection: XML-based, annotation-based and pure Java-based (programmatic)
  • CDI on the other hand is strictly annotation-based
  • ...2 more annotations...
  • pure feature oriented-perspective
  • only little critical difference in the two technologies
kuni katsuya

Chapter 10. Integration with CDI - 0 views

  • Integration with CDI
  • GraniteDS provides out-of-the-box integration with CDI via the Tide API
  • tideAnnotations
  • ...5 more annotations...
  • tideInterfaces
  • tideRoles
  • exceptionConverters
  • amf3MessageInterceptor
  • define the list of interface/class names that enable remote access to CDI beans
kuni katsuya

Chapter 10. Integration with CDI - 0 views

  • GraniteDS provides out-of-the-box integration with CDI via the Tide API
  • Integration with CDI
  • fully supports serialization of JPA entities from and to your Flex application, taking care of lazily loaded associations
  • ...3 more annotations...
  • GraniteDS also integrates with container security for authentication and role-based authorization
  • granite-cdi.jar
  • JBoss 6 and GlassFish v3
kuni katsuya

Shiro User - Shiro in CDI/JPA2/JSF2 project - 1 views

  • CDI, JPA2 and JSF2
  • Apache Shiro
  • JpaRealm
  • ...10 more annotations...
  • Entity Beans in combination with an EntityManager
  • use CDI to inject the EntityManager into my JpaRealm
  • JpaRealm is not container managed but is instantiated by Shiro
  • delegate your JpaRealm into @Stateless EJB, which can @Inject EntityManager
  • JpaRealm
  • @PersistenceContext   private EntityManager entityManager;
  • EnvironmentLoaderListener
  • found the cause
  • Instead of configuring the ShiroFilter in my web.xml I had the IniShiroFilter configured. The IniShiroFilter creates a new SecurityManager from the ini file. This new SecurityManager didn't know about the realm I've added in my EnvironmentLoader, so it didn't have any realms.
  • I replaced it with the ShiroFilter in my web.xml and all seems to be working now with my CdiEnvironmentLoaderListener.
kuni katsuya

Seam Framework - Home - 0 views

  • How do Seam, Weld and CDI relate to each other?
  • CDI is a JCP specification included in Java EE Weld is the reference implementation of CDI Seam 3 is a set of modules which extend CDI to provide functionality beyond that offered by Java EE 6
  • Seam 3 is a superset of JSR-299
  • ...6 more annotations...
  • Think of JSR-299 as the core of Seam 3 - it's the basic programming model for your application components, and for the built-in components that make up the Seam framework
  • Seam 3 is implemented as a set of portable extensions, or modules
  • run in any environment which supports JSR-299 (including any Java EE 6 environment).
  • BPM integration, Seam Security, Drools integration, RESTeasy integration, PDF and email templates, Excel generation, etc
  • 2.0.0.Final End of 2012 Full specification compliance
  • Weld 2
kuni katsuya

Improve your life Through Science and Art: JEE6: Interfaces on Demand with EE6 (CDI & e... - 0 views

  • JEE6: Interfaces on Demand with EE6 (CDI & ejb3.1)
  • JEE6: Interfaces on Demand with EE6 (CDI & ejb3.1)
  • Since Java Platform, Enterprise Edition 6 (Java EE 6),
  • ...9 more annotations...
  • interfaces are no longer required
  • by the container in order to realize common use cases
  • An interface becomes a vehicle for encapsulation or abstraction,
  • as it was originally intended to be:
  • “Interfaces are used to encode similarities which the classes of various types share, but do not necessarily constitute a class relationship. For instance, a human and a parrot can both whistle; however, it would not make sense to represent Humans and Parrots as subclasses of a Whistler class. Rather they would most likely be subclasses of an Animal class (likely with intermediate classes), but both would implement the Whistler interface.” [http://en.wikipedia.org/wiki/Java_interface]
  • Extensive use of interfaces derives from a
  • belief that they might be helpful in the future
  • Premature Extensibility Is the Root of Some Evil
  • The number of artifacts will double and you will have to introduce a configuration facility
kuni katsuya

Chapter 3. Project Setup - 0 views

  • Using Maven archetypes
  • GraniteDS/Tide/CDI/JPA: graniteds-tide-cdi-jpa
  • GraniteDS/Tide/Seam 2/JPA/Hibernate: graniteds-tide-seam-jpa-hibernate
  • ...3 more annotations...
  • Maven 3 is highly recommended but Maven 2.2 should also work
  • CDI archetype defines an embedded GlassFish run configuration
  • mvn embedded-glassfish:run
1 - 20 of 116 Next › Last »
Showing 20 items per page