SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Spring framework
                     Motto: Musíte rozbít vejce když chcete udělat omeletu




                Spring framework training materials by Roman Pichlík is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Sunday 13 May 2012                                                                                                                                       1
Java EE
                     Kurz jak používat Java EE a nezbláznit se z toho




Sunday 13 May 2012                                                      2
Co Spring nabízí
                     • EJB
                     • JMS
                     • JNDI
                     • JCA
                     • Remoting
                     • Napojení na služby

Sunday 13 May 2012                              3
EJB

                     • Zjednoduššené vytváření EJB
                      • SLSB, SLFB, MDB
                        • AbstractStatelessSessionBean
                        • AbstractStatefulSessionBean
                        • AbstractJmsMessageDrivenBean


Sunday 13 May 2012                                       4
Jak na vlastní beanu




Sunday 13 May 2012                          5
Vlastní business rozhraní


  public interface ReservationService {

  	
  	    public boolean reserveBook(Long bookId, Date from, Date to, User user);	
  	
  }




Sunday 13 May 2012                                                                6
Implementace

  @Service(value="reservationService")
  public class ReservationServiceImpl implements ReservationService {
  	
  	 @Autowired
  	 private BookService bookService;

  	    public boolean reserveBook(Long bookId, Date from, Date to, User user) {
  	    	 Book book = bookService.getBook(bookId);
  	    	 if(book == null) {
  	    	 	 throw new RuntimeException("Sorry, the book doesn't exist");
  	    	 }
  	    	 return true;
  	    }
  }




Sunday 13 May 2012                                                                7

Spring bean, mozno testovat
EJB facade




Sunday 13 May 2012                8
Vlastní fasáda
   Předek, zaručující Spring                            EJB má stejné rozhraní
           podport                                        jako Spring beana
  public class ReservationServiceEJBFacade extends
                               AbstractStatelessSessionBean implements ReservationService {
  	
  	 private static final long serialVersionUID = 1L;

  	    private ReservationService reservationService;                       Získání spring
  	    @Override                                                                beany
  	    protected void onEjbCreate() throws CreateException {
  	    	 reservationService = getBeanFactory().getBean("reservationService");	
  	    }

  	    public boolean reserveBook(Long bookId, Date from, Date to, User user) {	 	
  	    	 return reservationService.reserveBook(bookId, from, to, user);
  	    }	
  }




Sunday 13 May 2012                                                                            9

-stejny business interface nam umuznuje delegovat volani
Home a Local Interface
  import javax.ejb.CreateException;
  import javax.ejb.EJBLocalHome;

  public interface ReservationServiceHome extends EJBLocalHome {

  	    public ReservationServiceLocal create() throws CreateException;
  }




  import javax.ejb.EJBLocalObject;

  import cz.sweb.pichlik.ReservationService;

  public interface ReservationServiceLocal extends EJBLocalObject, ReservationService   {
  }




Sunday 13 May 2012                                                                          10
Jak se Spring startuje
  <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/
  XMLSchema-instance"
  	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-
  jar_2_1.xsd"
  	 version="2.1" id="ejb-jar_ID">
  	 <description>Book service EJB facade</description>
  	 <display-name>ejbs</display-name>                Určuje kontext, který se bude
  	 <enterprise-beans>                                         bootovat
  	 	 <session>
  	 	 	 <description>Book service EJB facade</description>
  	 	 	 <ejb-name>ReservationServiceEJBFacade</ejb-name>
  	 	 	 <local-home>cz.sweb.pichlik.ejb.ReservationServiceHome</local-home>
  	 	 	 <local>cz.sweb.pichlik.ejb.ReservationServiceLocal</local>
  	 	 	 <ejb-class>cz.sweb.pichlik.ejb.ReservationServiceEJBFacade</ejb-class>
  	 	 	 <session-type>Stateless</session-type>
  	 	 	 <transaction-type>Container</transaction-type>	    	 	
  	 	 	 <env-entry>
  	 	 	 	 <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
  	 	 	 	 <env-entry-type>java.lang.String</env-entry-type>
  	 	 	 	 <env-entry-value>classpath*:META-INF/businessContext.xml</env-entry-value>
  	 	 	 </env-entry>
  	 	 </session>
Sunday 13 May 2012                                                                         11

- kazda instance beany si vytvari vlastni kontext.
JNDI




Sunday 13 May 2012          12
Lookup generic, local&remote
  <jee:jndi-lookup id="simple"
               jndi-name="jdbc/MyDataSource"
               cache="true"
               resource-ref="true"
               lookup-on-startup="false"
               expected-type=""
               proxy-interface="com.myapp.Foo"/>

  <jee:local-slsb id="complexLocalEjb"
      jndi-name="ejb/RentalServiceBean"
      business-interface="com.foo.service.RentalService"
      cache-home="true"
      lookup-home-on-startup="true"
      resource-ref="true">

  <jee:remote-slsb id="complexRemoteEjb"
      jndi-name="ejb/MyRemoteBean"
      business-interface="com.foo.service.RentalService"
      cache-home="true"
      lookup-home-on-startup="true"
      resource-ref="true"
      home-interface="com.foo.service.RentalService"
      refresh-home-on-connect-failure="true">
