SlideShare a Scribd company logo
IOC and DI revisited with
Epo Jemba – Kametic
@ejemba
#nuun on freenode https://github.com/nuun-io
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
2/31
Epo Jemba, Freelance
● Software Architect, Developper
● 18 years designing clean softwares
● Fan of DDD and good practices
● Author of Nuun
● Co-Author of Seedstack
– Creator of the Business Framework
( Domain Driven Design with Java )
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
3/31
What is Nuun ? 
● Nuun is a java micro-framework
– For designing enterprise class applications and software stacks
– Is based on the « Inversion of Control » Architectural Pattern 
● Compatible with major Dependency Injection frameworks ( Spring, Guice, etc... )
● Nuun relies on standard and proven components
JSR 330 via Guice Dependency Injection
JDK ServiceLoader Discoverability
ronmamo/Reflections Classpath Scanning
All orchestrated by a unique Kernel/Plugin Protocol Extensibility, Uncoupling, Cohesion
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
4/31
Genesis of Nuun
● When elaborating a software stack for a major client, I found out that the
existing DI framework was limited :
– Lack of explicit Interface driven Injection
– Lack of means to create my own conventions
– … especially in automating binding definition creation,
– Error-prone, refactoring-adverse string identifiers
– Explicit configuration is XML and verbose
– Auto-wiring is concise but slow and not well suited to non-trivial applications
– Lack of Behaviour Delegation
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
5/31
Why Nuun ? 
● We need
– a Clear & Typesafe definition of the « Object Graph » in term of  Dependency Injection,
Aspect Oriented Programming, Properties management and more.
– New experience where developer don’t spend any time working on configuration but
applies conventions with sane defaults
– Applications are truly extensible, modules really discoverable,
● « Just add the dependency in the pom, and start working »   
● And still understand why and how everything is working ( no magic ! )
– Clean integration of 3rd party framework
– Creation of a sane software ecosystem
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
6/31
What are Nuun building blocks ? 
● a Runner that read Entrypoint class
● META-INF/scan file to easily configure packages to scan
● Two API to configure applications and modules
– Topology API  : A nominal API for application developers
– Kernel/Plugin API : A more advanced API and SPI aiming enterprise stack 
designers
● Nuun has been designed in enterprise context, thus the Enterprise
API has been designed first.
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
7/31
Runner Example
public static void main(String[] args) {
NuunRunner.entrypoint(Main.class).execute(args);
}
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
8/31
Entrypoint Example 
// default scan path is the package of the entrypoint
// otherwise explicitely use “packageScan”
@Entrypoint
public class Main implements Runnable {
@Inject @Named("message") // from properties
String message;
@Inject
HelloWorldService helloWorldService;
@Override
public void run() {
System.out.println("inside Main sample message is :n" +
helloWorldService.say(message));
}
}
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
9/31
Topology API
● Topologies are declarative fragments of configuration in which
developers describe
– Binding Definition
– AOP Interceptor
– Properties handling
– And more
● Topologies are java interfaces, not classes (so no need to unit test)
● Can compare with Spring Config but « Leaner »   
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
10/31
Topology simple example
@Topology(propertySources = "classpath:message.properties")
public interface SampleTopology {
// Definition of a simple constant
@Server // Server is a qualified annotation
String url = “http://nuun.io”;
// Definition of a simple binding Interface and Implementation
InternalHelloWorldService injects(HelloWorldService key);
// Definition of non trivial type as constants
Optional<TranslateService> translateService = Optional.empty();
}
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
11/31
Topology simple : resulted injections 
// Injection of “http://nuun.io”
@Inject @Server
String myglobalUrl;
// Injection of an instance of InternalHelloWorldService
@Inject
HelloWorldService helloWorldService;
// Injection of Optional.empty()
@Inject
Optional<TranslateService> translateService ;
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
12/31
Topology advanced example
// Definition of a list of string as a constant
List<String> genericList = new ArrayList<>(); // generics
// Definition of constants a qualified constant
@Server
Long port = 8080l;
// Definition of a qualified key for a service
MyService2Impl injectsTwo (@Named("two") MyService key);
// Definition of JSR330 Provider on a MyService2
MyService2Provider provides(MyService2 key);
// Definition of an interceptor using 2 predicates (on class and method)
MyMethodInterceptor intercepts(ClassePredicate pc, MethodPredicateMethodPredicate pm);
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
13/31
Topology advanced : resulted injections 
//new ArrayList<>() will be injected
@Inject
List<String> genericList;
// 8080L will be injected
@Inject @Server
Long port;
// result of the MyService2Provider.get() will be injected
@Inject @Named("two")
MyService key;
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
14/31
META-INF/scan
● META-INF/scan contains a list of java package to scan.
● We can have many in the classpath, one by jar file
● META-INF/scan is nuun standardization attempt to uncouple
configuration from classpath scan directive.
● In your reusable component, you can define your configuration
in one topology and use META-INF/scan to indicate the kernel
which package to scan.
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
15/31
Kernel/Plugin API
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
16/31
Kernel/Plugin API
● The kernel is in charge of providing the object graph of the
application
● For this it relies on plugins by aggregating their configuration
fragments into a global configuration
● The configuration is therefore always dependent on the
application environment
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
17/31
Kernel/Plugin API
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
18/31
Kernel usage
//
Kernel kernel = NuunCore.createKernel(
NuunCore.newKernelConfiguration()
.rootPackages(rootFromEntryPoint));
kernel.init(); // creating configuration initializing plugins
kernel.start(); // starting kernel from the configuration just created
// use your application vi the object graph
Injector injector = kernel.objectGraph().as(Injector.class)
// Stopping the kernel to free resources, stop daemons, etc ...
kernel.stop();
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
19/31
Kernel/Plugin Protocol
Kernel Loading from the
classpath
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
20/31
Kernel/Plugin
Protocol
Kernel loads plugins via
ServiceLoader
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
21/31
Kernel/Plugin
Protocol
Plugins send their
requests to the kernel
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
22/31
Kernel/Plugin
Protocol
Kernel scans classpath
according to plugins
requests
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
23/31
Kernel/Plugin
Protocol
Kernel returns its
results to each plugin
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
24/31
Kernel/Plugin
Protocol
From its result each
plugin build its dynamic
configuration
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
25/31
Kernel/Plugin
Protocol
Each plugin returns its
created configuration to
the kernel
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
26/31
Kernel/Plugin
Protocol
Kernel builds the Global
Configuration and create
the associated injector
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
27/31
Kernel/Plugin
Protocol
The resulting injector
is then tailored for the
application object
graph.
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
28/31
Deterministic Runtime Algorithm
● This process occurs at the beginning of the application only
once and lasts less than 200 ms
● Plugins can communicate and may have dependencies. The
resulting global configuration is of the most adapted
● This protocol brings an adaptive, resilient configuration system
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
29/31
Enterprise API
● API
– Kernel Lifecycle
– Kernel parameters
– Kernel Listener
– Plugin Lifecycle
– Request API
– Plugin Dependencies
– Integration Tests
– Etc …
–
● SPI
– Plugin Definition
– Dependency Inject° Providers
– Concerns
– Multi-Round initialization
– Kernel Extensions
– Kernel params aliases
– Etc …
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
30/31
Roadmap : Toward 1.0 
● First github commit was in november 2012
● 10 Milestones Version
● Nuun is used by Seedstack
● Nuun is stable and used in production since 2013.
● 2017 : Nuun is a  OW2 Project o/
● Toward 1.0
– Finalizing « Topology API »   
– Finalizing « Request API »   
– Finalizing « Concern API »   
– Documentation, Blogs & Samples on http://nuun.io
IOC and DI revisited with Nuun
Tuesday, 27th june 2017
31/31
Questions [and Demo]
● Thank you for your attention !
● https://github.com/nuun-io/kernel
● http://nuun.io
● Professional support on nuun and seedstack
– epo.jemba@kametic.com

