Posts Tagged ‘CDI’
[DevoxxBE2013] Part 1: Java EE 7: What’s New in the Java EE Platform
Antonio Goncalves and Arun Gupta, luminaries in Java EE advocacy, deliver a comprehensive exploration of Java EE 7’s advancements, blending simplification with expanded capabilities. Antonio, a senior architect and author of Beginning Java EE 6 Platform with GlassFish 3, collaborates with Arun, Red Hat’s Director of Developer Advocacy and former Java EE pioneer at Sun Microsystems, to unveil WebSocket, JSON processing, and enhanced CDI and JTA features. Their session, rich with demos, highlights how these innovations bolster HTML5 support and streamline enterprise development.
Java EE 7, they assert, refines container services while embracing modern web paradigms. From WebSocket’s real-time communication to CDI’s unified bean management, they showcase practical integrations, ensuring developers can craft scalable, responsive applications.
WebSocket for Real-Time Communication
Antonio introduces WebSocket, a cornerstone for HTML5’s bidirectional connectivity. He demonstrates @ServerEndpoint-annotated classes, crafting a chat application where messages flow instantly, bypassing HTTP’s overhead.
Arun details encoders/decoders, transforming POJOs to wire-ready text or binary frames, streamlining data exchange for real-time apps like live dashboards.
JSON Processing and JAX-RS Enhancements
Arun explores JSON-P (JSR 353), parsing and generating JSON with a fluid API. He demos building JSON objects from POJOs, integrating with JAX-RS’s HTTP client for seamless RESTful interactions.
This synergy, Antonio notes, equips developers to handle data-driven web applications, aligning with HTML5’s data-centric demands.
CDI and Managed Bean Alignment
Antonio unveils CDI’s evolution, unifying managed beans with injectable interceptors. He showcases constructor injection and method-level validation, simplifying dependency management across EJBs and servlets.
Arun highlights JTA’s declarative transactions, enabling @Transactional annotations to streamline database operations, reducing boilerplate.
Simplified JMS and Batch Processing
Arun introduces JMS 2.0’s simplified APIs, demonstrating streamlined message publishing. The new Batch API (JSR 352), Antonio adds, orchestrates chunk-based processing for large datasets, with demos showcasing job definitions.
These enhancements, they conclude, enhance usability, pruning legacy APIs while empowering enterprise scalability.
Resource Definitions and Community Engagement
Antonio details expanded resource definitions, configuring data sources via annotations. Arun encourages JCP involvement, noting Java EE 8’s community-driven roadmap.
Their demos—leveraging GlassFish—illustrate practical adoption, inviting developers to shape future specifications.
Links:
[DevoxxBE2012] Real World Java EE
Adam Bien, a renowned Java consultant, author, and Java Champion with decades of experience in enterprise applications, delivered an impromptu yet insightful session on practical Java EE usage. Adam, known for books like “Real World Java EE Patterns,” shared real-world insights from his freelance projects, emphasizing simplicity and effectiveness over hype.
He started by recounting his journey since 1995, favoring Java EE for its robustness in production. Adam advocated thin WAR deployments, bundling everything into a single archive for easy management, contrasting with complex EAR structures.
Discussing boundaries, Adam promoted domain-driven design, where entities form the core, with services as facades. He cautioned against unnecessary abstractions, like excessive DAOs, favoring direct JPA usage.
Adam highlighted CDI’s power for dependency injection, reducing boilerplate. He demonstrated boundary-control-entity patterns, where boundaries handle transactions, controls manage logic, and entities persist data.
Deployment Strategies and Simplicity
Adam stressed deploying as WARs to containers like GlassFish, avoiding heavy setups. He shared experiences with microservices avant la lettre, using REST for inter-service communication.
He critiqued over-engineering, like misusing ESBs for simple integrations, preferring lightweight approaches.
Testing and Quality Assurance
Adam advocated comprehensive testing: unit with JUnit, integration with Arquillian, and UI with Selenium/Graphene. He demonstrated embedding containers for realistic tests.
He emphasized boundary testing, simulating real scenarios without mocks where possible.
Performance and Scalability
Discussing optimization, Adam noted Java EE’s built-in clustering, but advised measuring first. He shared cases where simple configurations sufficed, avoiding premature scaling.
Community and Best Practices
Adam encouraged open-source contributions, sharing his GitHub projects. He addressed common pitfalls, like session misuse, advocating stateless designs.
In Q&A, he discussed tools like Jenkins for CI and IDEs like IntelliJ.
Adam’s talk reinforced Java EE’s viability for real-world applications through pragmatic, lean practices.
Links:
[DevoxxFR2013] Java EE 7 in Detail
Lecturer
David Delabassee is a Principal Product Manager in Oracle’s GlassFish team. Previously at Sun for a decade, he focused on end-to-end Java, related technologies, and tools. Based in Belgium, he contributes to Devoxx Belgium’s steering committee.
Abstract
David Delabassee’s overview details Java EE 7’s innovations, emphasizing developer simplicity and HTML5 support. Covering WebSockets, JSON-P, JAX-RS 2, JMS 2, concurrency, caching, and batch processing, he demonstrates features via GlassFish. The analysis explores alignments with modern needs like cloud and modularity, implications for productivity, and forward compatibility.
Evolution and Key Themes: Simplifying Development and Embracing Modern Web
Delabassee notes Java EE 6’s (2009) popularity, with widespread server adoption. Java EE 7, nearing finalization, builds on this via JCP, comprising 13 updated, 4 new specs.
Themes: ease of development (defaults, pruning), web enhancements (HTML5 via WebSockets), alignment with trends (cloud, multi-tenancy). Pruning removes outdated techs like EJB CMP; new APIs address gaps.
GlassFish 4, the reference implementation, enables early testing. Delabassee demos features, stressing community feedback.
Core API Enhancements: WebSockets, JSON, and REST Improvements
WebSocket (JSR 356): Enables full-duplex, bidirectional communication over single TCP. Annotate endpoints (@ServerEndpoint), handle messages (@OnMessage).
@ServerEndpoint("/echo")
public class EchoEndpoint {
@OnMessage
public void echo(String message, Session session) {
session.getBasicRemote().sendText(message);
}
}
JSON-P (JSR 353): Parsing/processing API with streaming, object models. Complements JAX-RS for RESTful services.
JAX-RS 2 (JSR 339): Client API, filters/interceptors, async support. Client example:
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://example.com");
Response response = target.request().get();
These foster efficient, modern web apps.
Messaging and Concurrency: JMS 2 and Utilities for EE
JMS 2 simplifies: annotation-based injection (@JMSConnectionFactory), simplified API for sending/receiving.
@Inject
JMSContext context;
@Resource(lookup="myQueue")
Queue queue;
context.send(queue, "message");
Concurrency Utilities (JSR 236): Managed executors, scheduled tasks in EE context. Propagate context to threads, avoiding direct Thread creation.
Batch Applications (JSR 352): Framework for chunk/step processing, job management. XML-defined jobs with readers, processors, writers.
Additional Features and Future Outlook: Caching, CDI, and Java EE 8
Though JCache (JSR 107) deferred, it enables standardized distributed caching, usable on EE 7.
CDI 1.1 enhances: @Vetoed for exclusions, alternatives activation.
Java EE 8 plans: modularity, cloud (PaaS/SaaS), further HTML5. Community shapes via surveys.
Delabassee urges Adopt-a-JSR participation for influence.
Implications for Enterprise Development: Productivity and Adaptability
Java EE 7 boosts productivity via simplifications, aligns with web/cloud via new APIs. Demos show practical integration, like WebSocket chats or batch jobs.
Challenges: Learning curve for new features; benefits outweigh via robust, scalable apps.
Forward, EE 7 paves for EE 8’s evolutions, ensuring Java’s enterprise relevance.
Links:
[DevoxxBE2012] Weld-OSGi in Action
Mathieu Ancelin and Matthieu Clochard, software engineers at SERLI specializing in Java EE and modular systems, showcased the synergy between CDI, OSGi, and Weld in their Weld-OSGi framework during DevoxxBE2012. Mathieu, a member of the CDI 1.1 expert group and contributor to projects like GlassFish, collaborated with Matthieu, who focuses on OSGi integrations, to demonstrate how Weld-OSGi simplifies dynamic application assembly without added complexity.
They started with CDI basics, where dependency injection manages component lifecycles via annotations like @Inject. OSGi’s modularity, with bundles as deployment units and a dynamic service registry, complements this by allowing runtime changes. Weld-OSGi bridges them, enabling CDI beans to interact seamlessly with OSGi services.
A demo illustrated bootstrapping Weld-OSGi in an OSGi environment, registering bundles, and using extensions for event handling. They emphasized transparent service interactions, where CDI observes OSGi events for dynamic updates.
Mathieu and Matthieu highlighted Weld-OSGi’s role in making OSGi accessible, countering perceptions of its difficulty by leveraging CDI’s programming model.
Fundamentals of CDI and OSGi Integration
Mathieu explained CDI’s bean management, scopes, and qualifiers for precise injections. Matthieu detailed OSGi’s bundle lifecycle and service registry, where services publish and consume dynamically.
Weld-OSGi embeds CDI containers in OSGi, using extensions to observe bundle events and register services as beans. This allows injecting OSGi services into CDI components effortlessly.
Dynamic Features and Practical Demonstrations
They demonstrated service dynamism: publishing a service updates dependent beans automatically. Unpublishing triggers alternatives or errors, ensuring robustness.
Demos included hybrid applications where Java EE components interact with OSGi bundles via the registry, deploying parts dynamically without restarts.
Future Prospects and Community Engagement
Mathieu discussed ongoing work for hybrid servers like GlassFish, embedding Weld-OSGi for cleaner integrations. They referenced RFC 146, inspired by Weld-OSGi, for native CDI-OSGi support.
Encouraging trials, they pointed to GitHub repositories with examples and documentation, fostering feedback to evolve the framework.
Mathieu and Matthieu’s presentation illustrated Weld-OSGi’s potential to create fully dynamic modular applications, blending CDI’s elegance with OSGi’s power.
Links:
[DevoxxBE2012] Raise Your Java EE 6 Productivity Bar with JBoss Forge
Koen Aers, a Red Hat engineer driving Eclipse integration for JBoss Forge, alongside guest Ivan St. Ivanov from SAP, explored boosting Java EE 6 development efficiency. Koen, with a background in jBPM and workflow editors, refreshed on Forge’s role in simplifying complex setups for novices.
Forge, a command-line tool using CDI, incrementally adds features to projects. Commands scaffold entities, UI, and services swiftly.
They demonstrated creating a project, adding persistence with JPA, generating entities like Speaker and Session, and scaffolding JSF views.
For tasks beyond built-ins, plugins extend functionality. Ivan showed developing an Envers plugin for auditing, installing it, and applying to entities.
Integration with IDEs like Eclipse opens Forge’s power graphically.
Their demo built a conference app, adding history views with auditing, showcasing rapid enhancements.
Koen and Ivan emphasized Forge’s elevation of productivity, enabling faster iterations.
Introducing Forge and Basic Workflows
Koen explained Forge’s shell for navigating projects, setting up Maven builds, and adding facets like JPA for persistence.xml configuration.
Commands generate entities with fields, relationships via annotations.
Scaffolding and UI Generation
Scaffolding creates CRUD operations and JSF views from entities, deploying to servers like AS7.
They customized views, adding fields and relations.
Extending with Plugins
Ivan illustrated plugin creation: facets detect capabilities, commands execute actions like adding dependencies.
The Envers plugin audited entities, integrating seamlessly.
IDE Integration and Real-World Application
Eclipse plugins embed Forge consoles, enhancing workflows.
In demo, they audited entities, added history beans, and viewed changes, proving incremental power.
Koen and Ivan’s insights highlighted Forge’s transformative impact on Java EE development.
Links:
[DevoxxBE2012] Apache TomEE: Java EE 6 Web Profile on Tomcat
David Blevins, a veteran in open-source Java EE and founder of projects like OpenEJB and TomEE, showcased Apache TomEE. With over a decade in specifications like EJB and CDI, David positioned TomEE as a bridge for Tomcat users seeking Java EE capabilities.
He polled the audience, revealing widespread Tomcat use alongside other servers, highlighting the migration pain TomEE addresses. David described TomEE as Tomcat enhanced with Java EE, unzipping Tomcat, adding Apache projects like OpenJPA and CXF, then certifying the bundle.
Emphasizing small size, certification, and Tomcat fidelity, David outlined distributions: Web Profile (minimal specs), JAX-RS (adding REST), and Plus (including JMS, JAX-WS).
Understanding the Web Profile
David clarified the Java EE 6 Web Profile, a subset of 12 specs from the full 24, excluding outdated ones like CORBA and CMP. This acknowledges Java EE’s growth, focusing on essentials for modern apps.
He noted exclusions like JAX-RS (added in EE 7) and inclusions like JavaMail in TomEE’s Web Profile for practicality. David projected EE 7’s profile reductions, potentially enabling full-profile TomEE certification.
Demonstrating TomEE in Action
In a live demo, David set up TomEE in Eclipse using Tomcat adapters, creating a servlet with EJB injection and JPA. He deployed seamlessly, showcasing CDI, transactions, and web services, all within Tomcat’s familiar environment.
David highlighted TomEE’s lightweight footprint—under 30MB—booting quickly with low memory. He integrated tools like Arquillian for testing, demonstrating in-container and embedded modes.
Advanced Features and Configuration
David explored clustering with Hazelcast, enabling session replication without code changes. He discussed production readiness, citing users like OpenShift and Jelastic.
Configuration innovations include flat XML-properties hybrids, human-readable times (e.g., “2 minutes”), and dynamic resource creation. David showed overriding via command-line or properties, extending for custom objects injectable via @Resource.
Error handling stands out: TomEE collects all deployment issues before failing, providing detailed, multi-level feedback to accelerate fixes.
Community and Future Directions
Celebrating TomEE’s first year, David shared growth metrics—surging commits and mailing lists—inviting contributions. He mentioned production adopters praising its simplicity and performance.
David announced a logo contest, encouraging participation. In Q&A, he affirmed production use, low memory needs, and solid components like OpenJPA.
Overall, David’s talk positioned TomEE as an empowering evolution for Tomcat loyalists, blending familiarity with Java EE power.