SlideShare a Scribd company logo
Google Guice
  Kirill Afanasjev
 Software Architect




       jug.lv
    Riga, Latvia
Overview

   Dependency Injection
   Why Guice
   Getting Guice
   Using Guice
   Advanced Guice
Code without DI

 public void sendButtonClicked() {
     String text = messageArea.getText();
     Validator validator = new MailValidator();
     validator.validate(text);
     MailSender sender = new MailSender();
     sender.send(text);
 }
Using factories

 public void sendButtonClicked() {
      String text = messageArea.getText();
      Validator validator = ValidatorFactory.get();
      validator.validate(text);
      MailSender sender = SenderFactory.get();
      sender.send(text);
  }

Recommended for you

AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation

What is AngularJS AngularJS main components View / Controller / Module / Scope Scope Inheritance. Two way data binding $watch / $digest / $apply Dirty Checking DI - Dependence Injection $provider vs $factory vs $service

angularjs
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB

Serverless development with MongoDB Stitch allows developers to build applications without managing infrastructure. Stitch provides four main services - QueryAnywhere for data access, Functions for server-side logic, Triggers for real-time notifications, and Mobile Sync for offline data synchronization. These services integrate with MongoDB and other data sources through a unified API, and apply access controls and filters to queries. Functions can be used to build applications or enable data services, and are integrated with application context including user information, services, and values. This allows developers to write code without dealing with deployment or scaling.

mongodbmongodb.localmongodb atlas
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions

https://youtu.be/_yLt_abcK2w Angular is a TypeScript-based open-source front-end platform that makes it easy to build applications with in web/mobile/desktop. The major features of this framework such as declarative templates, dependency injection, end to end tooling, and many more other features are used to ease the development. Angular 7 is a Javascript framework built around the concept of components, and more precisely, with the Web Components standard in mind. It was rewritten from scratch by the Angular team using Typescript (although we can use it with ES5, ES6, or Dart as well). Angular 7 is a big change for us compared to 1.x. Because it is a completely different framework than 1.x, and is not backward-compatible. Angular 7 is written entirely in Typescript and meets the ECMAScript 6 specification angular interview questions and answers, angular 7 interview questions and answers, angular interview question, angular interview questions and answers for experienced, angular 7 interview questions, angular 6 interview questions, angular interview questions, angular 6 interview questions and answers, angular 2 interview questions, angular7, angular 5 interview questions, angular interview, angular 2 interview questions and answers, angular questions and answers

angularangular interview questions and answersangular 7 interview questions and answers
Testable now
 public void testSendButton() {
      MockSender mockSender = new MockSender();
      SenderFactory.setInstance(mockSender);
      MailForm form = new MailForm();
      form.getMessageArea().setText("Some text");
      form.sendButtonClicked();
      assertEquals("Some text", mockSender.getSentText());
      SenderFactory.clearInstance();
 }
Well, not really
 public void testSendButton() {
       MockSender mockSender = new MockSender();
       SenderFactory.setInstance(mockSender);
       try {
           MailForm form = new MailForm();
           form.getMessageArea().setText("Some text");
           form.sendButtonClicked();
           assertEquals("Some text", mockSender.getSentText());
       } finally {
           SenderFactory.clearInstance();
       }
   }