More Related Content

Similar to IOC and DI revisited with Nuun

Cosug for jiang su lug dec 2011
Cosug  for jiang su lug dec 2011Cosug  for jiang su lug dec 2011
Cosug for jiang su lug dec 2011
OpenCity Community
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationJenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Oleg Nenashev
 
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
Puppet
 
Testing Rest with Spring by Kostiantyn Baranov (Senior Software Engineer, Gl...
Testing Rest with Spring  by Kostiantyn Baranov (Senior Software Engineer, Gl...Testing Rest with Spring  by Kostiantyn Baranov (Senior Software Engineer, Gl...
Testing Rest with Spring by Kostiantyn Baranov (Senior Software Engineer, Gl...
GlobalLogic Ukraine
 
CICD with Jenkins
CICD with JenkinsCICD with Jenkins
CICD with Jenkins
MoogleLabs default
 
DevOps CI Automation Continuous Integration
DevOps CI Automation Continuous IntegrationDevOps CI Automation Continuous Integration
DevOps CI Automation Continuous Integration
IRJET Journal
 
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
Sauce Labs
 
Devops - Continuous Integration And Continuous Development
Devops - Continuous Integration And Continuous DevelopmentDevops - Continuous Integration And Continuous Development
Devops - Continuous Integration And Continuous Development
SandyJohn5
 
Refreshing Your App in iOS 7
Refreshing Your App in iOS 7Refreshing Your App in iOS 7
Refreshing Your App in iOS 7
Aviary
 
Stmik bandung
Stmik bandungStmik bandung
Stmik bandung
farid savarudin
 
Jenkins pipeline as code
Jenkins pipeline as codeJenkins pipeline as code
Jenkins pipeline as code
Mohammad Imran Ansari
 
Eclipse Training - Introduction
Eclipse Training - IntroductionEclipse Training - Introduction
Eclipse Training - Introduction
Luca D'Onofrio
 
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docxGaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot kaur
 
report on internshala python training
 report on internshala python  training  report on internshala python  training
report on internshala python training
surabhimalviya1
 
Introduction to Biological Network Analysis and Visualization with Cytoscape ...
Introduction to Biological Network Analysis and Visualization with Cytoscape ...Introduction to Biological Network Analysis and Visualization with Cytoscape ...
Introduction to Biological Network Analysis and Visualization with Cytoscape ...
Keiichiro Ono
 
Devops course content
Devops course contentDevops course content
Devops course content
Thota Ravindra Reddy
 
Yocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux DistributionYocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux Distribution
emertxemarketing
 
How Nuxeo uses the open-source continuous integration server Jenkins
How Nuxeo uses the open-source continuous integration server JenkinsHow Nuxeo uses the open-source continuous integration server Jenkins
How Nuxeo uses the open-source continuous integration server Jenkins
Nuxeo
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
Davide Fella
 
Odo improving the developer experience on OpenShift - hack &amp; sangria
Odo   improving the developer experience on OpenShift - hack &amp; sangriaOdo   improving the developer experience on OpenShift - hack &amp; sangria
Odo improving the developer experience on OpenShift - hack &amp; sangria
Jorge Morales
 

Similar to IOC and DI revisited with Nuun (20)

Cosug for jiang su lug dec 2011
Cosug  for jiang su lug dec 2011Cosug  for jiang su lug dec 2011
Cosug for jiang su lug dec 2011
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationJenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
 
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
 
Testing Rest with Spring by Kostiantyn Baranov (Senior Software Engineer, Gl...
Testing Rest with Spring  by Kostiantyn Baranov (Senior Software Engineer, Gl...Testing Rest with Spring  by Kostiantyn Baranov (Senior Software Engineer, Gl...
Testing Rest with Spring by Kostiantyn Baranov (Senior Software Engineer, Gl...
 
CICD with Jenkins
CICD with JenkinsCICD with Jenkins
CICD with Jenkins
 
DevOps CI Automation Continuous Integration
DevOps CI Automation Continuous IntegrationDevOps CI Automation Continuous Integration
DevOps CI Automation Continuous Integration
 
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
 
Devops - Continuous Integration And Continuous Development
Devops - Continuous Integration And Continuous DevelopmentDevops - Continuous Integration And Continuous Development
Devops - Continuous Integration And Continuous Development
 
Refreshing Your App in iOS 7
Refreshing Your App in iOS 7Refreshing Your App in iOS 7
Refreshing Your App in iOS 7
 
Stmik bandung
Stmik bandungStmik bandung
Stmik bandung
 
Jenkins pipeline as code
Jenkins pipeline as codeJenkins pipeline as code
Jenkins pipeline as code
 
Eclipse Training - Introduction
Eclipse Training - IntroductionEclipse Training - Introduction
Eclipse Training - Introduction
 
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docxGaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docx
 
report on internshala python training
 report on internshala python  training  report on internshala python  training
report on internshala python training
 
Introduction to Biological Network Analysis and Visualization with Cytoscape ...
Introduction to Biological Network Analysis and Visualization with Cytoscape ...Introduction to Biological Network Analysis and Visualization with Cytoscape ...
Introduction to Biological Network Analysis and Visualization with Cytoscape ...
 
Devops course content
Devops course contentDevops course content
Devops course content
 
Yocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux DistributionYocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux Distribution
 
How Nuxeo uses the open-source continuous integration server Jenkins
How Nuxeo uses the open-source continuous integration server JenkinsHow Nuxeo uses the open-source continuous integration server Jenkins
How Nuxeo uses the open-source continuous integration server Jenkins
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
 
Odo improving the developer experience on OpenShift - hack &amp; sangria
Odo   improving the developer experience on OpenShift - hack &amp; sangriaOdo   improving the developer experience on OpenShift - hack &amp; sangria
Odo improving the developer experience on OpenShift - hack &amp; sangria
 

Recently uploaded

Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 

Recently uploaded (20)

Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 

IOC and DI revisited with Nuun

  • 1. IOC and DI revisited with Epo Jemba – Kametic @ejemba #nuun on freenode https://github.com/nuun-io
  • 2. IOC and DI revisited with Nuun Tuesday, 27th june 2017 2/31 Epo Jemba, Freelance ● Software Architect, Developper ● 18 years designing clean softwares ● Fan of DDD and good practices ● Author of Nuun ● Co-Author of Seedstack – Creator of the Business Framework ( Domain Driven Design with Java )
  • 3. IOC and DI revisited with Nuun Tuesday, 27th june 2017 3/31 What is Nuun ?  ● Nuun is a java micro-framework – For designing enterprise class applications and software stacks – Is based on the « Inversion of Control » Architectural Pattern  ● Compatible with major Dependency Injection frameworks ( Spring, Guice, etc... ) ● Nuun relies on standard and proven components JSR 330 via Guice Dependency Injection JDK ServiceLoader Discoverability ronmamo/Reflections Classpath Scanning All orchestrated by a unique Kernel/Plugin Protocol Extensibility, Uncoupling, Cohesion
  • 4. IOC and DI revisited with Nuun Tuesday, 27th june 2017 4/31 Genesis of Nuun ● When elaborating a software stack for a major client, I found out that the existing DI framework was limited : – Lack of explicit Interface driven Injection – Lack of means to create my own conventions – … especially in automating binding definition creation, – Error-prone, refactoring-adverse string identifiers – Explicit configuration is XML and verbose – Auto-wiring is concise but slow and not well suited to non-trivial applications – Lack of Behaviour Delegation
  • 5. IOC and DI revisited with Nuun Tuesday, 27th june 2017 5/31 Why Nuun ?  ● We need – a Clear & Typesafe definition of the « Object Graph » in term of  Dependency Injection, Aspect Oriented Programming, Properties management and more. – New experience where developer don’t spend any time working on configuration but applies conventions with sane defaults – Applications are truly extensible, modules really discoverable, ● « Just add the dependency in the pom, and start working »    ● And still understand why and how everything is working ( no magic ! ) – Clean integration of 3rd party framework – Creation of a sane software ecosystem
  • 6. IOC and DI revisited with Nuun Tuesday, 27th june 2017 6/31 What are Nuun building blocks ?  ● a Runner that read Entrypoint class ● META-INF/scan file to easily configure packages to scan ● Two API to configure applications and modules – Topology API  : A nominal API for application developers – Kernel/Plugin API : A more advanced API and SPI aiming enterprise stack  designers ● Nuun has been designed in enterprise context, thus the Enterprise API has been designed first.
  • 7. IOC and DI revisited with Nuun Tuesday, 27th june 2017 7/31 Runner Example public static void main(String[] args) { NuunRunner.entrypoint(Main.class).execute(args); }
  • 8. IOC and DI revisited with Nuun Tuesday, 27th june 2017 8/31 Entrypoint Example  // default scan path is the package of the entrypoint // otherwise explicitely use “packageScan” @Entrypoint public class Main implements Runnable { @Inject @Named("message") // from properties String message; @Inject HelloWorldService helloWorldService; @Override public void run() { System.out.println("inside Main sample message is :n" + helloWorldService.say(message)); } }
  • 9. IOC and DI revisited with Nuun Tuesday, 27th june 2017 9/31 Topology API ● Topologies are declarative fragments of configuration in which developers describe – Binding Definition – AOP Interceptor – Properties handling – And more ● Topologies are java interfaces, not classes (so no need to unit test) ● Can compare with Spring Config but « Leaner »   
  • 10. IOC and DI revisited with Nuun Tuesday, 27th june 2017 10/31 Topology simple example @Topology(propertySources = "classpath:message.properties") public interface SampleTopology { // Definition of a simple constant @Server // Server is a qualified annotation String url = “http://nuun.io”; // Definition of a simple binding Interface and Implementation InternalHelloWorldService injects(HelloWorldService key); // Definition of non trivial type as constants Optional<TranslateService> translateService = Optional.empty(); }
  • 11. IOC and DI revisited with Nuun Tuesday, 27th june 2017 11/31 Topology simple : resulted injections  // Injection of “http://nuun.io” @Inject @Server String myglobalUrl; // Injection of an instance of InternalHelloWorldService @Inject HelloWorldService helloWorldService; // Injection of Optional.empty() @Inject Optional<TranslateService> translateService ;
  • 12. IOC and DI revisited with Nuun Tuesday, 27th june 2017 12/31 Topology advanced example // Definition of a list of string as a constant List<String> genericList = new ArrayList<>(); // generics // Definition of constants a qualified constant @Server Long port = 8080l; // Definition of a qualified key for a service MyService2Impl injectsTwo (@Named("two") MyService key); // Definition of JSR330 Provider on a MyService2 MyService2Provider provides(MyService2 key); // Definition of an interceptor using 2 predicates (on class and method) MyMethodInterceptor intercepts(ClassePredicate pc, MethodPredicateMethodPredicate pm);
  • 13. IOC and DI revisited with Nuun Tuesday, 27th june 2017 13/31 Topology advanced : resulted injections  //new ArrayList<>() will be injected @Inject List<String> genericList; // 8080L will be injected @Inject @Server Long port; // result of the MyService2Provider.get() will be injected @Inject @Named("two") MyService key;
  • 14. IOC and DI revisited with Nuun Tuesday, 27th june 2017 14/31 META-INF/scan ● META-INF/scan contains a list of java package to scan. ● We can have many in the classpath, one by jar file ● META-INF/scan is nuun standardization attempt to uncouple configuration from classpath scan directive. ● In your reusable component, you can define your configuration in one topology and use META-INF/scan to indicate the kernel which package to scan.
  • 15. IOC and DI revisited with Nuun Tuesday, 27th june 2017 15/31 Kernel/Plugin API
  • 16. IOC and DI revisited with Nuun Tuesday, 27th june 2017 16/31 Kernel/Plugin API ● The kernel is in charge of providing the object graph of the application ● For this it relies on plugins by aggregating their configuration fragments into a global configuration ● The configuration is therefore always dependent on the application environment
  • 17. IOC and DI revisited with Nuun Tuesday, 27th june 2017 17/31 Kernel/Plugin API
  • 18. IOC and DI revisited with Nuun Tuesday, 27th june 2017 18/31 Kernel usage // Kernel kernel = NuunCore.createKernel( NuunCore.newKernelConfiguration() .rootPackages(rootFromEntryPoint)); kernel.init(); // creating configuration initializing plugins kernel.start(); // starting kernel from the configuration just created // use your application vi the object graph Injector injector = kernel.objectGraph().as(Injector.class) // Stopping the kernel to free resources, stop daemons, etc ... kernel.stop();
  • 19. IOC and DI revisited with Nuun Tuesday, 27th june 2017 19/31 Kernel/Plugin Protocol Kernel Loading from the classpath
  • 20. IOC and DI revisited with Nuun Tuesday, 27th june 2017 20/31 Kernel/Plugin Protocol Kernel loads plugins via ServiceLoader
  • 21. IOC and DI revisited with Nuun Tuesday, 27th june 2017 21/31 Kernel/Plugin Protocol Plugins send their requests to the kernel
  • 22. IOC and DI revisited with Nuun Tuesday, 27th june 2017 22/31 Kernel/Plugin Protocol Kernel scans classpath according to plugins requests
  • 23. IOC and DI revisited with Nuun Tuesday, 27th june 2017 23/31 Kernel/Plugin Protocol Kernel returns its results to each plugin
  • 24. IOC and DI revisited with Nuun Tuesday, 27th june 2017 24/31 Kernel/Plugin Protocol From its result each plugin build its dynamic configuration
  • 25. IOC and DI revisited with Nuun Tuesday, 27th june 2017 25/31 Kernel/Plugin Protocol Each plugin returns its created configuration to the kernel
  • 26. IOC and DI revisited with Nuun Tuesday, 27th june 2017 26/31 Kernel/Plugin Protocol Kernel builds the Global Configuration and create the associated injector
  • 27. IOC and DI revisited with Nuun Tuesday, 27th june 2017 27/31 Kernel/Plugin Protocol The resulting injector is then tailored for the application object graph.
  • 28. IOC and DI revisited with Nuun Tuesday, 27th june 2017 28/31 Deterministic Runtime Algorithm ● This process occurs at the beginning of the application only once and lasts less than 200 ms ● Plugins can communicate and may have dependencies. The resulting global configuration is of the most adapted ● This protocol brings an adaptive, resilient configuration system
  • 29. IOC and DI revisited with Nuun Tuesday, 27th june 2017 29/31 Enterprise API ● API – Kernel Lifecycle – Kernel parameters – Kernel Listener – Plugin Lifecycle – Request API – Plugin Dependencies – Integration Tests – Etc … – ● SPI – Plugin Definition – Dependency Inject° Providers – Concerns – Multi-Round initialization – Kernel Extensions – Kernel params aliases – Etc …
  • 30. IOC and DI revisited with Nuun Tuesday, 27th june 2017 30/31 Roadmap : Toward 1.0  ● First github commit was in november 2012 ● 10 Milestones Version ● Nuun is used by Seedstack ● Nuun is stable and used in production since 2013. ● 2017 : Nuun is a  OW2 Project o/ ● Toward 1.0 – Finalizing « Topology API »    – Finalizing « Request API »    – Finalizing « Concern API »    – Documentation, Blogs & Samples on http://nuun.io
  • 31. IOC and DI revisited with Nuun Tuesday, 27th june 2017 31/31 Questions [and Demo] ● Thank you for your attention ! ● https://github.com/nuun-io/kernel ● http://nuun.io ● Professional support on nuun and seedstack – epo.jemba@kametic.com