SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
Roboguice
also dependency injection framework
Paweł Byszewski
Cofiguration
JARs
roboguice.xml
Modules
Cofiguration
Cofiguration
Bindings
Interface to implementation
Adnotation bindings
Instance bindings
Provides methods and objects
On demand
Bindings - interface to implementation
Bindings - interface to implementation
Bindings
Interface to implementation
Adnotation bindings
Instance bindings
Provides methods and objects
On demand
Bindings - adnotation binding
Bindings - adnotation binding
Bindings
Interface to implementation
Adnotation bindings
Instance bindings
Provides methods and objects
On demand
Bindings - instance
Bindings
Interface to implementation
Adnotation bindings
Instance bindings
Provides methods and objects
On demand
Bindings - providers
Bindings - providers
Bindings - providers
Bindings
Interface to implementation
Adnotation bindings
Instance bindings
Provides methods and objects
On demand
Bindings - on demand
Bindings - on demand
08-27 16:44:31.182:INFO/EU.SOFTISLAND.MOBILEWARSAW/InstanceBindingActivity4.java:30(22432):
main Serwer url: 127.0.0.1
08-27 16:44:31.182:INFO/EU.SOFTISLAND.MOBILEWARSAW/InstanceBindingActivity4.java:32(22432):
main TIMEOUT: 15
Injection points
Injection points
Injection points
Injection points
Injection points
@ContentView, Resource etc.
@ContentView, Resource etc.
@ContentView, Resource etc.
@ContentView, Resource etc.
@ContentView, Resource etc.
@ContentView, Resource etc.
@ContentView, Resource etc.
System service Injection
PackageInfo
LocationManager
WindowManager
ActivityManager
PowerManager
AlarmManager
NotificationManager
KeyguardManager
Vibrator
SensorManager.
TelephonyManager
AudioManager
LayoutInflater
SearchManager
AccountManager
WifiManager
InputMethodManager
ConnectivityManager
http://github.com/roboguice/roboguice/blob/master/roboguice/src/main/java/roboguice/config/
DefaultRoboModule.java
@Observes
@Observes
OnActivityResultEvent
OnConfigurationChangeEvent
OnContentChangeEvent
OnCreateEvent
OnDestroyEvent
OnNewIntentEvent
OnPauseEvent
OnRestartEvent
OnResumeEvent
OnStartEvent
OnStopEvent
@Observes
@Observes
Async tasks
AsyncTask <String, Integer, Boolean>
Boolean doInBackground(String... params)
void onPreExecute()
void onPostExecute(Boolean aBoolean)
void onProgressUpdate(Integer... values)
void onCancelled(Boolean aBoolean)
RoboAsyncTask <Boolean>
Boolean call()
void onInterrupted(Exception e)
void onException(Exception e)
void onThrowable(Throwable t)
void onFinally()
void onPreExecute()
void onSuccess(Boolean aBoolean)
Async tasks
AsyncTask <String, Integer, Boolean>
+ progress update
- exception handle
RoboAsyncTask <Boolean>
- progress update
+ exception handle
+ injections
Application, Context, Activity ...
Context
Activity
RoboActivity
Service
RoboService
Application
Application, Context, Activity ...
Application, Context, Activity ...
Scopes
Singleton
ContextSingleton
Scopes
Mixing scopes
Robot legs problem
The Injector creation process
Phase 1: Static Building
Phase 2: Injection
Phase 3: Singleton Preloading
HTC Desire HD -
it takes 600 ms
HTC Wildfire -
it takes 1.8 to 2.4 s
Know your dependency tree
Avoid static injection like the plague
Avoid too many or complex modules
Create a development mode injector to
avoid eager loading of all singletons
Use a RoboSplashActivity as a last
resort
Best practices
Keep constructors as hidden as
possible
Inject only direct dependencies
Avoid cyclic dependencies
Modules should be fast and
side-effect free
Be careful about I/O in Providers
Avoid conditional logic in modules
Single responsibility principle
pawell.b@gmail.com
pbs@touk.pl
pawell.b@gmail.com
pbs@touk.pl

Weitere ähnliche Inhalte

Ähnlich wie Roboguice

Dependency Injection & IoC
Dependency Injection & IoCDependency Injection & IoC
Dependency Injection & IoC
Dennis Loktionov
 

Ähnlich wie Roboguice (20)

Best Web services tutorial | Websoles Strategic Digital Solutions
Best Web services tutorial | Websoles Strategic Digital SolutionsBest Web services tutorial | Websoles Strategic Digital Solutions
Best Web services tutorial | Websoles Strategic Digital Solutions
 
Linking Services and Linked Data: Keynote for AIMSA 2012
Linking Services and Linked Data: Keynote for AIMSA 2012Linking Services and Linked Data: Keynote for AIMSA 2012
Linking Services and Linked Data: Keynote for AIMSA 2012
 
Web Services and the Service-Oriented Architecture
Web Services and the Service-Oriented ArchitectureWeb Services and the Service-Oriented Architecture
Web Services and the Service-Oriented Architecture
 
100 ngn workshop-sdn-english-v4
100 ngn workshop-sdn-english-v4100 ngn workshop-sdn-english-v4
100 ngn workshop-sdn-english-v4
 
Linked services for the Web of Data
Linked services for the Web of DataLinked services for the Web of Data
Linked services for the Web of Data
 
Ibm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshopIbm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshop
 
vidhi talk.pdf
vidhi talk.pdfvidhi talk.pdf
vidhi talk.pdf
 
Enterprise service bus part 2
Enterprise service bus part 2Enterprise service bus part 2
Enterprise service bus part 2
 
WCF LOB SDK at CNUG
WCF LOB SDK at CNUGWCF LOB SDK at CNUG
WCF LOB SDK at CNUG
 
Realtime collaboration with Clojure - EuroClojure - Barcelona, 2015
Realtime collaboration with Clojure - EuroClojure - Barcelona, 2015Realtime collaboration with Clojure - EuroClojure - Barcelona, 2015
Realtime collaboration with Clojure - EuroClojure - Barcelona, 2015
 
Resource Discovery Landscape
Resource Discovery LandscapeResource Discovery Landscape
Resource Discovery Landscape
 
SynapseIndia dotnet framework library
SynapseIndia  dotnet framework librarySynapseIndia  dotnet framework library
SynapseIndia dotnet framework library
 
Dot net training bangalore
Dot net training bangaloreDot net training bangalore
Dot net training bangalore
 
iServe Version 1
iServe Version 1iServe Version 1
iServe Version 1
 
The Open Web
The Open WebThe Open Web
The Open Web
 
jVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginijVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by Schogini
 
LOD2 webinar series: Virtuoso by OpenLink Software
LOD2 webinar series: Virtuoso by OpenLink SoftwareLOD2 webinar series: Virtuoso by OpenLink Software
LOD2 webinar series: Virtuoso by OpenLink Software
 
Dependency Injection & IoC
Dependency Injection & IoCDependency Injection & IoC
Dependency Injection & IoC
 
Framework Independent Architectures
Framework Independent ArchitecturesFramework Independent Architectures
Framework Independent Architectures
 
Semantic Representation of Provenance in Wikipedia
Semantic Representation of Provenance in WikipediaSemantic Representation of Provenance in Wikipedia
Semantic Representation of Provenance in Wikipedia
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Roboguice