Dependency injection

 private Validator validator;
 private MailSender mailSender;


 public MailForm(Validator validator, MailSender mailSender) {
       this.validator = validator;
       this.mailSender = mailSender;
 }


 public void sendButtonClicked() {
 …..
Testing now

 public void testSendButton() {
      MockSender mockSender = new MockSender();
      Validator validator = new Validator();
      MailForm form = new MailForm(validator, mockSender);
      form.getMessageArea().setText("Some text");
      form.sendButtonClicked();
      assertEquals("Some text", mockSender.getSentText());
 }

Recommended for you

Angular Interview Questions & Answers
Angular Interview Questions & AnswersAngular Interview Questions & Answers
Angular Interview Questions & Answers

Top Angular Interview Questions and answers would help freshers and experienced candidates clear any Angular interview .Do let us know the Angular questions you faced in the interview that are covered ...

angular4angular2angular5
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop

AngularJS is an open-source JavaScript framework for building dynamic web applications. It uses HTML as the template language and allows extending HTML vocabulary for the application. The key concepts covered in the document include modules and dependency injection, data binding using controllers and scopes, services, filters, form validation, directives, and routing. Various AngularJS features like modules, controllers, services, directives etc. are demonstrated via code examples. The document provides an introduction to core AngularJS concepts through explanations, code samples and a demo.

angularjswebjavascript
Quick answers to Angular2+ Interview Questions
Quick answers to Angular2+ Interview QuestionsQuick answers to Angular2+ Interview Questions
Quick answers to Angular2+ Interview Questions

Here are some answers to common Angular interview questions. That's Angular 2+, not AngularJS. They’re quick, not really extended and are not in any particular order. Let’s get it on!

angularinterviewquestions
Why DI frameworks

   Avoid boilerplate code
   AOP
   Integrate your DI with http session/request,
    data access APIs, e.t.c
   Separate dependencies configuration from
    code
   Makes life easier
What is Guice

   Open source dependency injection framework
   License : Apache License 2.0
   Developer : Google
Why Guice

   Java API for configuration
   Easier to use
   Line numbers in error messages
   Less overhead
   Less features, too
   DI in GWT client-side code (using GIN)
Getting Guice

   http://code.google.com/p/google-guice/
   http://mvnrepository.com/
   Small – 865 KB
   Version without AOP, suitable for Android –
    470KB
   Lacks fast reflection and line numbers in errors

Recommended for you

Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs

This document provides an overview of Angular 2 and Rxjs. Some key points covered include: - Angular 2 is backed by Google and designed to be faster and more memory efficient than Angular 1. It uses TypeScript and focuses on components. - Bootstrapping, modules, directives, bindings and pipes work differently in Angular 2 compared to Angular 1 with fewer overall concepts. - Observables and operators from Rxjs allow for asynchronous programming and composing asynchronous operations. Common operators like map, filter and flatMap are discussed. - Services can be used to share data between components. Components follow a lifecycle with hooks like ngOnInit and ngOnDestroy. -

angular2rxjsangularjs
Angular2
Angular2Angular2
Angular2

The document discusses Angular modules, directives, and components. Angular modules help organize an application into blocks of functionality using the @NgModule annotation. There are three types of directives - components, attribute directives, and structural directives. Components are a subset of directives that use the @Component annotation and define templates to specify elements and logic on a page. The metadata definitions for @NgModule, @Directive, and @Component are also described.

Guice
GuiceGuice
Guice

Guice is a lightweight Java dependency injection framework that allows developers to declare dependencies through modules and inject them using annotations. With Guice, developers can define bindings between interfaces and implementations, and annotate constructors and fields to specify injection points. This reduces boilerplate code compared to alternatives like implementing dependency injection by hand. Guice validates dependencies at startup and handles circular dependencies automatically.

Dependency injection with Guice

 private Validator validator;
 private MailSender mailSender;


 @Inject
 public MailForm(Validator validator, MailSender mailSender) {
      this.validator = validator;
      this.mailSender = mailSender;
 }
Creating instance of MailForm

 Injector injector =
     Guice.createInjector(new YourAppModule());
 MailForm mailForm = injector.getInstance(MailForm.class);
Bindings

 public class YourAppModule extends AbstractModule {
     protected void configure() {
                bind(MailService.class).to(MailServiceImpl.class);
                bind(Validator.class).to(ValidatorImpl.class);
     }
 }
Providers
 public class YourAppModule extends AbstractModule {
      protected void configure() {
                 bind(Validator.class).to(ValidatorImpl.class);
      }


      @Provides
      MailService getMailService() {
                 MailService service = new MailService();
                 return service;

      }
 ….

Recommended for you

Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection

Dependency injection is a design pattern that removes tight coupling between objects and their dependencies. It allows for objects to have their dependencies satisfied externally rather than internally. There are three main types of dependency injection: constructor injection, setter injection, and interface injection. Constructor injection passes dependencies through a class's constructor, while setter injection uses properties, and interface injection relies on implementing a common interface. Dependency injection promotes loose coupling, testability, and flexibility between classes.

Html5 Interview Questions & Answers
Html5 Interview Questions & AnswersHtml5 Interview Questions & Answers
Html5 Interview Questions & Answers

Read Best Html5 interview questions with their answers.hether you're a candidate or interviewer, these interview questions will help ...

Spring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGSpring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUG

The document provides an overview of Spring MVC and best practices for implementing the MVC pattern with Spring. It discusses the basic components of MVC - Model, View, Controller - and how Spring splits code into these areas. It describes annotations used in Spring MVC like @Controller, @RequestMapping, and @ModelAttribute. It also covers common tasks like handling user input, populating the model, creating forms, and using Bean Validation. Finally, it discusses additional topics like view resolvers, exception handling, and file uploads.

springmvcjava
Injecting fields

 @Inject
 private Validator validator;
 @Inject
 private MailSender mailSender;


 public MailForm() {
 }
Injecting with setter methods

   private Validator validator;


   public MailForm() {
   }


   @Inject
   public void setValidator(Validator validator) {
               this.validator = validator;
   }
Optional injection

   Inject(optional=true)
   Ignores values for which no bindings are
    avalaible
   Possible with setter methods only
Bind instance

    protected void configure() {
         bind(Integer.class).annotatedWith(ThreadCount.cla
         ss).toInstance(4);
    }
    ..
    @ThreadCount
    int threadCount;

   IDE autocomplete, find usages e.t.c

Recommended for you

Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection

Boost the quality of your code by learning how to use the patterns and principles of dependency injection!

testabilitysolidinversion of control
JSRs 303 and 330 in Action
JSRs 303 and 330 in ActionJSRs 303 and 330 in Action
JSRs 303 and 330 in Action

This document discusses integrating Apache Bean Validation with Google Guice. It describes how to bootstrap Bean Validation using Guice, obtain ConstraintValidator instances via Guice injection, require injection of javax.validation components, and intercept methods to validate arguments. Integrating the two allows for dependency injection with Bean Validation and easy validation of method arguments using annotations.

apache bval google guice
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)

This document discusses effective practices for dependency injection (DI). It begins with a quick DI refresher and then provides guidelines for DI such as: explicitly defining dependencies, injecting exactly what is needed, preferring constructor injection, avoiding work in constructors, and avoiding direct dependencies on the injector. It also discusses testing code using DI, applying DI to existing code, and techniques for migrating code to use DI such as bottom-up or top-down approaches.

Two implementations
  protected void configure() {
             bind(Validator.class).to(ValidatorImpl.class);
             bind(Validator.class).to(StrictValidatorImpl.class);
  }
Two implementations

Exception in thread "main" com.google.inject.CreationException:
Guice configuration errors:
1) Error at lv.jug.MailService.configure(YourAppModule.java:12):
A binding to lv.jug.MailService was already configured at
lv.jug.YourAppModule.configure(YourAppModule.java:11)
Two implementations
  protected void configure() {
                bind(Validator.class).to(ValidatorImpl.class);
                bind(Validator.class)
                   .annotatedWith(Strict.class)
                   .to(StrictValidatorImpl.class);
  }
  ….
  @Inject
  public MailForm(@Strict Validator validator) {
      this.validator = validator;
  }
