Guice Java Injection Framework http://code.google.com/p/google-guice/

Slides:



Advertisements
Presentaciones similares
Java nos ofrece System.out para escribir en pantalla, pero también tenemos System.in para leer. System.in es un objeto de una clase de java que se llama.
Advertisements

Cache Distribuida Ayudante - German Rende
FUNDAMENTALS OF THE JAVA PROGRAMMING LANGUAGE
UML 1.4 Peter Emerson Pinchao Solis.
5. Ingeniería de Pruebas LS4128: Ingeniería del Software II
UNIT TESTING pruebas unitarias pruebas unitarias.
Spring Framework v2.5.
Ddd PATTERNS JAVA
Índice 1. Introducción, objetivos y justificación del proyecto.
RMI (Remote Method Invocation)
Aplicación del paradigma orientado a objetos
Encapsulamiento y Abstracción
Abstracción de Datos La abstracción es un recurso fundamental en la programación orientada a objetos y está además fuertemente ligado a reusabilidad.
JAVA Persistence API (JPA)
Patrones de diseño OO Gang of Four (GoF)
Lenguaje de Programación II Manejo de Paquetes Corporación Universitaria del Caribe CECAR.
Unit Testing with Mock Objects Angel Núñez / snahider.blogspot.com.
Java. Objeto Es la instancia de una clase. Cada objeto se crea utilizando la palabra reservada new. Un objeto es conocido como una instancia. Ejemplo.
SISTEMAS DE LA INFORMACIÓN
Realizado por: Bertha Palomeque A. Rodrigo Barzola J. Sensor de Temperatura utilizando el Starter Kit Javelin Stamp.
El patrón de diseño Proxy Raúl Heras Alberto Blasco José Manuel Arévalo.
Java Mayra M. Méndez Anota.
Patrón Observador Un patrón de diseño es una descripción de clases y objetos comunicándose entre si adaptada para resolver un problema de diseño general.
UOC José Mª Casablanca González. Índice Introducción Objetivos generales y específicos Problema y posibles soluciones Características y definición.
Sincronización de Objectos Compartidos usando MatchMaker a través de Web Services Thomas Pieper DCC, Universidad de Chile.
Invocación de Métodos Remotos RMI: Remote Method Invocation
Programación Orientada a Aspectos (POA)
Patrones Creacionales
Diplomado Desarrollo de Aplicaciones en Internet
SPRING MVC.
INTRODUCCIÓN A LA PROGRAMACIÓN ORIENTADA A OBJETOS Encapsulamiento.
Programación Orientada a Objetos usando CONSTRUCTORES DESTRUCTORES.
INTRODUCCIÓN A LA PROGRAMACIÓN ORIENTADA A OBJETOS Encapsulamiento.
RMI Remote Method Invocation 2da. Clase del 19 de Junio
Patrones de diseño DECORATOR Mario Rodríguez Martín
Enterprise Java Beans. EJBs Beans gestionados por un contenedor del servidor de aplicaciones para gestionar el acceso a recursos (bases de datos, colas.
SUMA DE DOS NÚMEROS Pseudocódigo, diagrama de flujo y programa java.
Hola mundo. 2 En Java para indicar el inicio y fin de un bloque de instrucciones utiliza las llaves { } es decir: { Inicio de instrucciones para la clase.
Spring Framework. Contenedor ligero de aplicaciones
César Estéban Castañeda Luis Andrés Almanza
M.C. Juan Carlos Olivares Rojas
Andrés Harker Gutiérrez Director: Cesar Julio Bustacara Medina MSc. Asesor: Oscar Xavier Chavarro MSc. Arquitectura de un módulo I/O para objetos 3D Pontificia.
Metodología de Programación Ayudantía 5 lelagos.ublog.cl 2009.
Patrón Iterator Santiago García Sánchez Rebeca Marcos Salcedo Mª Cristina Zapatero Gironda.
Herencia. Introducción La idea básica es poder crear clases basadas en clases ya existentes. Cuando heredamos de una clase existente, estamos re-usando.
PROGRAMACION ORIENTADA A OBJETOS POR OVER YESID BARRERA FERNANDEZ.
Presentado por: PABLO ANDRES DIAZ SAIN HASSAM CAICEDO
Detalles Generales sobre Java
LE, EI, Profesor Ramón Castro Liceaga UNIVERSIDAD LATINA (UNILA) LENGUAJES DE PROGRAMACIÓN PARA EL DESARROLLO DE INTERFACES.
© Softtek Internal. Introducción a Spring Sesión 1: Introducción y teoría Juan Irungaray
:: Prof. Yeniffer Peña Programación I Programación Orientada a Objetos Presentación.
Luis Ponce Cabello.  Primera Parte : JSF  Segunda Parte : Facelets  Tercera Parte : Icefaces.
Abstracción El concepto de abstracción es esencial en ciencias de la computación. Un programa es en sí mismo una abstracción, un modelo de la resolución.
Manejá tus tiempos Facultad de Ingeniería de la Universidad de Buenos Aires – Marzo 2012.
Patrones de Diseño Agustín J. González ElO329.
Encapsulamiento Miguel Ángel Rojas Aguilar Esthela Carmina Carranza Cabrera.
Clases “ Es una Abstracción de un elemento del mundo real ”
Un paseo por las nuevas funciones. Patrones de Diseño Por si no ha quedado claro, los Patrones de Diseño, son el esqueleto de las soluciones a problemas.
TALLER POO JAVA ERNESTO GOMEZ VARGAS. OBJETIVOS REALIZAR UNA APLICACIÓN SENCILLA DE P.O.O FAMILIARIZARSE CON LA HERRAMETA NETBEANS APLICAR EL CONCEPTO.
INTRODUCCIÓN A LA PROGRAMACIÓN ORIENTADA A OBJETOS GUI.
Herencias Conceptos básicos i
Factorías e Iterables Introducción del concepto de patrón de diseño Construcción de tipos para recorridos con for extendido Fundamentos de Programación.
Estructuras de control selectivas Fundamentos de Programación Departamento de Lenguajes y Sistemas Informáticos Versión Práctica 3.
Fundamentos de Programación Departamento de Lenguajes y Sistemas Informáticos Práctica 4 Versión Diseño de tipos Igualdad, representación, código,
Softlogia S.R.L. Formación de Recursos Humanos Spring Instructor: Martin R. Baspineiro.
Programación I Clases. Paradigma POO La programación Orientada a objetos (POO) es una forma programar, más cercana a como expresaríamos las cosas en la.
:: Prof. Yeniffer Peña Programación I Programación Orientada a Objetos Presentación.
ESTRUCTURA DE UN PROGRAMA EN
INTRODUCCIÓN A LA PROGRAMACIÓN ORIENTADA A OBJETOS Herencia.
Spring Framework.
Transcripción de la presentación:

Guice Java Injection Framework http://code.google.com/p/google-guice/

Inversion of Control IoC es un patron de disenno en el que se basa otro patron de disenno: “Dependency of Injection” que es el que implementa GoogleGuice. Inversión de control (Inversion of Control en inglés, IoC) es un concepto junto a unas técnicas de programación en las que el flujo de ejecución de un programa se invierte respecto a los métodos de programación tradicionales, en los que la interacción se expresa de forma imperativa haciendo llamadas a procedimientos (procedure calls) o funciones. Tradicionalmente el programador especifica la secuencia de decisiones y procedimientos que pueden darse durante el ciclo de vida de un programa mediante llamadas a funciones. En su lugar, en la inversión de control se especifican respuestas deseadas a sucesos o solicitudes de datos concretas, dejando que algún tipo de entidad o arquitectura externa lleve a cabo las acciones de control que se requieran en el orden necesario y para el conjunto de sucesos que tengan que ocurrir.

Dependency Injection Inyección de Dependencias (en inglés Dependency Injection, DI) es un patrón de arquitectura orientado a objetos, en el que se inyectan objetos a una clase en lugar de ser la propia clase quien cree el objeto.

Java Annotations Desde el JDK 5 (Tiger) se dispone de las Java Annotations ( anotaciones ) que le permiten al programador agregar metadatos a el codigo fuente, metadatos que pueden ser explotados por otros programas o frameworks. JUnit JPA Hibernate

Google Guice Es un Framework para “Dependency Injection” para Java 5 o superior. Utiliza Java Annotations. Guice elimina la necesidad de Factories y el uso de new en el codigo de Java. Se puede pensar el @Inject como un nuevo new. Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

Injection Process First, create an instance of your module and pass it to Guice.createInjector(). Guice creates a Binder and passes it to your module. Your module uses the binder to define bindings. Based on the bindings you specified, Guice creates an Injector and returns it to you. You use the injector to inject an object.

Service.java public interface Service { public void go(); } Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

ServiceImpl.java @Singleton public class ServiceImpl implements Service { public void go() { System.out.println("Este es un servicio..."); } Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

ServiceImpl2.java @Singleton public class ServiceImpl2 implements Service { public void go() { System.out.println("Este es otro servicio..."); } Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

MyModule.java public class MyModule implements Module { public void configure(Binder binder) { binder.bind(Service.class).to(ServiceImpl.class).in(Scopes.SINGLETON); } Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

Client.java public class Client { private final Service service; @Inject public Client(Service service){ this.service = service; } public void go(){ service.go(); Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

Main.java public static void main(String[] args) { Injector injector = Guice.createInjector(new MyModule()); Client client = injector.getInstance(Client.class); client.go(); } Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

Funcionalidades Inject: Strings. Metodos. Clases. Atributos. Usa la funcionalidad de Annotations. Extensible mediante annotations. Facilidad para la implementacions de Tests, Junit, Mocks, Stubs. Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

Otros Frameworks Spring http://www.springframework.org/ HiveMind http://hivemind.apache.org/ PicoContainer http://www.picocontainer.org/ Etc, etc. Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

Bob Lee Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts. Guice embraces Java's type safe nature, especially when it comes to features introduced in Java 5 such as generics and annotations. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice. Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework. Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.