SlideShare una empresa de Scribd logo
1 de 59
Enterprise Guice

 Robbie Vanbrabant
Dependency



             Art by Jesse Wilson
Pure Java™
interface Hero {
}

class Batman implements Hero {
}

class GothamCity {
  GothamCity(Hero hero) {
    ...
  }
}
class GothamCity {
  @Inject GothamCity(Hero hero) {
    ...
  }
}

class HeroModule implements Module {
  public void configure(Binder binder) {
    binder.bind(Hero.class).to(Batman.class);
  }
}
Enterprise Guice
2.0
  Guice

              2.0
Warp   Persist

 Google GIN
Art by Jesse Wilson
Basics
AOP
     for
Mere Mortals
Guice Servlet
Java Virtual Machine

                    Web Container



                                            Servlet
                          Filter pipeline
HTTP Request


HTTP Request                                Servlet


HTTP Request
                                            Servlet
Java Virtual Machine

                 Web Container



                                                        Servlet
HTTP Request       GuiceFilter        Filter pipeline


HTTP Request                                            Servlet


HTTP Request
                                                        Servlet
2.0
AssistedInject
Private Modules
Modules.override(
  new ProductionModule(),
  new TestModule()
);
Grapher
Code {}
  vs
<XML/>
Properties
database.url        =   jdbc:mysql://localhost/test
database.driver     =   com.mysql.jdbc.Driver
database.user       =   test
database.password   =   test
class PropertiesModule extends AbstractModule {
  protected void configure() {
    Names.bindProperties(binder(),
        load(“database.properties”));
  }
}

class UsesDatabase {
  @Inject @Named(“database.host”)
  private String host;
}
But I Want <XML/>
Compile-time Smiling
class AppModule extends AbstractModule {
  protected void configure() {
    install(new DataModule());
    install(new WebModule());
  }
}

<beans>
    <import resource=“data-context.xml”/>
    <import resource=“web-context.xml”/>
</beans>
@Annotations
     and
Tight Coupling
Summary
Guice 1.0 March 2007

Guice 2.0 Any minute
Hibernate

   JPA

 DB4O

Neodatis
@Transactional

Dynamic Finders
Unit of Work

Session / Transaction