Binding annotation

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@BindingAnnotation
public @interface Strict {}

Recommended for you

Jsr 303
Jsr 303Jsr 303
Jsr 303

JSR-303 defines a metadata model and API for JavaBean validation using annotations. It allows for validation on both the server and client sides. Implementations include Hibernate Validator and Apache Bean Validation. Validation can be configured using annotations and custom constraints can be defined. Errors are handled by binding results to the model in Spring MVC. Both property and object level validation can be tested.

Sapphire Gimlets
Sapphire GimletsSapphire Gimlets
Sapphire Gimlets

This document provides an overview of the Guice and Gin dependency injection frameworks. It discusses key features and differences between the two, including how Guice supports both server-side and client-side Java applications while Gin is tailored specifically for GWT client-side apps. Examples are given of basic usage and configuration for common tasks like singleton scopes and dependency injection.

gin guice java gwt
Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New

Spring 3 emphasizes annotation configuration over XML. Key changes include support for JSR 250, 299/330, and 303 annotations as well as a simplified MVC framework with @Controller and @RequestMapping annotations. Validation is integrated using JSR 303 annotations and executed automatically by the framework. Configuration is also simplified through @Configuration classes and the @Bean annotation.

springjavajee
Implicit binding

      @Inject
      public MailForm(
         @ImplementedBy(StrictValidator.class) Validator
         Validator validator,
         MailSender mailSender) {
       this.validator = validator;
       this.mailSender = mailSender;
  }
Static injection

   protected void configure() {
               bind(Validator.class).to(ValidatorImpl.class);
               requestStaticInjection(OurClass.class);
   }
   …
   …
  @Inject static Validator validator;