Sunday 13 May 2012                                         13
Remoting




Sunday 13 May 2012              14
Podporované protokoly

                     • Client/Server
                      • RMI
                      • Hessian/Burlap
                      • HttpInvoker
                      • JAX-RPC, JAX-WS


Sunday 13 May 2012                           15
HttpInvoker service
     <servlet>
                                                                        web.xml
       <servlet-name>remoting</servlet-name>
       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
     </servlet>

     <servlet-mapping>
       <servlet-name>remoting</servlet-name>
       <url-pattern>/remoting/*</url-pattern>
     </servlet-mapping>




                                        remoting-servlet.xml

  <bean name="/ReservationService"
  class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    	 <property name="service" ref="web.reservationService"/>
       	 <property name="serviceInterface" value="cz.sweb.pichlik.ReservationService"/>
  </bean>



Sunday 13 May 2012                                                                        16
HttpInvoker client


  <bean id="client.reservationService"
  class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
     <property name="serviceUrl" value="http://localhost:8080/servlet/remoting/ReservationService"/>
     <property name="serviceInterface" value="cz.sweb.pichlik.ReservationService"/>
  </bean>




Sunday 13 May 2012                                                                                     17
JMS




Sunday 13 May 2012         18
Podporované typy


                     • MDB
                        • AbstractJmsMessageDrivenBean
                     • Spring MDB
                     • Client


Sunday 13 May 2012                                       19
Mail




Sunday 13 May 2012          20
import org.springframework.mail.SimpleMailMessage;
 import org.springframework.mail.MailSender;

 @Service
 public class EmailExample {

     @Autowired
     private MailSender mailSender;
     @Autowired
     private SimpleMailMessage templateMessage;

     public void sayHello() {
         SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
         msg.setTo(order.getCustomer().getEmailAddress());
         msg.setText(“HelloWorld”);
         this.mailSender.send(msg);
     }
 }




 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
   <property name="host" value="mail.mycompany.com"/>
 </bean>

 <!-- this is a template message that we can pre-load with default state -->
 <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage">
   <property name="from" value="customerservice@mycompany.com"/>
   <property name="subject" value="Your order"/>
 </bean>




Sunday 13 May 2012                                                                     21
org.springframework.mail.javamail.MimeMessageHelp
er

Mais conteúdo relacionado

Semelhante a Spring J2EE

J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical Overview
Svetlin Nakov
 
Java script performance tips
Java script performance tipsJava script performance tips
Java script performance tips
Shakti Shrestha
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)
vikram singh
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)
vikram singh
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
vikram singh
 
Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2
vikram singh
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)
vikram singh
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
vikram singh
 

Semelhante a Spring J2EE (20)

GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012
 
Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
 
J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical Overview
 
Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee Overview
 
14 mvc
14 mvc14 mvc
14 mvc
 
EJB 3.1 and GlassFish v3 Prelude
EJB 3.1 and GlassFish v3 PreludeEJB 3.1 and GlassFish v3 Prelude
EJB 3.1 and GlassFish v3 Prelude
 
Java script performance tips
Java script performance tipsJava script performance tips
Java script performance tips
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration Backend
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)
 
10 J D B C
10  J D B C10  J D B C
10 J D B C
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
 
Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2
 
Spring database - part2
Spring database -  part2Spring database -  part2
Spring database - part2
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
 

Mais de Roman Pichlík (9)

Spring ioc-advanced
Spring ioc-advancedSpring ioc-advanced
Spring ioc-advanced
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Spring dao
Spring daoSpring dao
Spring dao
 
Spring aop
Spring aopSpring aop
Spring aop
 
Spring Web Services
Spring Web ServicesSpring Web Services
Spring Web Services
 
MongoDB for Java Developers
MongoDB for Java DevelopersMongoDB for Java Developers
MongoDB for Java Developers
 
Nosql from java developer pov
Nosql from java developer povNosql from java developer pov
Nosql from java developer pov
 
Spring framework - J2EE S Lidskou Tvari
Spring framework - J2EE S Lidskou TvariSpring framework - J2EE S Lidskou Tvari
Spring framework - J2EE S Lidskou Tvari
 
Dependency Injection Frameworky
Dependency Injection FrameworkyDependency Injection Frameworky
Dependency Injection Frameworky
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Spring J2EE

  • 1. Spring framework Motto: Musíte rozbít vejce když chcete udělat omeletu Spring framework training materials by Roman Pichlík is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Sunday 13 May 2012 1
  • 2. Java EE Kurz jak používat Java EE a nezbláznit se z toho Sunday 13 May 2012 2
  • 3. Co Spring nabízí • EJB • JMS • JNDI • JCA • Remoting • Napojení na služby Sunday 13 May 2012 3
  • 4. EJB • Zjednoduššené vytváření EJB • SLSB, SLFB, MDB • AbstractStatelessSessionBean • AbstractStatefulSessionBean • AbstractJmsMessageDrivenBean Sunday 13 May 2012 4
  • 5. Jak na vlastní beanu Sunday 13 May 2012 5
  • 6. Vlastní business rozhraní public interface ReservationService { public boolean reserveBook(Long bookId, Date from, Date to, User user); } Sunday 13 May 2012 6
  • 7. Implementace @Service(value="reservationService") public class ReservationServiceImpl implements ReservationService { @Autowired private BookService bookService; public boolean reserveBook(Long bookId, Date from, Date to, User user) { Book book = bookService.getBook(bookId); if(book == null) { throw new RuntimeException("Sorry, the book doesn't exist"); } return true; } } Sunday 13 May 2012 7 Spring bean, mozno testovat
  • 8. EJB facade Sunday 13 May 2012 8
  • 9. Vlastní fasáda Předek, zaručující Spring EJB má stejné rozhraní podport jako Spring beana public class ReservationServiceEJBFacade extends AbstractStatelessSessionBean implements ReservationService { private static final long serialVersionUID = 1L; private ReservationService reservationService; Získání spring @Override beany protected void onEjbCreate() throws CreateException { reservationService = getBeanFactory().getBean("reservationService"); } public boolean reserveBook(Long bookId, Date from, Date to, User user) { return reservationService.reserveBook(bookId, from, to, user); } } Sunday 13 May 2012 9 -stejny business interface nam umuznuje delegovat volani
  • 10. Home a Local Interface import javax.ejb.CreateException; import javax.ejb.EJBLocalHome; public interface ReservationServiceHome extends EJBLocalHome { public ReservationServiceLocal create() throws CreateException; } import javax.ejb.EJBLocalObject; import cz.sweb.pichlik.ReservationService; public interface ReservationServiceLocal extends EJBLocalObject, ReservationService { } Sunday 13 May 2012 10
  • 11. Jak se Spring startuje <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb- jar_2_1.xsd" version="2.1" id="ejb-jar_ID"> <description>Book service EJB facade</description> <display-name>ejbs</display-name> Určuje kontext, který se bude <enterprise-beans> bootovat <session> <description>Book service EJB facade</description> <ejb-name>ReservationServiceEJBFacade</ejb-name> <local-home>cz.sweb.pichlik.ejb.ReservationServiceHome</local-home> <local>cz.sweb.pichlik.ejb.ReservationServiceLocal</local> <ejb-class>cz.sweb.pichlik.ejb.ReservationServiceEJBFacade</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <env-entry> <env-entry-name>ejb/BeanFactoryPath</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>classpath*:META-INF/businessContext.xml</env-entry-value> </env-entry> </session> Sunday 13 May 2012 11 - kazda instance beany si vytvari vlastni kontext.
  • 13. Lookup generic, local&remote <jee:jndi-lookup id="simple" jndi-name="jdbc/MyDataSource" cache="true" resource-ref="true" lookup-on-startup="false" expected-type="" proxy-interface="com.myapp.Foo"/> <jee:local-slsb id="complexLocalEjb" jndi-name="ejb/RentalServiceBean" business-interface="com.foo.service.RentalService" cache-home="true" lookup-home-on-startup="true" resource-ref="true"> <jee:remote-slsb id="complexRemoteEjb" jndi-name="ejb/MyRemoteBean" business-interface="com.foo.service.RentalService" cache-home="true" lookup-home-on-startup="true" resource-ref="true" home-interface="com.foo.service.RentalService" refresh-home-on-connect-failure="true"> Sunday 13 May 2012 13
  • 15. Podporované protokoly • Client/Server • RMI • Hessian/Burlap • HttpInvoker • JAX-RPC, JAX-WS Sunday 13 May 2012 15
  • 16. HttpInvoker service <servlet> web.xml <servlet-name>remoting</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>remoting</servlet-name> <url-pattern>/remoting/*</url-pattern> </servlet-mapping> remoting-servlet.xml <bean name="/ReservationService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"> <property name="service" ref="web.reservationService"/> <property name="serviceInterface" value="cz.sweb.pichlik.ReservationService"/> </bean> Sunday 13 May 2012 16
  • 17. HttpInvoker client <bean id="client.reservationService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> <property name="serviceUrl" value="http://localhost:8080/servlet/remoting/ReservationService"/> <property name="serviceInterface" value="cz.sweb.pichlik.ReservationService"/> </bean> Sunday 13 May 2012 17
  • 18. JMS Sunday 13 May 2012 18
  • 19. Podporované typy • MDB • AbstractJmsMessageDrivenBean • Spring MDB • Client Sunday 13 May 2012 19
  • 21. import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.MailSender; @Service public class EmailExample { @Autowired private MailSender mailSender; @Autowired private SimpleMailMessage templateMessage; public void sayHello() { SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setTo(order.getCustomer().getEmailAddress()); msg.setText(“HelloWorld”); this.mailSender.send(msg); } } <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="mail.mycompany.com"/> </bean> <!-- this is a template message that we can pre-load with default state --> <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage"> <property name="from" value="customerservice@mycompany.com"/> <property name="subject" value="Your order"/> </bean> Sunday 13 May 2012 21 org.springframework.mail.javamail.MimeMessageHelp er