SlideShare une entreprise Scribd logo
1  sur  15
Paradigmas de Linguagens de Programação Paradigma Orientado a Aspectos Aula #9 (CopyLeft)2009 - Ismar Frango ismar@mackenzie.br
AOP A Programação Orientada por Aspectos (AOP), proposta por Gregor Kiczales em 1997 tem por objetivo modularizar decisões de projeto que não podem ser adequadamente definidas por meio da POO. Na AOP, requisitos de sistemas são modelados por meio de  classes , que implementam os objetos do mundo real,  e  aspectos , que implementam requisitos transversais do sistema
Benefícios da AOP ,[object Object],[object Object],[object Object],“ Programs that clearly express the design structure they implement are easier to maintain” Gregor Kiczales
Exemplo: Hello, world  (que novidade!)   class  Hello{ public static void  main(String args[ ]) {  System.out.println("Início da Monitoração");  System.out.println("Hello World!");  System.out.println("Final da monitoração"); } } Tangled code
Exemplo: Hello, world  (novidade!) aspect  Monitor{ pointcut  impressao(): execution  ( public static void  Hello.main(String [])); before (): impressao () { System.out.println("Inicio da impressao"); } after (): impressao () { System.out.println("Final da impressao"); }  } class  Hello{ public static void  main(String args[ ]){ System.out.println("Hello World!"); } } Hello.java Monitor.aj
Weaving Hello.java Monitor.aj ajc Hello.class Monitor.class
Exemplo: Logger OO Exemplo de Tirelo et al. – JAI2004
Exemplo: Logger AOP public aspect  LoggingAspect { pointcut  publicMethods():  execution  (public  * * (..)); pointcut  logObjectCalls() :  execution ( *  Logger. * (..)); pointcut  loggableCalls() : publicMethods()  && !  logObjectCalls(); before (): loggableCalls() { Logger.logEntry( thisJoinPoint.getSignature().toString()); } after () returning: loggableCalls() { Logger.logNormalExit( thisJoinPoint.getSignature().toString()); }
Exemplo: Disque-saúde com RMI Exemplo de Sérgio Soares e Paulo Borba - UFPE
Implementação com RMI public class Complaint  implements java.io.Serializable  { private String description; private Person complainer; ...  public Complaint(String description, Person complainer, ...) {  ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } ... } public class HealthWatcherFacade  implements IFacade  { public void update(Complaint complaint)  throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... }  public static void main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade);  java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {... } catch (MalformedURLException rmiEx) { ...} catch(Exception ex) {... } } } public class ServletUpdateComplaintData extends HttpServlet { private  IFacade  facade; public void init(ServletConfig config) throws ServletException { try { facade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... facade.update(complaint); ... } ... } public class Person  implements java.io.Serializable  { private String nome; ... public Person(String nome, …) { this.nome   = nome; … } public String getNome() { return nome; } … } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . .  }
Visão geral do código OO public class Complaint  implements java.io.Serializable  { private String description; private Person complainer; ...  public Complaint(String description, Person complainer, ...) {  ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } ... } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . .  } public class HealthWatcherFacade  implements IFacade  { public void update(Complaint complaint)  throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... }  public static void main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade);  java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {... } catch (MalformedURLException rmiEx) { ...} catch(Exception ex) {... } } } public class Person  implements java.io.Serializable  { private String nome; ... public Person(String nome, …) { this.nome   = nome; … } public String getNome() { return nome; } … } public class ServletUpdateComplaintData extends HttpServlet { private  IFacade  facade; public void init(ServletConfig config) throws ServletException { try { facade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... facade.update(complaint); ... } ... } Código RMI
Problemas na implementação OO ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Disque-saúde com AOP
Implementação em AspectJ public class Complaint { private String description; private Person complainer; ...  public Complaint(String description, Person complainer, ...) {  ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } } public class ServletUpdateComplaintData extends HttpServlet { private HealthWatcherFacade facade; public void init(ServletConfig config) throws ServletException { try { facade = HealthWatcherFacade.getInstance(); } catch (Exception ex) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... } ... } public class Person { private String nome; ... public Person(String nome, ...) { this.matricula = matricula; ... } public String getNome() { return nome; } ... } public class HealthWatcherFacade { public void update(Complaint complaint)  throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... } } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . .  } aspect DistributionAspect { declare parents: HealthWatcherFacade implements IFacade; declare parents: Complaint || Person implements java.io.Serializable; public static void HealthWatcherFacade.main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade);  java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {...} catch (MalformedURLException rmiEx) {...} catch(Exception ex) {...} }  //segue... private IFacade remoteFacade; pointcut facadeMethodsExecution():  within(HttpServlet+) &&  execution(* HealthWatcherFacade.*(..)) && this(HealthWatcherFacade);  before(): facadeMethodsExecution()  { prepareFacade();} private synchronized void prepareFacade() { if (healthWatcher == null) { try {  remoteFacade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } void around(Complaint complaint) throws TransactionException, RepositoryException ObjectNotFoundException,ObjectNotValidException: facadeRemoteExecutions()  && args(complaint)  && call(void update(Complaint)) { try {  remoteFacade.update(complaint); } catch (RemoteException rmiEx) {...} } }
Disque-Saúde em AOP : Visão geral public class Complaint { private String description; private Person complainer; ...  public Complaint(String description, Person complainer, ...) {  ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . .  } public class HealthWatcherFacade { public void update(Complaint complaint)  throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... } } public class Person { private String nome; ... public Person(String nome, ...) { this.matricula = matricula; ... } public String getNome() { return nome; } ... } public class ServletUpdateComplaintData extends HttpServlet { private HealthWatcherFacade facade; public void init(ServletConfig config) throws ServletException { try { facade = HealthWatcherFacade.getInstance(); } catch (Exception ex) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... } ... } aspect DistributionAspect { declare parents: HealthWatcherFacade implements IFacade; declare parents: Complaint || Person implements java.io.Serializable; public static void HealthWatcherFacade.main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade);  java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {...} catch (MalformedURLException rmiEx) {...} catch(Exception ex) {...} }  private IFacade remoteFacade; pointcut facadeMethodsExecution():  within(HttpServlet+) &&  execution(* HealthWatcherFacade.*(..)) && this(HealthWatcherFacade);  before(): facadeMethodsExecution()  {  prepareFacade();} private synchronized void prepareFacade() { if (healthWatcher == null) { try {  remoteFacade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } void around(Complaint complaint) throws TransactionException, RepositoryExceptio n ObjectNotFoundException,ObjectNotValidException: facadeRemoteExecutions()  & &  args(complaint)  && call(void update(Complaint)) { try {  remoteFacade.update(complaint); } catch (RemoteException rmiEx) {...} } } Sistema local Aspectos de  Distribuição para RMI

Contenu connexe

Tendances

ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуdelimitry
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptSeok-joon Yun
 
Exception handling
Exception handlingException handling
Exception handlingKapish Joshi
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujeigersonjack
 
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++Seok-joon Yun
 
Pointcuts and Analysis
Pointcuts and AnalysisPointcuts and Analysis
Pointcuts and AnalysisWiwat Ruengmee
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMMario Fusco
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answerssheibansari
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumlercorehard_by
 
Presentacion clean code
Presentacion clean codePresentacion clean code
Presentacion clean codeIBM
 

Tendances (20)

ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
Exception handling
Exception handlingException handling
Exception handling
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
 
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++
 
Ocl 09
Ocl 09Ocl 09
Ocl 09
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Java programs
Java programsJava programs
Java programs
 
Pointcuts and Analysis
Pointcuts and AnalysisPointcuts and Analysis
Pointcuts and Analysis
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
 
Core java
Core javaCore java
Core java
 
Oop objects_classes
Oop objects_classesOop objects_classes
Oop objects_classes
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answers
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
report
reportreport
report
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumler
 
Modeling FSMs
Modeling FSMsModeling FSMs
Modeling FSMs
 
Presentacion clean code
Presentacion clean codePresentacion clean code
Presentacion clean code
 

En vedette

Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8Ismar Silveira
 
Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10Ismar Silveira
 
Engenharia de Software - Aula1
Engenharia de Software - Aula1Engenharia de Software - Aula1
Engenharia de Software - Aula1Ismar Silveira
 
Paradigmas De Linguagem De Programação.
Paradigmas De Linguagem De Programação.Paradigmas De Linguagem De Programação.
Paradigmas De Linguagem De Programação.Valmon Gaudencio
 
MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013Ismar Silveira
 
Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2Ismar Silveira
 
#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - Methodologies#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - MethodologiesIsmar Silveira
 
Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009Ismar Silveira
 
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional DesignInteraccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional DesignIsmar Silveira
 
Mini-curso RubyOnRails CESOL
Mini-curso RubyOnRails CESOLMini-curso RubyOnRails CESOL
Mini-curso RubyOnRails CESOLtarginosilveira
 
E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11Ismar Silveira
 
Charla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinalCharla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinalIsmar Silveira
 
Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7Ismar Silveira
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Ismar Silveira
 
Lua para Jogos
Lua para JogosLua para Jogos
Lua para JogosDavid Ruiz
 

En vedette (20)

Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8
 
Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10
 
Engenharia de Software - Aula1
Engenharia de Software - Aula1Engenharia de Software - Aula1
Engenharia de Software - Aula1
 
Paradigmas De Linguagem De Programação.
Paradigmas De Linguagem De Programação.Paradigmas De Linguagem De Programação.
Paradigmas De Linguagem De Programação.
 
MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013
 
Ismar webinar-udelar
Ismar webinar-udelarIsmar webinar-udelar
Ismar webinar-udelar
 
Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2
 
#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - Methodologies#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - Methodologies
 
Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009
 
wei2010
wei2010wei2010
wei2010
 
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional DesignInteraccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional Design
 
Mini-curso RubyOnRails CESOL
Mini-curso RubyOnRails CESOLMini-curso RubyOnRails CESOL
Mini-curso RubyOnRails CESOL
 
Sinatra - Primeiros Passos
Sinatra - Primeiros PassosSinatra - Primeiros Passos
Sinatra - Primeiros Passos
 
Fundcompsis 1.1
Fundcompsis 1.1Fundcompsis 1.1
Fundcompsis 1.1
 
E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11
 
Paradigmas do Ruby
Paradigmas do RubyParadigmas do Ruby
Paradigmas do Ruby
 
Charla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinalCharla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinal
 
Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5
 
Lua para Jogos
Lua para JogosLua para Jogos
Lua para Jogos
 

Similaire à Paradigmas de linguagens de programacao - aula#9

比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
JDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
JDD 2016 - Sebastian Malaca - You Dont Need Unit TestsJDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
JDD 2016 - Sebastian Malaca - You Dont Need Unit TestsPROIDEA
 
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"IT Event
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agentsRafael Winterhalter
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257newegg
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Yann-Gaël Guéhéneuc
 
Android Architecture Components
Android Architecture ComponentsAndroid Architecture Components
Android Architecture ComponentsBurhanuddinRashid
 
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
 

Similaire à Paradigmas de linguagens de programacao - aula#9 (20)

比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Java rmi
Java rmiJava rmi
Java rmi
 
Introduction to-java
Introduction to-javaIntroduction to-java
Introduction to-java
 
JDK Power Tools
JDK Power ToolsJDK Power Tools
JDK Power Tools
 
JDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
JDD 2016 - Sebastian Malaca - You Dont Need Unit TestsJDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
JDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
 
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
 
IKH331-07-java-rmi
IKH331-07-java-rmiIKH331-07-java-rmi
IKH331-07-java-rmi
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
 
Android Architecture Components
Android Architecture ComponentsAndroid Architecture Components
Android Architecture Components
 
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
 

Plus de Ismar Silveira

REA - Recursos Educacionais Abertos
REA - Recursos Educacionais AbertosREA - Recursos Educacionais Abertos
REA - Recursos Educacionais AbertosIsmar Silveira
 
Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informação - Aula #7
Fundamentos de Sistemas de Informação - Aula #7Fundamentos de Sistemas de Informação - Aula #7
Fundamentos de Sistemas de Informação - Aula #7Ismar Silveira
 
Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009
Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009
Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula 6
Fundamentos de Sistemas de Informacao - Aula 6Fundamentos de Sistemas de Informacao - Aula 6
Fundamentos de Sistemas de Informacao - Aula 6Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)
Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)
Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)Ismar Silveira
 