Scoping

  protected void configure() {
             bind(Validator.class).to(ValidatorImpl.class)
                   .in(Scopes.SINGLETON);
             bind(MailService.class).to(MailServiceImpl.class)
                   .asEagerSingleton();
  }
Multibindings

  Multibinder<Plugin> pluginBinder =
  Multibinder.newSetBinder(binder(), Plugin.class);
  pluginBinder.addBinding().to(SomePluginImpl.class);
  pluginBinder.addBinding().to(AnotherPluginImpl.class);
  ….

  @Inject Set<Plugin> plugins

Recommended for you

Guice gin
Guice ginGuice gin
Guice gin

This document provides an overview of the Guice and Gin dependency injection frameworks. It discusses key features of Guice like annotation-based configuration, scopes, and type-safe injection. It compares Guice to Spring, noting Guice's simpler configuration. It also covers using Guice and Gin in web applications and GWT clients. Additional topics include the Warp utilities, configuration options like @Named, and limitations of Gin for GWT apps.

java guice gin
Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914

This document discusses different methods for implementing validation in Entity Framework models, including: - Using data annotations to enable client-side and server-side validation. Properties can be marked as required, have a maximum length, etc. - Implementing validation logic in the DbContext using the Fluent API. This allows validating properties when the model is created. - Implementing custom validation by having entities implement IValidatableObject and adding validation logic. - Overriding ValidateEntity in the DbContext to add validation that runs when entities are added, modified or deleted. - Explicitly triggering validation by calling GetValidationErrors instead of just waiting for SaveChanges.

Enterprise Guice 20090217 Bejug
Enterprise Guice 20090217 BejugEnterprise Guice 20090217 Bejug
Enterprise Guice 20090217 Bejug

This document summarizes the Guice dependency injection framework. It provides an overview of key Guice concepts like dependency injection, modules, and bindings. It also discusses Guice extensions like Warp Persist for persistence and transaction management and Google GIN which compiles Guice configuration at compile time for improved performance.

bejugjavaguice
Grapher

   Describe the object graph in detail
   Show bindings and dependencies from several
    classes in a complex application in a unified
    diagram
   Generates .dot file
Advanced Guice
   AOP
   Warp
   Google Gin
   Spring integration
   Using guice with Servlets
Why AOP

   Transaction handling
   Logging
   Security
   Exception handling
   e.t.c
AOP
   void bindInterceptor(
    Match <? super Class<?>> classMatcher,
    Matcher<? super Method> methodMatcher,
    MethodInterceptor... interceptors)


    public interface MethodInterceptor extends
    Interceptor {
        Object invoke (MethodInvocation invocation) throws
        Throwable
    }

Recommended for you

Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6

Apache Wicket is constantly growing in popularity throughout all kinds of projects. However Wicket doesn't come out of the box with a built-in Java EE support. Integration to CDI is missing and the same is valid for Bean Validation support for example. This session demonstrates how you can user CDI, Conversations and Bean Validation together with Apache Wicket. The first part of the talk will consist of a small slide-driven theoretical part whereas the second part will consist of a coding session that demonstrates hands-on how to hook everything together.

wicketjavaweb development
Creating a Facebook Clone - Part XXV - Transcript.pdf
Creating a Facebook Clone - Part XXV - Transcript.pdfCreating a Facebook Clone - Part XXV - Transcript.pdf
Creating a Facebook Clone - Part XXV - Transcript.pdf

This is a part of an online Codename One course published around 2017 see it all for free at https://debugagent.com/series/cn1

Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02

This document discusses architecting a GWT application with the GWT-Platform framework. It recommends using a Model-View-Presenter architecture and describes some MVP frameworks for GWT including gwt-platform. It provides an overview of how to structure an app with GWT-Platform and GXT3 including using places, tokens, presenters and dependency injection with GIN. It also covers styling the app with ClientBundle and includes sample code for creating a default presenter.

gwtgwtpmvp
AOP

   You can not match on private and final methods
    due to technical limitations in Java
   Only works for objects Guice creates
Warp

   http://www.wideplay.com/
   Eco-system for Google Guice
   Thin lightweight modules for Guice applications
   Persistence
   Transactions
   Servlets
