0
How to build customizablemultitenant web applications
Multitenant web applications About me  Stephan Hochdörfer, bitExpert AG  Department Manager Research Labs  enjoying PHP...
Multitenant web applications Single Tenancy
Multitenant web applications     Developer                 vs.   Businessman
Multitenant web applications Single Tenancy – more customers
Multitenant web applications Single Tenancy – even more customers
Multitenant web applications Where will this lead to?
Multitenant web applications Maintenance nightmare!
Multitenant web applications Single Tenancy                            Tenant 1                           Application     ...
Multitenant web applications Single Tenancy            Tenant 1       Tenant 2      Tenant 3           Application    Appl...
Multitenant web applications Multi Tenancy            Tenant 1       Tenant 2     Tenant 3                          Applic...
Multitenant web applications What should be customizable?
Multitenant web applications What should be customizable?            Tenant 1       Tenant 2     Tenant 3                 ...
Multitenant web applications What should be customizable?            Tenant 1       Tenant 2     Tenant 3                 ...
Multitenant web applications How to skin an application?
Multitenant web applications How to skin an application?                  Remember:            It`s a web application!
Multitenant web applications How to skin an application?                               HTML
Multitenant web applications How to skin an application?                      HTML + CSS
Multitenant web applications
Multitenant web applications
Multitenant web applications
Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org...
Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org...
Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org...
Multitenant web applications Feature driven CSS              Wait, there`s more...
Multitenant web applications Feature driven CSS                     display: none
Multitenant web applications This is not an security advice!
Multitenant web applications Next level...
Multitenant web applications Menubar generation <?php if($user->hasEnabled(Module::ORDERMANAGEMENT)) {   if($user->canAcce...
Multitenant web applications Menubar generation <?php if($tenant->hasModule(Module::ORDERMANAGEMENT) {   if($user->hasEnab...
Multitenant web applications Menubar generation                      Modularize!
Multitenant web applications Menubar generation           Module 1        Module 2       Module 3                         ...
Multitenant web applications Menubar generation           Module 1        Module 2       Module 3                         ...
Multitenant web applications Menubar generation           Module 1        Module 2       Module 3                         ...
Multitenant web applications Optimize workflows
Multitenant web applications Optimize workflows <?php if(CC == $paymentType) {   // handle credit card payment } else if(C...
Multitenant web applications Optimize workflows <?php if(CC == $paymentType) {   // handle credit card payment for some te...
Multitenant web applications Optimize workflows            Decouple functionality!
Multitenant web applications Optimize workflows <?php $paymentType = CC; // set via request $payment     = PaymentFactory:...
Multitenant web applications Optimize workflows <?php $paymentType = CC; // set via request $payment     = PaymentFactory:...
Multitenant web applications Optimize workflows          How to add custom logic?
Multitenant web applications Custom logic - Subclassing?                           Abstract                           Paym...
Multitenant web applications Custom logic                  Any alternatives?
Multitenant web applications Custom logic                 Let`s add hooks...
Multitenant web applications Custom logic - Hooks <?php $paymentType = CC; // set via request $payment     = PaymentFactor...
Multitenant web applications Custom logic      How to set the dependencies?
Multitenant web applications Custom logic             Dependency Injection!
Multitenant web applications Custom logic – Dependency Injection <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="htt...
Multitenant web applications Custom logic – Dependency Injection <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="htt...
Multitenant web applications Custom logic         Any further improvements?
Multitenant web applications Custom logic <?php $paymentType = CC; // set via request $payment     = PaymentFactory::creat...
Multitenant web applications Custom logic <?php $paymentType = CC; // set via request $payment     = PaymentFactory::creat...
Multitenant web applications Custom logic      Aspect-oriented programming
Multitenant web applications Custom logic – Aspects for the masses! /**  * @aspect  */ class CustomPaymentProcessingAspect...
Multitenant web applications Custom logic - Result <?php $paymentType = CC; // set via request $payment     = PaymentFacto...
Multitenant web applications Next level...
Multitenant web applications Database – Where to store the data?
Multitenant web applications Database – Where to store the data?             We need to store data                 for a t...
Multitenant web applications Database – Where to store the data?               Database per Tenant?
Multitenant web applications Database – Where to store the data?               Database per Tenant?                Schema ...
Multitenant web applications Database – Where to store the data?               Database per Tenant?                Schema ...
Multitenant web applications Database – How to access the data?                               vs.              ORM        ...
Multitenant web applications                  Generalize you should!
Multitenant web applications No single solution!
Multitenant web applications Softwaresystemfamily
Multitenant web applications A factory for mass production!
Multitenant web applications Multi Tenancy – Single Instance            Tenant 1           Tenant 2   Tenant 3            ...
Multitenant web applications Multi Tenancy – Multi Instance            Tenant 1           Tenant 2   Tenant 3             ...
Multitenant web applications Multi Tenancy – Multi Instance           Generative Programming
Multitenant web applications Generative Programming                               Generator                               ...
Multitenant web applications Generative Programming                               Configuration                           ...
Multitenant web applications Generative Programming                               Configuration                           ...
Multitenant web applications Generative Programming                               Configuration                           ...
Multitenant web applications Generative Programming                               Configuration                           ...
Multitenant web applications Generative Programming                               Configuration                           ...
Multitenant web applications Generative Programming                                                Tenant 33              ...
Multitenant web applications Generative Programming - Goal    Create an optimized application!
Multitenant web applications Generative Programming - Goal          Create an optimized        application for one tenant!
Multitenant web applications Generative Programming – Bonus points
Multitenant web applications Generative Programming – Bonus points     Reduce application complexity
Multitenant web applications Generative Programming – Bonus points <?php $paymentType = CC; // set via request $payment   ...
Multitenant web applications Generative Programming – Bonus points public class PostProcessorFrame extends SimpleFrameCont...
Multitenant web applications Generative Programming – Bonus points      Reduce maintenance support
Multitenant web applications Generative Programming – Bonus points                               Implementation           ...
Multitenant web applications Generative Programming – Bonus points            Feature            Tenant
Multitenant web applications Generative Programming – Bonus points                               Tenant                   ...
Multitenant web applications Generative Programming – The book
http://joind.in/3517
Flickr Creditshttp://www.flickr.com/photos/andresrueda/3452940751/http://www.flickr.com/photos/andresrueda/3455410635/
Upcoming SlideShare
Loading in...5
×

How to build customizable multitenant web applications - IPC11 Spring Edition

12,110

Published on

Transcript of "How to build customizable multitenant web applications - IPC11 Spring Edition"

  1. 1. How to build customizablemultitenant web applications
  2. 2. Multitenant web applications About me  Stephan Hochdörfer, bitExpert AG  Department Manager Research Labs  enjoying PHP since 1999  S.Hochdoerfer@bitExpert.de  @shochdoerfer
  3. 3. Multitenant web applications Single Tenancy
  4. 4. Multitenant web applications Developer vs. Businessman
  5. 5. Multitenant web applications Single Tenancy – more customers
  6. 6. Multitenant web applications Single Tenancy – even more customers
  7. 7. Multitenant web applications Where will this lead to?
  8. 8. Multitenant web applications Maintenance nightmare!
  9. 9. Multitenant web applications Single Tenancy Tenant 1 Application Database Hardware
  10. 10. Multitenant web applications Single Tenancy Tenant 1 Tenant 2 Tenant 3 Application Application Application Database Database Database Hardware Hardware Hardware
  11. 11. Multitenant web applications Multi Tenancy Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  12. 12. Multitenant web applications What should be customizable?
  13. 13. Multitenant web applications What should be customizable? Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  14. 14. Multitenant web applications What should be customizable? Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  15. 15. Multitenant web applications How to skin an application?
  16. 16. Multitenant web applications How to skin an application? Remember: It`s a web application!
  17. 17. Multitenant web applications How to skin an application? HTML
  18. 18. Multitenant web applications How to skin an application? HTML + CSS
  19. 19. Multitenant web applications
  20. 20. Multitenant web applications
  21. 21. Multitenant web applications
  22. 22. Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My App</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/styles/myapp.css" /> </head> <body> </body> </html>
  23. 23. Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My App</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/styles/<?php echo $tenant ?>.css" /> </head> <body> </body> </html>
  24. 24. Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My App</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/styles/myapp.css" /> <link rel="stylesheet" type="text/css" href="css/styles/<?php echo $tenant ?>.css" /> </head> <body> </body> </html>
  25. 25. Multitenant web applications Feature driven CSS Wait, there`s more...
  26. 26. Multitenant web applications Feature driven CSS display: none
  27. 27. Multitenant web applications This is not an security advice!
  28. 28. Multitenant web applications Next level...
  29. 29. Multitenant web applications Menubar generation <?php if($user->hasEnabled(Module::ORDERMANAGEMENT)) { if($user->canAccess(OrderManagement::LIST_ORDERS)) { $this->renderLink(OrderManagement::LIST_ORDERS); } if($user->canAccess(OrderManagement::ADD_ORDER)) { $this->renderLink(OrderManagement::ADD_ORDER); } }
  30. 30. Multitenant web applications Menubar generation <?php if($tenant->hasModule(Module::ORDERMANAGEMENT) { if($user->hasEnabled(Module::ORDERMANAGEMENT)) { if($user->canAccess(OrderManagement::LIST_ORDERS)) { $this->renderLink(OrderManagement::LIST_ORDERS); } if($user->canAccess(OrderManagement::ADD_ORDER)) { $this->renderLink(OrderManagement::ADD_ORDER); } } }
  31. 31. Multitenant web applications Menubar generation Modularize!
  32. 32. Multitenant web applications Menubar generation Module 1 Module 2 Module 3 register at start up Application core
  33. 33. Multitenant web applications Menubar generation Module 1 Module 2 Module 3 register at start up Application core
  34. 34. Multitenant web applications Menubar generation Module 1 Module 2 Module 3 register at start up Application core
  35. 35. Multitenant web applications Optimize workflows
  36. 36. Multitenant web applications Optimize workflows <?php if(CC == $paymentType) { // handle credit card payment } else if(COD == $paymentType) { // handle cash on delivery payment }
  37. 37. Multitenant web applications Optimize workflows <?php if(CC == $paymentType) { // handle credit card payment for some tenants! if(in_array($tenant->getName(), array(tenant1, tenant2)) { // insert logic here... } } else if(COD == $paymentType) { // handle cash on delivery payment for some tenants! }
  38. 38. Multitenant web applications Optimize workflows Decouple functionality!
  39. 39. Multitenant web applications Optimize workflows <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType); $payment->execute($order);
  40. 40. Multitenant web applications Optimize workflows <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order);
  41. 41. Multitenant web applications Optimize workflows How to add custom logic?
  42. 42. Multitenant web applications Custom logic - Subclassing? Abstract Payment CC Payment CCPayment CCPayment Tenant 1 Tenant 2
  43. 43. Multitenant web applications Custom logic Any alternatives?
  44. 44. Multitenant web applications Custom logic Let`s add hooks...
  45. 45. Multitenant web applications Custom logic - Hooks <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); if($this->paymentPostProcessor instanceof IPaymentPostProcessor) { $this->paymentPostProcessor->run($payment, $tenant, $order); }
  46. 46. Multitenant web applications Custom logic How to set the dependencies?
  47. 47. Multitenant web applications Custom logic Dependency Injection!
  48. 48. Multitenant web applications Custom logic – Dependency Injection <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.bitexpert.de/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bitexpert.de/schema/ http://www.bitexpert.de/schema/bitFramework- beans.xsd"> <bean id="Service.Order" class="MyAppServiceOrder.php"> </bean> <bean id="Tenant1.Order" class="MyAppServiceOrder.php"> <property name="paymentPostProcessor" ref="Tentant1.Payment.SendOrderMail" /> </bean> </beans>
  49. 49. Multitenant web applications Custom logic – Dependency Injection <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.bitexpert.de/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bitexpert.de/schema/ http://www.bitexpert.de/schema/bitFramework- beans.xsd"> <bean id="Tenant2.Order" class="MyAppServiceOrder.php"> <property name="paymentPostProcessor" ref="Tentant1.Payment.PushToERP" /> </bean> </beans>
  50. 50. Multitenant web applications Custom logic Any further improvements?
  51. 51. Multitenant web applications Custom logic <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); if($this->paymentPostProcessor instanceof IPaymentPostProcessor) { $this->paymentPostProcessor->run($payment, $tenant, $order); }
  52. 52. Multitenant web applications Custom logic <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); if($this->paymentPostProcessor instanceof IPaymentPostProcessor) { $this->paymentPostProcessor->run($payment, $tenant, $order); }
  53. 53. Multitenant web applications Custom logic Aspect-oriented programming
  54. 54. Multitenant web applications Custom logic – Aspects for the masses! /** * @aspect */ class CustomPaymentProcessingAspect { /** * @around MyAppServiceOrder->processPayment */ public function customFilter(JoinPointInterface $jP) { $result = $jP->getAdviceChain()->proceed($jP); // @TODO: implement post-processing logic return $result; } }
  55. 55. Multitenant web applications Custom logic - Result <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order);
  56. 56. Multitenant web applications Next level...
  57. 57. Multitenant web applications Database – Where to store the data?
  58. 58. Multitenant web applications Database – Where to store the data? We need to store data for a tenant!
  59. 59. Multitenant web applications Database – Where to store the data? Database per Tenant?
  60. 60. Multitenant web applications Database – Where to store the data? Database per Tenant? Schema per Tenant?
  61. 61. Multitenant web applications Database – Where to store the data? Database per Tenant? Schema per Tenant? Tenant Id per Row?
  62. 62. Multitenant web applications Database – How to access the data? vs. ORM dynamic statements
  63. 63. Multitenant web applications Generalize you should!
  64. 64. Multitenant web applications No single solution!
  65. 65. Multitenant web applications Softwaresystemfamily
  66. 66. Multitenant web applications A factory for mass production!
  67. 67. Multitenant web applications Multi Tenancy – Single Instance Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  68. 68. Multitenant web applications Multi Tenancy – Multi Instance Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  69. 69. Multitenant web applications Multi Tenancy – Multi Instance Generative Programming
  70. 70. Multitenant web applications Generative Programming Generator Generator
  71. 71. Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Generator Generator
  72. 72. Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Implementation- Implementation- components Generator Generator components
  73. 73. Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) 1..n Implementation- Implementation- components Generator Generator Product components Product
  74. 74. Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Implementation- Implementation- components Generator Generator Tenant 11 components Tenant
  75. 75. Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Tenant 22 Tenant Implementation- Implementation- components Generator Generator Tenant 11 components Tenant
  76. 76. Multitenant web applications Generative Programming Tenant 33 Tenant Configuration Configuration (DSL) (DSL) Tenant 22 Tenant Implementation- Implementation- components Generator Generator Tenant 11 components Tenant
  77. 77. Multitenant web applications Generative Programming - Goal Create an optimized application!
  78. 78. Multitenant web applications Generative Programming - Goal Create an optimized application for one tenant!
  79. 79. Multitenant web applications Generative Programming – Bonus points
  80. 80. Multitenant web applications Generative Programming – Bonus points Reduce application complexity
  81. 81. Multitenant web applications Generative Programming – Bonus points <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); <!{PostProcessor}!>
  82. 82. Multitenant web applications Generative Programming – Bonus points public class PostProcessorFrame extends SimpleFrameController { public void execute(Frame frame, FeatureConfig config) { if(config.hasFeature("order_send_mail")) { frame.setSlot("PostProcessor", "..."); } if(config.hasFeature("order_push_to_erp")) { frame.setSlot("PostProcessor", "..."); } } }
  83. 83. Multitenant web applications Generative Programming – Bonus points Reduce maintenance support
  84. 84. Multitenant web applications Generative Programming – Bonus points Implementation Feature component
  85. 85. Multitenant web applications Generative Programming – Bonus points Feature Tenant
  86. 86. Multitenant web applications Generative Programming – Bonus points Tenant Feature Implementation component
  87. 87. Multitenant web applications Generative Programming – The book
  88. 88. http://joind.in/3517
  89. 89. Flickr Creditshttp://www.flickr.com/photos/andresrueda/3452940751/http://www.flickr.com/photos/andresrueda/3455410635/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×