Plus de Ismar Silveira (15)

REA - Recursos Educacionais Abertos
REA - Recursos Educacionais AbertosREA - Recursos Educacionais Abertos
REA - Recursos Educacionais Abertos
 
Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16
 
Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2
 
Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13
 
Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2
 
Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2
 
Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
 
Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2
 
Fundamentos de Sistemas de Informação - Aula #7
Fundamentos de Sistemas de Informação - Aula #7Fundamentos de Sistemas de Informação - Aula #7
Fundamentos de Sistemas de Informação - Aula #7
 
Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6
 
Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009
Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009
Fundamentos de Sistemas de Informacao - Aula #7 - 2sem2009
 
Fundamentos de Sistemas de Informacao - Aula 6
Fundamentos de Sistemas de Informacao - Aula 6Fundamentos de Sistemas de Informacao - Aula 6
Fundamentos de Sistemas de Informacao - Aula 6
 
Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)
Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)
Fundamentos de Sistemas de Informacao - Aula #5 (2009_2)
 

Dernier

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 

Dernier (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

Paradigmas de linguagens de programacao - aula#9

  • 1. Paradigmas de Linguagens de Programação Paradigma Orientado a Aspectos Aula #9 (CopyLeft)2009 - Ismar Frango ismar@mackenzie.br
  • 2. AOP A Programação Orientada por Aspectos (AOP), proposta por Gregor Kiczales em 1997 tem por objetivo modularizar decisões de projeto que não podem ser adequadamente definidas por meio da POO. Na AOP, requisitos de sistemas são modelados por meio de classes , que implementam os objetos do mundo real, e aspectos , que implementam requisitos transversais do sistema
  • 3.
  • 4. Exemplo: Hello, world (que novidade!) class Hello{ public static void main(String args[ ]) { System.out.println("Início da Monitoração"); System.out.println("Hello World!"); System.out.println("Final da monitoração"); } } Tangled code
  • 5. Exemplo: Hello, world (novidade!) aspect Monitor{ pointcut impressao(): execution ( public static void Hello.main(String [])); before (): impressao () { System.out.println("Inicio da impressao"); } after (): impressao () { System.out.println("Final da impressao"); } } class Hello{ public static void main(String args[ ]){ System.out.println("Hello World!"); } } Hello.java Monitor.aj
  • 6. Weaving Hello.java Monitor.aj ajc Hello.class Monitor.class
  • 7. Exemplo: Logger OO Exemplo de Tirelo et al. – JAI2004
  • 8. Exemplo: Logger AOP public aspect LoggingAspect { pointcut publicMethods(): execution (public * * (..)); pointcut logObjectCalls() : execution ( * Logger. * (..)); pointcut loggableCalls() : publicMethods() && ! logObjectCalls(); before (): loggableCalls() { Logger.logEntry( thisJoinPoint.getSignature().toString()); } after () returning: loggableCalls() { Logger.logNormalExit( thisJoinPoint.getSignature().toString()); }
  • 9. Exemplo: Disque-saúde com RMI Exemplo de Sérgio Soares e Paulo Borba - UFPE
  • 10. Implementação com RMI public class Complaint implements java.io.Serializable { private String description; private Person complainer; ... public Complaint(String description, Person complainer, ...) { ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } ... } public class HealthWatcherFacade implements IFacade { public void update(Complaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... } public static void main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade); java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {... } catch (MalformedURLException rmiEx) { ...} catch(Exception ex) {... } } } public class ServletUpdateComplaintData extends HttpServlet { private IFacade facade; public void init(ServletConfig config) throws ServletException { try { facade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... facade.update(complaint); ... } ... } public class Person implements java.io.Serializable { private String nome; ... public Person(String nome, …) { this.nome = nome; … } public String getNome() { return nome; } … } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . . }
  • 11. Visão geral do código OO public class Complaint implements java.io.Serializable { private String description; private Person complainer; ... public Complaint(String description, Person complainer, ...) { ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } ... } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . . } public class HealthWatcherFacade implements IFacade { public void update(Complaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... } public static void main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade); java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {... } catch (MalformedURLException rmiEx) { ...} catch(Exception ex) {... } } } public class Person implements java.io.Serializable { private String nome; ... public Person(String nome, …) { this.nome = nome; … } public String getNome() { return nome; } … } public class ServletUpdateComplaintData extends HttpServlet { private IFacade facade; public void init(ServletConfig config) throws ServletException { try { facade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... facade.update(complaint); ... } ... } Código RMI
  • 12.
  • 14. Implementação em AspectJ public class Complaint { private String description; private Person complainer; ... public Complaint(String description, Person complainer, ...) { ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } } public class ServletUpdateComplaintData extends HttpServlet { private HealthWatcherFacade facade; public void init(ServletConfig config) throws ServletException { try { facade = HealthWatcherFacade.getInstance(); } catch (Exception ex) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... } ... } public class Person { private String nome; ... public Person(String nome, ...) { this.matricula = matricula; ... } public String getNome() { return nome; } ... } public class HealthWatcherFacade { public void update(Complaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... } } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . . } aspect DistributionAspect { declare parents: HealthWatcherFacade implements IFacade; declare parents: Complaint || Person implements java.io.Serializable; public static void HealthWatcherFacade.main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade); java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {...} catch (MalformedURLException rmiEx) {...} catch(Exception ex) {...} } //segue... private IFacade remoteFacade; pointcut facadeMethodsExecution(): within(HttpServlet+) && execution(* HealthWatcherFacade.*(..)) && this(HealthWatcherFacade); before(): facadeMethodsExecution() { prepareFacade();} private synchronized void prepareFacade() { if (healthWatcher == null) { try { remoteFacade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } void around(Complaint complaint) throws TransactionException, RepositoryException ObjectNotFoundException,ObjectNotValidException: facadeRemoteExecutions() && args(complaint) && call(void update(Complaint)) { try { remoteFacade.update(complaint); } catch (RemoteException rmiEx) {...} } }
  • 15. Disque-Saúde em AOP : Visão geral public class Complaint { private String description; private Person complainer; ... public Complaint(String description, Person complainer, ...) { ... } public String getDescription() { return this.description; } public Person getComplainer() { return this.complainer; } public void setDescription(String desc) { this.description = desc; } public void setComplainer(Person complainer) { this.complainer = complainer; } } public interface IFacade extends java.rmi.Remote { public void updateComplaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException, RemoteException; . . . } public class HealthWatcherFacade { public void update(Complaint complaint) throws TransactionException, RepositoryException, ObjectNotFoundException, ObjectNotValidException { ... } } public class Person { private String nome; ... public Person(String nome, ...) { this.matricula = matricula; ... } public String getNome() { return nome; } ... } public class ServletUpdateComplaintData extends HttpServlet { private HealthWatcherFacade facade; public void init(ServletConfig config) throws ServletException { try { facade = HealthWatcherFacade.getInstance(); } catch (Exception ex) {...} } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... } ... } aspect DistributionAspect { declare parents: HealthWatcherFacade implements IFacade; declare parents: Complaint || Person implements java.io.Serializable; public static void HealthWatcherFacade.main(String[] args) { try { HealthWatcherFacade facade = HealthWatcherFacade.getInstance(); System.out.println("Creating RMI server..."); UnicastRemoteObject.exportObject(facade); java.rmi.Naming.rebind("/HealthWatcher"); System.out.println("Server created and ready."); } catch (RemoteException rmiEx) {...} catch (MalformedURLException rmiEx) {...} catch(Exception ex) {...} } private IFacade remoteFacade; pointcut facadeMethodsExecution(): within(HttpServlet+) && execution(* HealthWatcherFacade.*(..)) && this(HealthWatcherFacade); before(): facadeMethodsExecution() { prepareFacade();} private synchronized void prepareFacade() { if (healthWatcher == null) { try { remoteFacade = (IFacade) java.rmi.Naming.lookup("//HealthWatcher"); } catch (java.rmi.RemoteException rmiEx) {...} catch (java.rmi.NotBoundException rmiEx) {...} catch (java.net.MalformedURLException rmiEx) {...} } void around(Complaint complaint) throws TransactionException, RepositoryExceptio n ObjectNotFoundException,ObjectNotValidException: facadeRemoteExecutions() & & args(complaint) && call(void update(Complaint)) { try { remoteFacade.update(complaint); } catch (RemoteException rmiEx) {...} } } Sistema local Aspectos de Distribuição para RMI