Warp-persist

   Supports : Hibernate/JPA/Db4Objects
   Inject DAOs & Repositories
   Flexible units-of-work
   Declarative transaction management
    ( @Transactional )
   Your own AOP for transactions management
   @Finder(query="from Person")
Google Gin

   Automatic dependency injection for GWT client-
    side code
   Code generation
   Little-to-no runtime overhead, compared to
    manual DI
   Uses Guice binding language
   http://code.google.com/p/google-gin/

Recommended for you

Jasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casJasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-cas

The document discusses migrating an existing authentication system at Columbia University to the Central Authentication Service (CAS). Specifically, it addresses: 1) Integrating the legacy service registry and custom attributes into CAS. 2) Adding support for the legacy "WIND" authentication protocol to CAS to allow existing clients to continue using either the legacy or CAS protocols during migration. 3) Customizing CAS login behavior and UI to match the existing system.

jasigsakai12
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad

CDI provides standards-based and typesafe dependency injection in Java EE 6. It integrates well with other Java EE 6 technologies like EJB, JPA, JSF, and JAX-WS. Portable extensions facilitate a richer programming model. Weld is the reference implementation of CDI and is integrated into application servers like GlassFish and JBoss.

javaoneindiajavaee
Thomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalThomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-final

The document discusses dependency injection (DI) using RoboGuice in Android applications. DI makes code more concise, modular, and easier to test by allowing classes to declare dependencies without knowing how they are satisfied. RoboGuice uses annotations to inject dependencies into activities and services. It allows for loose coupling, high cohesion, and centralized configuration through bindings. DI improves testability by increasing controllability, observability, and isolation of units under test.

Spring integration

   http://code.google.com/p/guice-spring/
   @Named(”mySpringBean”)
JSR-330

   javax.inject
   @Inject
   @Named
   @Qualifier
   @Scope
   @Singleton
   e.t.c
   Supported by Guice, Spring, EJB