Session / Request
class PersistenceModule extends ServletModule {
  protected void configureServlets() {

        install(PersistenceService.usingHibernate()
                                  .across(UnitOfWork.REQUEST)
                                  .buildModule());

        bind(Configuration.class).toInstance(
            new AnnotationConfiguration()
                .addAnnotatedClass(Product.class)
                .setProperties(load(quot;hibernate.propertiesquot;))
        );

        filter(“/*”).through(PersistenceFilter.class);
    }
}

Guice.createInjector(new PersistenceModule());
# configure hibernate to use the HSQL in-memory database
hibernate.connection.driver_class=org.hsqldb.jdbcDriver
hibernate.connection.url=jdbc:hsqldb:mem
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.connection.pool_size=1
hibernate.dialect=org.hibernate.dialect.HSQLDialect

# creates tables for us automatically
hibernate.hbm2ddl.auto=create

# let Warp Persist apply the open-session-in-view pattern
hibernate.current_session_context_class=managed

# don’t use 2nd level caching
hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
public class ProductManager {
    @Inject Provider<Session> session;

    @Transactional
    public void create(Product p) {
        session.get().save(p);
    }
}
public interface ProductAccess {
  @Transactional
  @Finder(namedQuery=“all products”)
  List<Product> listAll();

    @Transactional
    @Finder(query=“from Product where pn = :name”)
    Product find(@Named(“name”) String name);
}
@Transactional(rollbackOn = IOException.class,
               exceptOn = FileNotFoundException.class)
public class ProductService {
    @Inject Provider<Session> session;

    public void process(Product p) throws IOException {
        session.get().save(p);

        // do IO stuff
    }
}
PersistenceService.usingHibernate()
                  .across(UnitOfWork.REQUEST)
                  .forAll(
                      annotatedWith(Transactional.class),
                      any())
                  .buildModule());
Multiple Modules
public class ProductManager {
    @Inject @Product
    Provider<Session> session;

    @Transactional(unit=Product.class)
    public void create(Product p) {
        session.get().save(p);
    }
}
class PersistenceModule extends ServletModule {
  protected void configureServlets() {
    HibernatePersistenceStrategy hibernate =
        HibernatePersistenceStrategy.builder()
            .annotatedWith(Product.class).build();

        // Connect to the product database
        PersistenceService.using(hibernate)
                         .across(UnitOfWork.TRANSACTION)
                         .buildModule();

        bind(Configuration.class).annotatedWith(Product.class).toInstance(
            new AnnotationConfiguration()
                .addAnnotatedClass(Product.class)
                .setProperties(load(quot;hibernate.propertiesquot;))
        );
        ...
    }
}
Google GIN
on the
Client
Google Web Toolkit
brings
  Type Safety
       to
Web Development
Miracles Happen
   Java™                JavaScript
              Miracle
Source Code               HTML
“Bunny Heaven” by Mikko Eerola
No Bytecode
    cglib
No Reflection
     MyType.class
klazz.getAnnotation(...)
   Class.forName(...)
GIN
            is
Statically Compiled Guice
Code Generator
Zero
Overhead
Guice
http://code.google.com/p/google-guice

                Warp
http://code.google.com/p/warp-persist

              Google GIN
 http://code.google.com/p/google-gin

               Robbie
     http://garbagecollected.org
Pray for Common Sense
Enterprise Guice
Enterprise Guice 20090217 Bejug

Más contenido relacionado

La actualidad más candente

Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersNaresha K
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureZachary Klein
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developersTricode (part of Dept)
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7Dongho Cho
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011Manuel Carrasco Moñino
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitAriya Hidayat
 
Ship your Scala code often and easy with Docker
Ship your Scala code often and easy with DockerShip your Scala code often and easy with Docker
Ship your Scala code often and easy with DockerMarcus Lönnberg
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-kyon mm
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
 
BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...
BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...
BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...Mark A
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new buildIgor Khotin
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Tomek Kaczanowski
 
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationGDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationKAI CHU CHUNG
 
Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2Fabio Collini
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesHassan Abid
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with DropwizardAndrei Savu
 

La actualidad más candente (20)

Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
 
Micronaut Launchpad
Micronaut LaunchpadMicronaut Launchpad
Micronaut Launchpad
 
Spring 4 - A&BP CC
Spring 4 - A&BP CCSpring 4 - A&BP CC
Spring 4 - A&BP CC
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro Future
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developers
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Ship your Scala code often and easy with Docker
Ship your Scala code often and easy with DockerShip your Scala code often and easy with Docker
Ship your Scala code often and easy with Docker
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 
BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...
BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...
BizSpark SF Lightning Talk: "Automated Testing (Unit, Integration and Systems...
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
Android development
Android developmentAndroid development
Android development
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010
 
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationGDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
 
Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin Coroutines
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 

Similar a Enterprise Guice 20090217 Bejug

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 02rhemsolutions
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EEAlexis Hassler
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Michael Plöd
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitIMC Institute
 
Groovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web ApplicationsGroovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web Applicationsrohitnayak
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CNjojule
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web FrameworkLuther Baker
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Chris Ramsdale
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 

Similar a Enterprise Guice 20090217 Bejug (20)

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
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
Guice gin
Guice ginGuice gin
Guice gin
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 
Sapphire Gimlets
Sapphire GimletsSapphire Gimlets
Sapphire Gimlets
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
 
Groovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web ApplicationsGroovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web Applications
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
 
Arquitecturas de microservicios - Medianet Software
Arquitecturas de microservicios   -  Medianet SoftwareArquitecturas de microservicios   -  Medianet Software
Arquitecturas de microservicios - Medianet Software
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
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
 
Servlets
ServletsServlets
Servlets
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 

Último

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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 WorkerThousandEyes
 
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 MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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...apidays
 
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 2024Rafal Los
 
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...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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...
 
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
 
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...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Enterprise Guice 20090217 Bejug

  • 2. Dependency Art by Jesse Wilson
  • 4. interface Hero { } class Batman implements Hero { } class GothamCity { GothamCity(Hero hero) { ... } }
  • 5. class GothamCity { @Inject GothamCity(Hero hero) { ... } } class HeroModule implements Module { public void configure(Binder binder) { binder.bind(Hero.class).to(Batman.class); } }
  • 6.
  • 7.
  • 9. 2.0 Guice 2.0 Warp Persist Google GIN
  • 10. Art by Jesse Wilson
  • 12. AOP for Mere Mortals
  • 14. Java Virtual Machine Web Container Servlet Filter pipeline HTTP Request HTTP Request Servlet HTTP Request Servlet
  • 15. Java Virtual Machine Web Container Servlet HTTP Request GuiceFilter Filter pipeline HTTP Request Servlet HTTP Request Servlet
  • 18. Modules.override( new ProductionModule(), new TestModule() );
  • 20.
  • 21.
  • 22. Code {} vs <XML/>
  • 23.
  • 24. Properties database.url = jdbc:mysql://localhost/test database.driver = com.mysql.jdbc.Driver database.user = test database.password = test
  • 25. class PropertiesModule extends AbstractModule { protected void configure() { Names.bindProperties(binder(), load(“database.properties”)); } } class UsesDatabase { @Inject @Named(“database.host”) private String host; }
  • 26. But I Want <XML/>
  • 27. Compile-time Smiling class AppModule extends AbstractModule { protected void configure() { install(new DataModule()); install(new WebModule()); } } <beans> <import resource=“data-context.xml”/> <import resource=“web-context.xml”/> </beans>
  • 28. @Annotations and Tight Coupling
  • 30. Guice 1.0 March 2007 Guice 2.0 Any minute
  • 31.
  • 32.
  • 33. Hibernate JPA DB4O Neodatis
  • 35. Unit of Work Session / Transaction Session / Request
  • 36. class PersistenceModule extends ServletModule { protected void configureServlets() { install(PersistenceService.usingHibernate() .across(UnitOfWork.REQUEST) .buildModule()); bind(Configuration.class).toInstance( new AnnotationConfiguration() .addAnnotatedClass(Product.class) .setProperties(load(quot;hibernate.propertiesquot;)) ); filter(“/*”).through(PersistenceFilter.class); } } Guice.createInjector(new PersistenceModule());
  • 37. # configure hibernate to use the HSQL in-memory database hibernate.connection.driver_class=org.hsqldb.jdbcDriver hibernate.connection.url=jdbc:hsqldb:mem hibernate.connection.username=sa hibernate.connection.password= hibernate.connection.pool_size=1 hibernate.dialect=org.hibernate.dialect.HSQLDialect # creates tables for us automatically hibernate.hbm2ddl.auto=create # let Warp Persist apply the open-session-in-view pattern hibernate.current_session_context_class=managed # don’t use 2nd level caching hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
  • 38. public class ProductManager { @Inject Provider<Session> session; @Transactional public void create(Product p) { session.get().save(p); } }
  • 39. public interface ProductAccess { @Transactional @Finder(namedQuery=“all products”) List<Product> listAll(); @Transactional @Finder(query=“from Product where pn = :name”) Product find(@Named(“name”) String name); }
  • 40. @Transactional(rollbackOn = IOException.class, exceptOn = FileNotFoundException.class) public class ProductService { @Inject Provider<Session> session; public void process(Product p) throws IOException { session.get().save(p); // do IO stuff } }
  • 41. PersistenceService.usingHibernate() .across(UnitOfWork.REQUEST) .forAll( annotatedWith(Transactional.class), any()) .buildModule());
  • 43. public class ProductManager { @Inject @Product Provider<Session> session; @Transactional(unit=Product.class) public void create(Product p) { session.get().save(p); } }
  • 44. class PersistenceModule extends ServletModule { protected void configureServlets() { HibernatePersistenceStrategy hibernate = HibernatePersistenceStrategy.builder() .annotatedWith(Product.class).build(); // Connect to the product database PersistenceService.using(hibernate) .across(UnitOfWork.TRANSACTION) .buildModule(); bind(Configuration.class).annotatedWith(Product.class).toInstance( new AnnotationConfiguration() .addAnnotatedClass(Product.class) .setProperties(load(quot;hibernate.propertiesquot;)) ); ... } }
  • 48. brings Type Safety to Web Development
  • 49. Miracles Happen Java™ JavaScript Miracle Source Code HTML
  • 50. “Bunny Heaven” by Mikko Eerola
  • 51. No Bytecode cglib
  • 52. No Reflection MyType.class klazz.getAnnotation(...) Class.forName(...)
  • 53. GIN is Statically Compiled Guice
  • 56. Guice http://code.google.com/p/google-guice Warp http://code.google.com/p/warp-persist Google GIN http://code.google.com/p/google-gin Robbie http://garbagecollected.org