Spring as a Cloud Platform (Developer Summit 2011 17-C-5)

2,607 views
2,513 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,607
On SlideShare
0
From Embeds
0
Number of Embeds
453
Actions
Shares
0
Downloads
130
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Spring as a Cloud Platform (Developer Summit 2011 17-C-5)

  1. 1. 17-C-5 Developers Summit 2011
  2. 2. Developers Summit 2011
  3. 3. Developers Summit 2011
  4. 4. Developers Summit 2011
  5. 5. Simple Object Portable Service Abstraction Developers Summit 2011
  6. 6. Developers Summit 2011
  7. 7. Developers Summit 2011
  8. 8. Developers Summit 2011
  9. 9. Developers Summit 2011
  10. 10. Developers Summit 2011
  11. 11. Developers Summit 2011
  12. 12. Developers Summit 2011
  13. 13. Developers Summit 2011
  14. 14. Application Framework Middle Ware OS H/W Developers Summit 2011
  15. 15. Roo/Grails Spring Servlet JVM Developers Summit 2011
  16. 16. vSphere App App App vCloud Other Cloud App App App Developers Summit 2011
  17. 17. Force.com Your Java App Platform Services Spring & Tomcat VMware vCloud VMware vSphere Force.com Database Developers Summit 2011
  18. 18. Your Java App Scaling( ) and Load- balancing( ) as a service Monitoring( ) and diagnostics( ) as a service & Force.com Database Developers Summit 2011
  19. 19. GWT Hyperic GAE/J Spring Developers Summit 2011
  20. 20. Developers Summit 2011
  21. 21. SUSE Linux vCloud vSphere Developers Summit 2011
  22. 22. App App App Linux vCloud vSphere Developers Summit 2011
  23. 23. Developers Summit 2011
  24. 24. Developers Summit 2011
  25. 25. Web Service Data Access JPA Hibernate Spring JDBC HSQLDB Spring tc Server Developers Summit 2011
  26. 26. @Controller@RequestMapping("/login.form")public class LoginController { private LoginService loginService; @Autowired public void setLoginService(LoginService loginService) { this.loginService = loginService; } ... @RequestMapping(method = RequestMethod.GET) appContext-web.xml public String setupForm(ModelMap model) { <?xml version="1.0" encoding="UTF-8"?> if (loginService.isLogin()) { <beans ...> model.addAttribute("login", loginService.getLoginUser()); return loginService.getWelcomePage(); <context:component-scan } else { base-package="sample.spring.mvc.web" /> <bean id="messageSource" model.addAttribute("login", new LoginBean()); return loginService.getLoginPage(); class="org.springframework.context.support. } ResourceBundleMessageSource"> } <property name="basename" value="messages" /> …} </bean> </beans> Developers Summit 2011
  27. 27. <%@ page language="java" contentType="text/html; charset=Shift_JIS" pageEncoding="Shift_JIS" isELIgnored="false" %><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"><title>Login Page</title></head><body><h1>Login!</h1><form:form modelAttribute="login"><table> appContext-view.xml <tr> <?xml version="1.0" encoding="UTF-8"?> <td>Login Name:</td> <td> <beans:beans ...> <form:input path="loginname"/> <annotation-driven /> <font color="red"><form:errors path="loginname"/></font> </td> <resources mapping="/resources/**" location="/resources/" /> </tr> <beans:bean .... <tr> class="org.springframework.web.servlet.view. InternalResourceViewResolver"> <td colspan="2"><input type="submit" name="Login" value="Login"></td> </tr> <beans:property name="prefix" value="/WEB-INF/views/" /></table></form:form> <beans:property name="suffix" value=".jsp" /></body> </beans:bean></html>login.jsp </beans:beans> Developers Summit 2011
  28. 28. @Service("loginService")public class LoginServiceImpl implements LoginService { @Autowired private MemberDao memberDao; public void setMemberDao(MemberDao memberDao) { this.memberDao = memberDao; } @Transactional(readOnly=true) public boolean login(String loginname, String password) { appContext-service.xml List<LoginBean> beans = memberDao.findByLoginname(loginname); <?xml version="1.0" encoding="UTF-8"?> if (beans.size() > 0) { <beans …> LoginBean bean = beans.get(0); <context:annotation-config/> if (bean.getPassword() != null && <context:component-scan bean.getPassword().equals(password)) { base-package="sample.spring.mvc.service"/> loginManager.setLoginUser(bean); return true; <bean id="loginManager" scope="session" } class="sample.spring.mvc.service.LoginManager"> } <aop:scoped-proxy/> return false; </bean> } </beans>} Developers Summit 2011
  29. 29. @Repository("memberDao")public class MemberDaoImpl implements MemberDao { @PersistenceContext appContext-dao.xml EntityManager em; <?xml version="1.0" encoding="UTF-8"?> <beans… <context:annotation-config/> public List<LoginBean> findByLoginname(String loginname) { <context:component-scan base-package="sample.spring.mvc.dao"/> Query query = em.createQuery( <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> "SELECT l FROM LoginBean l WHERE l.loginname = value="sample" /> <property name="persistenceUnitName" :loginname"); query.setParameter("loginname", loginname); ref="dataSource"/> <property name="dataSource" <property name="jpaVendorAdapter"> return query.getResultList(); <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> } <property name="showSql" value="true" /> </bean>} </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> <property name="url" value="jdbc:hsqldb:hsql://localhost/"/> <property name="username" value="sa"/> <property name="password" value=""/> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> </beans> Developers Summit 2011
  30. 30. @Entity@Table(name="member")public class LoginBean implements Serializable { public LoginBean() {} @Id @GeneratedValue <?xml version="1.0" encoding="UTF-8"?> private Long id; <persistence …> @Column(unique=true) <persistence-unit name="sample" private String loginname; transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> private String password; <class>sample.spring.mvc.bean.LoginBean</class> @Column(name="name") <exclude-unlisted-classes>false</exclude-unlisted-classes> private String nickname; <properties> … <property name="hibernate.dialect"} value="org.hibernate.dialect.HSQLDialect" /> </properties> </persistence-unit> </persistence> persistence.xml Developers Summit 2011
  31. 31. Developers Summit 2011
  32. 32. Developers Summit 2011
  33. 33. Developers Summit 2011
  34. 34. Developers Summit 2011
  35. 35. Web Service Data Access JPA Datanucleus Web API Spring Connector Force.com Database Spring tc Server on VMForce Developers Summit 2011
  36. 36. @Controller@RequestMapping("/login.form")public class LoginController { private LoginService loginService; @Autowired public void setLoginService(LoginService loginService) { this.loginService = loginService; } ... @RequestMapping(method = RequestMethod.GET) appContext-web.xml public String setupForm(ModelMap model) { <?xml version="1.0" encoding="UTF-8"?> if (loginService.isLogin()) { <beans ...> model.addAttribute("login", loginService.getLoginUser()); return loginService.getWelcomePage(); <context:component-scan } else { base-package="sample.spring.mvc.web" /> <bean id="messageSource" model.addAttribute("login", new LoginBean()); return loginService.getLoginPage(); class="org.springframework.context.support. } ResourceBundleMessageSource"> } <property name="basename" value="messages" /> …} </bean> </beans> Developers Summit 2011
  37. 37. <%@ page language="java" contentType="text/html; charset=Shift_JIS" pageEncoding="Shift_JIS" isELIgnored="false" %><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"><title>Login Page</title></head><body><h1>Login!</h1><form:form modelAttribute="login"><table> appContext-view.xml <tr> <?xml version="1.0" encoding="UTF-8"?> <td>Login Name:</td> <td> <beans:beans ...> <form:input path="loginname"/> <annotation-driven /> <font color="red"><form:errors path="loginname"/></font> </td> <resources mapping="/resources/**" location="/resources/" /> </tr> <beans:bean .... <tr> class="org.springframework.web.servlet.view. InternalResourceViewResolver"> <td colspan="2"><input type="submit" name="Login" value="Login"></td> </tr> <beans:property name="prefix" value="/WEB-INF/views/" /></table></form:form> <beans:property name="suffix" value=".jsp" /></body> </beans:bean></html>login.jsp </beans:beans> Developers Summit 2011
  38. 38. @Service("loginService")public class LoginServiceImpl implements LoginService { @Autowired private MemberDao memberDao; public void setMemberDao(MemberDao memberDao) { this.memberDao = memberDao; } @Transactional(readOnly=true) public boolean login(String loginname, String password) { appContext-service.xml List<LoginBean> beans = memberDao.findByLoginname(loginname); <?xml version="1.0" encoding="UTF-8"?> if (beans.size() > 0) { <beans …> LoginBean bean = beans.get(0); <context:annotation-config/> if (bean.getPassword() != null && <context:component-scan bean.getPassword().equals(password)) { base-package="sample.spring.mvc.service"/> loginManager.setLoginUser(bean); return true; <bean id="loginManager" scope="session" } class="sample.spring.mvc.service.LoginManager"> } <aop:scoped-proxy/> return false; </bean> } </beans>} Developers Summit 2011
  39. 39. @Repository("memberDao")public class MemberDaoImpl implements MemberDao { @PersistenceContext EntityManager em; public List<LoginBean> findByLoginname(String loginname) { Query query = em.createQuery( appContext-dao.xml "SELECT l FROM LoginBean l WHERE l.loginname = :loginname"); <?xml version="1.0" encoding="UTF-8"?> <beans ...> query.setParameter("loginname", loginname); <context:annotation-config/> return query.getResultList(); <context:component-scan base-package="sample.spring.mvc.dao"/> } <bean id="entityManagerFactory"} class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="sample" /> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> </beans> Developers Summit 2011
  40. 40. @Entity@Table(name="member")public class LoginBean implements Serializable { ID public LoginBean() {} String <?xml version="1.0" encoding="UTF-8" standalone="no"?> @Id <persistence ...> <persistence-unit name="sample"> @GeneratedValue(strategy = GenerationType.IDENTITY) <provider>org.datanucleus.jpa.PersistenceProviderImpl</provider> private String id; <properties> <property name="datanucleus.Optimistic" value="false"/> @Column(unique=true) <property name="datanucleus.datastoreTransactionDelayOperations" value="true"/> private String loginname; <property name="sfdcConnectionName" value="DefaultSFDCConnection"/> private String password; <property name="datanucleus.ConnectionURL" value="sfdc:https://xxx.salesforce.com/services/Soap/u/20.0"/> //@Column(name="name") <property name="datanucleus.ConnectionUserName" value="xxx@xxx.com"/> private String nickname; <property name="datanucleus.ConnectionPassword" value="xxxx"/> ... <property name="datanucleus.autoCreateSchema" value="false"/> <property name="datanucleus.autoCreateTables" force.com API value="true"/>} <property name="datanucleus.autoCreateColumns" value="false"/> <property name="datanucleus.autoCreateConstraints" value="false"/> <property name="datanucleus.validateTables" value="false"/> <property name="datanucleus.validateConstraints" value="false"/> <property name="datanucleus.jpa.addClassTransformer" value="false"/> </properties> </persistence-unit> </persistence> Developers Summit 2011 persistence.xml
  41. 41. Developers Summit 2011
  42. 42. Developers Summit 2011
  43. 43. VMForce Extension Developers Summit 2011
  44. 44. Developers Summit 2011
  45. 45. URL Developers Summit 2011
  46. 46. Developers Summit 2011
  47. 47. Developers Summit 2011
  48. 48. Developers Summit 2011
  49. 49. Web Service Data Access JPA Datanucleus Spring Connector Google AppEngine BigTable Developers Summit 2011
  50. 50. @Controller@RequestMapping("/login.form")public class LoginController { private LoginService loginService; @Autowired public void setLoginService(LoginService loginService) { this.loginService = loginService; } ... @RequestMapping(method = RequestMethod.GET) appContext-web.xml public String setupForm(ModelMap model) { <?xml version="1.0" encoding="UTF-8"?> if (loginService.isLogin()) { <beans ...> model.addAttribute("login", loginService.getLoginUser()); return loginService.getWelcomePage(); <context:component-scan } else { base-package="sample.spring.mvc.web" /> <bean id="messageSource" model.addAttribute("login", new LoginBean()); return loginService.getLoginPage(); class="org.springframework.context.support. } ResourceBundleMessageSource"> } <property name="basename" value="messages" /> …} </bean> </beans> Developers Summit 2011
  51. 51. <%@ page language="java" contentType="text/html; charset=Shift_JIS" pageEncoding="Shift_JIS" isELIgnored="false" %><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"><title>Login Page</title></head><body><h1>Login!</h1><form:form modelAttribute="login"><table> appContext-view.xml <tr> <?xml version="1.0" encoding="UTF-8"?> <td>Login Name:</td> <td> <beans:beans ...> <form:input path="loginname"/> <annotation-driven /> <font color="red"><form:errors path="loginname"/></font> </td> <resources mapping="/resources/**" location="/resources/" /> </tr> <beans:bean .... <tr> class="org.springframework.web.servlet.view. InternalResourceViewResolver"> <td colspan="2"><input type="submit" name="Login" value="Login"></td> </tr> <beans:property name="prefix" value="/WEB-INF/views/" /></table></form:form> <beans:property name="suffix" value=".jsp" /></body> </beans:bean></html>login.jsp </beans:beans> Developers Summit 2011
  52. 52. <?xml version="1.0" encoding="utf-8" standalone="no"?><appengine-web-app xmlns="http://appengine.google.com/ns/1.0"><application>xxx</application><version>2</version><sessions-enabled>true</sessions-enabled> </appengine-web-app> appengine-web.xml Developers Summit 2011
  53. 53. @Service("loginService")public class LoginServiceImpl implements LoginService { @Autowired private MemberDao memberDao; public void setMemberDao(MemberDao memberDao) { this.memberDao = memberDao; } @Transactional(readOnly=true) public boolean login(String loginname, String password) { appContext-service.xml List<LoginBean> beans = memberDao.findByLoginname(loginname); <?xml version="1.0" encoding="UTF-8"?> if (beans.size() > 0) { <beans …> LoginBean bean = beans.get(0); <context:annotation-config/> if (bean.getPassword() != null && <context:component-scan bean.getPassword().equals(password)) { base-package="sample.spring.mvc.service"/> loginManager.setLoginUser(bean); return true; <bean id="loginManager" scope="session" } class="sample.spring.mvc.service.LoginManager"> } <aop:scoped-proxy/> return false; </bean> } </beans>} Developers Summit 2011
  54. 54. @Repository("memberDao")public class MemberDaoImpl implements MemberDao { @PersistenceContext EntityManager em; public List<LoginBean> findByLoginname(String loginname) { Query query = em.createQuery( appContext-dao.xml "SELECT l FROM LoginBean l WHERE l.loginname = :loginname"); <?xml version="1.0" encoding="UTF-8"?> <beans ...> query.setParameter("loginname", loginname); <context:annotation-config/> return query.getResultList(); <context:component-scan base-package="sample.spring.mvc.dao"/> } <bean id="entityManagerFactory"} class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="sample" /> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> </beans> Developers Summit 2011
  55. 55. @Entity@Table(name="member") AppEnginepublic class LoginBean implements Serializable { JPA public LoginBean() {} @Id <?xml version="1.0" encoding="UTF-8" standalone="no"?> @GeneratedValue(strategy =<persistence …> GenerationType.IDENTITY) <persistence-unit name="sample"> private String id; <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider> //@Column(unique=true) <properties> private String loginname; <property name="datanucleus.NontransactionalRead" value="true"/> <property name="datanucleus.NontransactionalWrite" value="true"/> private String password; <property name="datanucleus.ConnectionURL" value="appengine"/> //@Column(name="name") <property name="datanucleus.ConnectionUserName" value=""/> private String nickname; <property name="datanucleus.ConnectionPassword" value=""/> <property name="datanucleus.autoCreateSchema" value="false"/> ... <property name="datanucleus.autoCreateTables" value="true"/> } <property name="datanucleus.autoCreateColumns" value="false"/> <property name="datanucleus.autoCreateConstraints" value="false"/> <property name="datanucleus.validateTables" value="false"/> <property name="datanucleus.validateConstraints" value="false"/> <property name="datanucleus.jpa.addClassTransformer" value="false"/> </properties> </persistence-unit> </persistence> Developers Summit 2011 persistence.xml
  56. 56. Developers Summit 2011
  57. 57. Developers Summit 2011
  58. 58. Developers Summit 2011
  59. 59. Developers Summit 2011
  60. 60. Developers Summit 2011
  61. 61. Developers Summit 2011
  62. 62. Developers Summit 2011
  63. 63. Developers Summit 2011
  64. 64. Developers Summit 2011
  65. 65. Developers Summit 2011

×