Using Guice with Servlets

   @RequestScoped
   @SessionScoped
   ServletModule
   serve(”/admin”).with(AdminPanelServlet.class)
   serve("*.html", "/my/*").with(MyServlet.class)
   filter(”/*”).through(MyFilter.class)
   @Inject @RequestParameters Map<String,
    String[]> params;
Thank you

   Questions ?

Recommended for you

Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container

Introduction of Dependency Injection pattern, and integration of 'Symfony Injection' component and 'Zend Framework'.

php software oo zend symfony injection di dependen
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE

Le temps est révolu où Java EE ne serait qu’à développer des applications de mise à jour de données, avec JSF / EJB / JPA. Aujourd’hui Java EE s’est assoupli et s’est ouvert sur le monde, avec CDI comme clé de voûte et a repoussé nos limites grâce à des capacités d’extension puissantes et faciles d’utilisation comme JCA. Dans un premier temps, nous reviendrons rapidement sur la place de CDI dans JavaEE 7 et sur ses mécanismes d’extension. Dans un deuxième temps, nous verrons les techniques de connecteurs JCA et comment ils peuvent aussi constituer une possibilité d’ouverture simple à mettre en œuvre. JCA fournit des techniques pour gérer des connexions sortantes ou entrantes, sur des formats ou protocoles variés.

java eejcacdi
ASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 Validation

1. Validations in MVC can be done using data annotations attributes on models, custom validation attributes, and implementing validation interfaces. 2. Data annotations attributes provide both client and server validation without additional coding and include attributes like Required, StringLength, Range etc. 3. Custom validation attributes can be created by deriving from ValidationAttribute and overriding IsValid. These work on the server. 4. Client side validation is enabled by including jQuery and validation scripts. Data annotations are translated to HTML5 data attributes that jQuery validation understands.

aspnetvalidationmvc

More Related Content

What's hot

Dependency Injection with Unity Container
Dependency Injection with Unity ContainerDependency Injection with Unity Container
Dependency Injection with Unity Container
Mindfire Solutions
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
Ravindra K
 
Dependency Injection Inversion Of Control And Unity
Dependency Injection Inversion Of Control And UnityDependency Injection Inversion Of Control And Unity
Dependency Injection Inversion Of Control And Unity
rainynovember12
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
Phan Tuan
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
Goa App
 
Angular Interview Questions & Answers
Angular Interview Questions & AnswersAngular Interview Questions & Answers
Angular Interview Questions & Answers
Ratnala Charan kumar
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
Ran Wahle
 
Quick answers to Angular2+ Interview Questions
Quick answers to Angular2+ Interview QuestionsQuick answers to Angular2+ Interview Questions
Quick answers to Angular2+ Interview Questions
Luis Martín Espino Rivera
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
Christoffer Noring
 
Angular2
Angular2Angular2
Guice
GuiceGuice
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Anand Kumar Rajana
 
Html5 Interview Questions & Answers
Html5 Interview Questions & AnswersHtml5 Interview Questions & Answers
Html5 Interview Questions & Answers
Ratnala Charan kumar
 
Spring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGSpring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUG
Ted Pennings
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Giovanni Scerra ☃
 

What's hot (16)

Dependency Injection with Unity Container
Dependency Injection with Unity ContainerDependency Injection with Unity Container
Dependency Injection with Unity Container
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
 
Dependency Injection Inversion Of Control And Unity
Dependency Injection Inversion Of Control And UnityDependency Injection Inversion Of Control And Unity
Dependency Injection Inversion Of Control And Unity
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
 
Angular Interview Questions & Answers
Angular Interview Questions & AnswersAngular Interview Questions & Answers
Angular Interview Questions & Answers
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
Quick answers to Angular2+ Interview Questions
Quick answers to Angular2+ Interview QuestionsQuick answers to Angular2+ Interview Questions
Quick answers to Angular2+ Interview Questions
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Angular2
Angular2Angular2
Angular2
 
Guice
GuiceGuice
Guice
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Html5 Interview Questions & Answers
Html5 Interview Questions & AnswersHtml5 Interview Questions & Answers
Html5 Interview Questions & Answers
 
Spring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGSpring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUG
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 

Similar to Jug Guice Presentation

JSRs 303 and 330 in Action
JSRs 303 and 330 in ActionJSRs 303 and 330 in Action
JSRs 303 and 330 in Action
simonetripodi
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
Jerome Dochez
 
Jsr 303
Jsr 303Jsr 303
Sapphire Gimlets
Sapphire GimletsSapphire Gimlets
Sapphire Gimlets
Robert Cooper
 
Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New
Ted Pennings
 
Guice gin
Guice ginGuice gin
Guice gin
Robert Cooper
 
Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914
LearningTech
 
Enterprise Guice 20090217 Bejug
Enterprise Guice 20090217 BejugEnterprise Guice 20090217 Bejug
Enterprise Guice 20090217 Bejug
robbiev
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
Michael Plöd
 
Creating a Facebook Clone - Part XXV - Transcript.pdf
Creating a Facebook Clone - Part XXV - Transcript.pdfCreating a Facebook Clone - Part XXV - Transcript.pdf
Creating a Facebook Clone - Part XXV - Transcript.pdf
ShaiAlmog1
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02
rhemsolutions
 
Jasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casJasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-cas
ellentuck
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
Prasad Subramanian
 
Thomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalThomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-final
Droidcon Berlin
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
Diego Lewin
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
Alexis Hassler
 
ASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 Validation
Eyal Vardi
 
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter LehtoJavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Testing in android
Testing in androidTesting in android
Testing in android
jtrindade
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
First Tuesday Bergen
 

Similar to Jug Guice Presentation (20)

JSRs 303 and 330 in Action
JSRs 303 and 330 in ActionJSRs 303 and 330 in Action
JSRs 303 and 330 in Action
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Jsr 303
Jsr 303Jsr 303
Jsr 303
 
Sapphire Gimlets
Sapphire GimletsSapphire Gimlets
Sapphire Gimlets
 
Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New
 
Guice gin
Guice ginGuice gin
Guice gin
 
Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914
 
Enterprise Guice 20090217 Bejug
Enterprise Guice 20090217 BejugEnterprise Guice 20090217 Bejug
Enterprise Guice 20090217 Bejug
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 
Creating a Facebook Clone - Part XXV - Transcript.pdf
Creating a Facebook Clone - Part XXV - Transcript.pdfCreating a Facebook Clone - Part XXV - Transcript.pdf
Creating a Facebook Clone - Part XXV - Transcript.pdf
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02
 
Jasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casJasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-cas
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
Thomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalThomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-final
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
ASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 Validation
 
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter LehtoJavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
 
Testing in android
Testing in androidTesting in android
Testing in android
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
 

More from Dmitry Buzdin

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
Dmitry Buzdin
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
Dmitry Buzdin
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
Dmitry Buzdin
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
Dmitry Buzdin
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
Dmitry Buzdin
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
Dmitry Buzdin
 
JOOQ and Flyway
JOOQ and FlywayJOOQ and Flyway
JOOQ and Flyway
Dmitry Buzdin
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
Dmitry Buzdin
 
Whats New in Java 8
Whats New in Java 8Whats New in Java 8
Whats New in Java 8
Dmitry Buzdin
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на Одноклассниках
Dmitry Buzdin
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
Dmitry Buzdin
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
Dmitry Buzdin
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part II
Dmitry Buzdin
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching Solutions
Dmitry Buzdin
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
Dmitry Buzdin
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contest
Dmitry Buzdin
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
Dmitry Buzdin
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
Dmitry Buzdin
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
Dmitry Buzdin
 

More from Dmitry Buzdin (20)

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
 
JOOQ and Flyway
JOOQ and FlywayJOOQ and Flyway
JOOQ and Flyway
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
 
Whats New in Java 8
Whats New in Java 8Whats New in Java 8
Whats New in Java 8
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на Одноклассниках
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part II
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching Solutions
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contest
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
 

Recently uploaded

How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
Aurora Consulting
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
shanthidl1
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Bert Blevins
 
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
Liveplex
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
Matthew Sinclair
 

Recently uploaded (20)

How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
 
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
 

Jug Guice Presentation

  • 1. Google Guice Kirill Afanasjev Software Architect jug.lv Riga, Latvia
  • 2. Overview  Dependency Injection  Why Guice  Getting Guice  Using Guice  Advanced Guice
  • 3. Code without DI public void sendButtonClicked() { String text = messageArea.getText(); Validator validator = new MailValidator(); validator.validate(text); MailSender sender = new MailSender(); sender.send(text); }
  • 4. Using factories public void sendButtonClicked() { String text = messageArea.getText(); Validator validator = ValidatorFactory.get(); validator.validate(text); MailSender sender = SenderFactory.get(); sender.send(text); }
  • 5. Testable now public void testSendButton() { MockSender mockSender = new MockSender(); SenderFactory.setInstance(mockSender); MailForm form = new MailForm(); form.getMessageArea().setText("Some text"); form.sendButtonClicked(); assertEquals("Some text", mockSender.getSentText()); SenderFactory.clearInstance(); }
  • 6. Well, not really public void testSendButton() { MockSender mockSender = new MockSender(); SenderFactory.setInstance(mockSender); try { MailForm form = new MailForm(); form.getMessageArea().setText("Some text"); form.sendButtonClicked(); assertEquals("Some text", mockSender.getSentText()); } finally { SenderFactory.clearInstance(); } }
  • 7. Dependency injection private Validator validator; private MailSender mailSender; public MailForm(Validator validator, MailSender mailSender) { this.validator = validator; this.mailSender = mailSender; } public void sendButtonClicked() { …..
  • 8. Testing now public void testSendButton() { MockSender mockSender = new MockSender(); Validator validator = new Validator(); MailForm form = new MailForm(validator, mockSender); form.getMessageArea().setText("Some text"); form.sendButtonClicked(); assertEquals("Some text", mockSender.getSentText()); }
  • 9. Why DI frameworks  Avoid boilerplate code  AOP  Integrate your DI with http session/request, data access APIs, e.t.c  Separate dependencies configuration from code  Makes life easier
  • 10. What is Guice  Open source dependency injection framework  License : Apache License 2.0  Developer : Google
  • 11. Why Guice  Java API for configuration  Easier to use  Line numbers in error messages  Less overhead  Less features, too  DI in GWT client-side code (using GIN)
  • 12. Getting Guice  http://code.google.com/p/google-guice/  http://mvnrepository.com/  Small – 865 KB  Version without AOP, suitable for Android – 470KB  Lacks fast reflection and line numbers in errors
  • 13. Dependency injection with Guice private Validator validator; private MailSender mailSender; @Inject public MailForm(Validator validator, MailSender mailSender) { this.validator = validator; this.mailSender = mailSender; }
  • 14. Creating instance of MailForm Injector injector = Guice.createInjector(new YourAppModule()); MailForm mailForm = injector.getInstance(MailForm.class);
  • 15. Bindings public class YourAppModule extends AbstractModule { protected void configure() { bind(MailService.class).to(MailServiceImpl.class); bind(Validator.class).to(ValidatorImpl.class); } }
  • 16. Providers public class YourAppModule extends AbstractModule { protected void configure() { bind(Validator.class).to(ValidatorImpl.class); } @Provides MailService getMailService() { MailService service = new MailService(); return service; } ….
  • 17. Injecting fields @Inject private Validator validator; @Inject private MailSender mailSender; public MailForm() { }
  • 18. Injecting with setter methods private Validator validator; public MailForm() { } @Inject public void setValidator(Validator validator) { this.validator = validator; }
  • 19. Optional injection  Inject(optional=true)  Ignores values for which no bindings are avalaible  Possible with setter methods only
  • 20. Bind instance protected void configure() { bind(Integer.class).annotatedWith(ThreadCount.cla ss).toInstance(4); } .. @ThreadCount int threadCount;  IDE autocomplete, find usages e.t.c
  • 21. Two implementations protected void configure() { bind(Validator.class).to(ValidatorImpl.class); bind(Validator.class).to(StrictValidatorImpl.class); }
  • 22. Two implementations Exception in thread "main" com.google.inject.CreationException: Guice configuration errors: 1) Error at lv.jug.MailService.configure(YourAppModule.java:12): A binding to lv.jug.MailService was already configured at lv.jug.YourAppModule.configure(YourAppModule.java:11)
  • 23. Two implementations protected void configure() { bind(Validator.class).to(ValidatorImpl.class); bind(Validator.class) .annotatedWith(Strict.class) .to(StrictValidatorImpl.class); } …. @Inject public MailForm(@Strict Validator validator) { this.validator = validator; }
  • 25. Implicit binding @Inject public MailForm( @ImplementedBy(StrictValidator.class) Validator Validator validator, MailSender mailSender) { this.validator = validator; this.mailSender = mailSender; }
  • 26. Static injection protected void configure() { bind(Validator.class).to(ValidatorImpl.class); requestStaticInjection(OurClass.class); } … … @Inject static Validator validator;
  • 27. Scoping protected void configure() { bind(Validator.class).to(ValidatorImpl.class) .in(Scopes.SINGLETON); bind(MailService.class).to(MailServiceImpl.class) .asEagerSingleton(); }
  • 28. Multibindings Multibinder<Plugin> pluginBinder = Multibinder.newSetBinder(binder(), Plugin.class); pluginBinder.addBinding().to(SomePluginImpl.class); pluginBinder.addBinding().to(AnotherPluginImpl.class); …. @Inject Set<Plugin> plugins
  • 29. Grapher  Describe the object graph in detail  Show bindings and dependencies from several classes in a complex application in a unified diagram  Generates .dot file
  • 30. Advanced Guice  AOP  Warp  Google Gin  Spring integration  Using guice with Servlets
  • 31. Why AOP  Transaction handling  Logging  Security  Exception handling  e.t.c
  • 32. AOP  void bindInterceptor( Match <? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors) public interface MethodInterceptor extends Interceptor { Object invoke (MethodInvocation invocation) throws Throwable }
  • 33. AOP  You can not match on private and final methods due to technical limitations in Java  Only works for objects Guice creates
  • 34. Warp  http://www.wideplay.com/  Eco-system for Google Guice  Thin lightweight modules for Guice applications  Persistence  Transactions  Servlets
  • 35. Warp-persist  Supports : Hibernate/JPA/Db4Objects  Inject DAOs & Repositories  Flexible units-of-work  Declarative transaction management ( @Transactional )  Your own AOP for transactions management  @Finder(query="from Person")
  • 36. Google Gin  Automatic dependency injection for GWT client- side code  Code generation  Little-to-no runtime overhead, compared to manual DI  Uses Guice binding language  http://code.google.com/p/google-gin/
  • 37. Spring integration  http://code.google.com/p/guice-spring/  @Named(”mySpringBean”)
  • 38. JSR-330  javax.inject  @Inject  @Named  @Qualifier  @Scope  @Singleton  e.t.c  Supported by Guice, Spring, EJB
  • 39. Using Guice with Servlets  @RequestScoped  @SessionScoped  ServletModule  serve(”/admin”).with(AdminPanelServlet.class)  serve("*.html", "/my/*").with(MyServlet.class)  filter(”/*”).through(MyFilter.class)  @Inject @RequestParameters Map<String, String[]> params;
  • 40. Thank you  Questions ?