SlideShare a Scribd company logo
1 of 25
Architecture and Implementation
Short video...
User selects the sports he practices or would
like to practice
User selects places on map where practices
the selected sports
User selects his favourite days and time
HomePage showing participants and events
near the selected location
January 2011, We-Sport is sponsor of
"2011 IPC ALPINE SKIING WORLD CHAMPIONSHIPS"
Quick diagram
Spring configuration

web.xml
...
<servlet>
    <servlet-name>sports</servlet-name>
    <servlet-class>
       org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
     <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>sports</servlet-name>
    <url-pattern>/api/*</url-pattern>
  </servlet-mapping>
...
SportController
@Controller
@RequestMapping("/sport")
public class SportController extends AbstractController {

@Autowired
private SportsService sportsService;

@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {

setParams(request);
Sport sport = null;
ModelAndView result = new ModelAndView();
sport = sportsService.findSportById(getSportId());
result.addObject("sport", sport);
return result;
}
     private void setParams(request){...}
}
Handle multiple output types
<?xml..><beans ...">
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes">
<map><entry key="json" value="application/json" /> <entry key="xml" value="application/xml" /> <entry key="pdf"
value="application/pdf" /></map> </property> <property name="defaultViews"> <list> <bean class="com.sports.service.PDFPage"
                                                                                      Spring 3
p:contentType="application/pdf" /> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
<bean class="org.springframework.web.servlet.view.xml.MarshallingView"> <constructor-arg> <bean id="castorMarshaller"
                                                                            ContentNegotiatingViewResolver
class="org.springframework.oxm.castor.CastorMarshaller" /> </constructor-arg> </bean></list></property> </bean></beans>
                                                                                 (sports-servlet.xml)
Examples of API requests:
RpcSportsServiceImpl
public class RpcSportsServiceImpl extends AutoinjectingRemoteServiceServlet
implements
RpcSportsService {

    @Autowired
    private SportsService sportsService;

    public Sport findSportById(Long sportId) {
      return sportsService.findSportById(sportId);
    }

    // getters and setters of sportsService
}
AutoinjectingRemoteServiceServlet
public abstract class AutoinjectingRemoteServiceServlet extends
RemoteServiceServlet {

 @Override
 public void init(ServletConfig config) throws ServletException {
  super.init(config);
WebApplicationContext ctx = WebApplicationContextUtils
  .getRequiredWebApplicationContext(config.getServletContext());

  AutowireCapableBeanFactory beanFactory = ctx
.getAutowireCapableBeanFactory();
    beanFactory.autowireBean(this);
  }
}
SportsServiceImpl
public class SportsServiceImpl implements SportsService {

  @Autowired
  private SportDao sportDao;

  public Sport findSportById(Long sportId) {
    final String cacheKey = "findSportById_"+sportId;
    if (!getCache().contains(cacheKey) ||
        getCache().get(cacheKey) == null) {
getCache().put(cacheKey, sportDao.findById(sportId));
    }
    return (Sport) getCache().get(cacheKey);
  }
}
DataStore Access - JDO
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
....... default-lazy-init="true">                                                     Spring 3 - JDOTemplate
<context:component-scan base-package="com.sports.dao.jdo" /> <context:component-scan base-
                                                                                            Configuration
package="com.sports.server.servlet.filter" /> <bean id="sportsService" class="com.sports.service.SportsServiceImpl" />
                                                                                      (applicationContext.xml)
<tx:annotation-driven /> <bean id="persistenceManagerFactory" class="com.sports.server.utils.GaePMF" factory-
method="getPersistenceManagerFactory"> </bean> <bean id="transactionManager"
class="org.springframework.orm.jdo.JdoTransactionManager"> <property name="persistenceManagerFactory"
ref="persistenceManagerFactory" /> </bean> <bean id="jdoTemplate" class="org.springframework.orm.jdo.JdoTemplate">
<constructor-arg ref="persistenceManagerFactory" /> <constructor-arg value="false" type="boolean" /> </bean> </beans>
BaseDaoJdo
package com.sports.dao.jdo;
import ...

public abstract class BaseDaoJdo {

@Autowired
protected PersistenceManagerFactory pmf;

@Autowired
protected JdoTemplate jdoTemplate;
@Autowired
protected JdoTransactionManager transactionManager;

}
SportDaoJdo
package com.sports.dao.jdo;
import ...

@Component
public class SportDaoJdo extends BaseDaoJdo implements SportDao {
     public Sport save(Sport sport) {
return jdoTemplate.makePersistent(sport);
}
     @SuppressWarnings("unchecked")
public Collection<Sport> findAll() {
Object[] a = {};
return jdoTemplate.detachCopyAll(jdoTemplate.find("select from " +
Sport.class.getName() + " order by name", a));
}
}
Cron + TaskQueue

cron:
- description: Update Sports Counter
  url: /api/cron/updateSportCounter    cron.yaml
  schedule: every 24 hours
UpdateSportCounter
@Controller
@RequestMapping("/cron/updateSportCounter")
public class UpdateSportCounter {
 @Autowired
private SportsService sportsService;
 @RequestMapping(method = RequestMethod.GET)
 public void execute(HttpServletResponse response) throws IOException {

  for (SportOutput sportOut : sportsService.findAllSports()){
   final Long id = sportOut.getId();
   final int counter = sportsService.getCountPlayersBySport(id);
   UpdateCounterSportTaskQueue.updateCounterSportTask(id, counter);
}
response.getWriter().write("Scheduled all taskqueues.");
}
}
UpdateCounterSportTaskQueue
public class UpdateCounterSportTaskQueue {
 public static void updateCounterSportTask(final Long id, final int counter) {

  TaskOptions taskOptions =
    TaskOptions.Builder.withUrl(
"/api/task/updateCounterSport");

    taskOptions.param("id", String.valueOf(id));
    taskOptions.param("counter", String.valueOf(counter));

    QueueFactory.getDefaultQueue().add(taskOptions);

    }
}
UpdateCounterSportWorker
@Controller
@RequestMapping("/task/updateCounterSport")
public class UpdateCounterSportWorker {
     @Autowired
private SportDao sportDao;
     @RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.ACCEPTED)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void execute(@RequestParam long id, @RequestParam int counter) {
Sport sport = sportDao.findById(id);
sport.setCounter(counter);
sport.setUpdatedDate(new Date());
sportDao.save(sport);
}
}
Version Control - GIT
Decentralization
Distributed Version Control Systems take advantage of the peer-to-peer
approach. Clients can communicate between each other and maintain their
own local branches without having to go through a Central
Server/Repository. Then synchronization takes place between the peers who
decide which changesets to exchange.
GIT + Dropbox
 I think that git on dropbox is great. I use it all of the time. I have multiple
 computers (two at home and one elsewhere) that I use dropbox as a central
 bare repo. Since I don't want to host it on a public service and I don't have
 access to a server that I can always ssh to, Dropbox takes care of this by
 syncing (very quickly) in the background.
 Setup is something like this:




http://stackoverflow.com/questions/1960799/using-gitdropbox-together-effectively
Thank you for your kind attention


busy busy ...

More Related Content

What's hot

Reactive state management with Jetpack Components
Reactive state management with Jetpack ComponentsReactive state management with Jetpack Components
Reactive state management with Jetpack ComponentsGabor Varadi
 
Asp.Net Mvc Internals &amp; Extensibility
Asp.Net Mvc Internals &amp; ExtensibilityAsp.Net Mvc Internals &amp; Extensibility
Asp.Net Mvc Internals &amp; ExtensibilityEyal Vardi
 
Building an app with Google's new suites
Building an app with Google's new suitesBuilding an app with Google's new suites
Building an app with Google's new suitesToru Wonyoung Choi
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedToru Wonyoung Choi
 
What's new in Java EE 7
What's new in Java EE 7What's new in Java EE 7
What's new in Java EE 7gedoplan
 
망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18종인 전
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverSpike Brehm
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM patternNAVER Engineering
 
Ui perfomance
Ui perfomanceUi perfomance
Ui perfomanceCleveroad
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutes50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutesAntonio Goncalves
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shintutorialsruby
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limitsDroidcon Berlin
 

What's hot (20)

Reactive state management with Jetpack Components
Reactive state management with Jetpack ComponentsReactive state management with Jetpack Components
Reactive state management with Jetpack Components
 
Paging Like A Pro
Paging Like A ProPaging Like A Pro
Paging Like A Pro
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
 
Asp.Net Mvc Internals &amp; Extensibility
Asp.Net Mvc Internals &amp; ExtensibilityAsp.Net Mvc Internals &amp; Extensibility
Asp.Net Mvc Internals &amp; Extensibility
 
Building an app with Google's new suites
Building an app with Google's new suitesBuilding an app with Google's new suites
Building an app with Google's new suites
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
What's new in Java EE 7
What's new in Java EE 7What's new in Java EE 7
What's new in Java EE 7
 
망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 
Ui perfomance
Ui perfomanceUi perfomance
Ui perfomance
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Android - Api & Debugging in Android
Android - Api & Debugging in AndroidAndroid - Api & Debugging in Android
Android - Api & Debugging in Android
 
Django
DjangoDjango
Django
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
RicoLiveGrid
RicoLiveGridRicoLiveGrid
RicoLiveGrid
 
50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutes50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutes
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shin
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
 

Viewers also liked

Social Media Sport A Community Building Partnership
Social Media Sport A Community Building PartnershipSocial Media Sport A Community Building Partnership
Social Media Sport A Community Building PartnershipImpactiv8
 
Moho Pu’ Uwai Basket Ball Sport Complex
Moho Pu’ Uwai  Basket Ball Sport ComplexMoho Pu’ Uwai  Basket Ball Sport Complex
Moho Pu’ Uwai Basket Ball Sport ComplexCedric L. Chester
 
Architecture By Baseball
Architecture By BaseballArchitecture By Baseball
Architecture By BaseballLarry Clarkin
 
Ppt on stadium construction
Ppt on stadium constructionPpt on stadium construction
Ppt on stadium constructionLOKESH
 
Beijing National Stadium
Beijing National StadiumBeijing National Stadium
Beijing National Stadiumluisaam
 
Stadium Project
Stadium ProjectStadium Project
Stadium Projectlakvij
 

Viewers also liked (7)

Social Media Sport A Community Building Partnership
Social Media Sport A Community Building PartnershipSocial Media Sport A Community Building Partnership
Social Media Sport A Community Building Partnership
 
Moho Pu’ Uwai Basket Ball Sport Complex
Moho Pu’ Uwai  Basket Ball Sport ComplexMoho Pu’ Uwai  Basket Ball Sport Complex
Moho Pu’ Uwai Basket Ball Sport Complex
 
Architecture By Baseball
Architecture By BaseballArchitecture By Baseball
Architecture By Baseball
 
Sport Complex
Sport ComplexSport Complex
Sport Complex
 
Ppt on stadium construction
Ppt on stadium constructionPpt on stadium construction
Ppt on stadium construction
 
Beijing National Stadium
Beijing National StadiumBeijing National Stadium
Beijing National Stadium
 
Stadium Project
Stadium ProjectStadium Project
Stadium Project
 

Similar to We sport architecture_implementation

Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Red Hat Developers
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Training: Day Four - Struts, Tiles, Renders and Faces
Training: Day Four - Struts, Tiles, Renders and FacesTraining: Day Four - Struts, Tiles, Renders and Faces
Training: Day Four - Struts, Tiles, Renders and FacesArtur Ventura
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the TrenchesJonathan Wage
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Michael Plöd
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Mashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsMashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsBastian Hofmann
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012hwilming
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
Modules and injector
Modules and injectorModules and injector
Modules and injectorEyal Vardi
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortalJennifer Bourey
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play FrameworkKnoldus Inc.
 

Similar to We sport architecture_implementation (20)

Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Angular2 - In Action
Angular2  - In ActionAngular2  - In Action
Angular2 - In Action
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Training: Day Four - Struts, Tiles, Renders and Faces
Training: Day Four - Struts, Tiles, Renders and FacesTraining: Day Four - Struts, Tiles, Renders and Faces
Training: Day Four - Struts, Tiles, Renders and Faces
 
Mashing up JavaScript
Mashing up JavaScriptMashing up JavaScript
Mashing up JavaScript
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Mashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsMashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web Apps
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
Meteor iron:router
Meteor iron:routerMeteor iron:router
Meteor iron:router
 
Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Modules and injector
Modules and injectorModules and injector
Modules and injector
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 

We sport architecture_implementation

  • 3. User selects the sports he practices or would like to practice
  • 4. User selects places on map where practices the selected sports
  • 5. User selects his favourite days and time
  • 6. HomePage showing participants and events near the selected location
  • 7. January 2011, We-Sport is sponsor of "2011 IPC ALPINE SKIING WORLD CHAMPIONSHIPS"
  • 9. Spring configuration web.xml ... <servlet> <servlet-name>sports</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>sports</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping> ...
  • 10. SportController @Controller @RequestMapping("/sport") public class SportController extends AbstractController { @Autowired private SportsService sportsService; @Override @RequestMapping(method = RequestMethod.GET) protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { setParams(request); Sport sport = null; ModelAndView result = new ModelAndView(); sport = sportsService.findSportById(getSportId()); result.addObject("sport", sport); return result; } private void setParams(request){...} }
  • 11. Handle multiple output types <?xml..><beans ..."> <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map><entry key="json" value="application/json" /> <entry key="xml" value="application/xml" /> <entry key="pdf" value="application/pdf" /></map> </property> <property name="defaultViews"> <list> <bean class="com.sports.service.PDFPage" Spring 3 p:contentType="application/pdf" /> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> <bean class="org.springframework.web.servlet.view.xml.MarshallingView"> <constructor-arg> <bean id="castorMarshaller" ContentNegotiatingViewResolver class="org.springframework.oxm.castor.CastorMarshaller" /> </constructor-arg> </bean></list></property> </bean></beans> (sports-servlet.xml)
  • 12. Examples of API requests:
  • 13. RpcSportsServiceImpl public class RpcSportsServiceImpl extends AutoinjectingRemoteServiceServlet implements RpcSportsService { @Autowired private SportsService sportsService; public Sport findSportById(Long sportId) { return sportsService.findSportById(sportId); } // getters and setters of sportsService }
  • 14. AutoinjectingRemoteServiceServlet public abstract class AutoinjectingRemoteServiceServlet extends RemoteServiceServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(config.getServletContext()); AutowireCapableBeanFactory beanFactory = ctx .getAutowireCapableBeanFactory(); beanFactory.autowireBean(this); } }
  • 15. SportsServiceImpl public class SportsServiceImpl implements SportsService { @Autowired private SportDao sportDao; public Sport findSportById(Long sportId) { final String cacheKey = "findSportById_"+sportId; if (!getCache().contains(cacheKey) || getCache().get(cacheKey) == null) { getCache().put(cacheKey, sportDao.findById(sportId)); } return (Sport) getCache().get(cacheKey); } }
  • 16. DataStore Access - JDO <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" ....... default-lazy-init="true"> Spring 3 - JDOTemplate <context:component-scan base-package="com.sports.dao.jdo" /> <context:component-scan base- Configuration package="com.sports.server.servlet.filter" /> <bean id="sportsService" class="com.sports.service.SportsServiceImpl" /> (applicationContext.xml) <tx:annotation-driven /> <bean id="persistenceManagerFactory" class="com.sports.server.utils.GaePMF" factory- method="getPersistenceManagerFactory"> </bean> <bean id="transactionManager" class="org.springframework.orm.jdo.JdoTransactionManager"> <property name="persistenceManagerFactory" ref="persistenceManagerFactory" /> </bean> <bean id="jdoTemplate" class="org.springframework.orm.jdo.JdoTemplate"> <constructor-arg ref="persistenceManagerFactory" /> <constructor-arg value="false" type="boolean" /> </bean> </beans>
  • 17. BaseDaoJdo package com.sports.dao.jdo; import ... public abstract class BaseDaoJdo { @Autowired protected PersistenceManagerFactory pmf; @Autowired protected JdoTemplate jdoTemplate; @Autowired protected JdoTransactionManager transactionManager; }
  • 18. SportDaoJdo package com.sports.dao.jdo; import ... @Component public class SportDaoJdo extends BaseDaoJdo implements SportDao { public Sport save(Sport sport) { return jdoTemplate.makePersistent(sport); } @SuppressWarnings("unchecked") public Collection<Sport> findAll() { Object[] a = {}; return jdoTemplate.detachCopyAll(jdoTemplate.find("select from " + Sport.class.getName() + " order by name", a)); } }
  • 19. Cron + TaskQueue cron: - description: Update Sports Counter url: /api/cron/updateSportCounter cron.yaml schedule: every 24 hours
  • 20. UpdateSportCounter @Controller @RequestMapping("/cron/updateSportCounter") public class UpdateSportCounter { @Autowired private SportsService sportsService; @RequestMapping(method = RequestMethod.GET) public void execute(HttpServletResponse response) throws IOException { for (SportOutput sportOut : sportsService.findAllSports()){ final Long id = sportOut.getId(); final int counter = sportsService.getCountPlayersBySport(id); UpdateCounterSportTaskQueue.updateCounterSportTask(id, counter); } response.getWriter().write("Scheduled all taskqueues."); } }
  • 21. UpdateCounterSportTaskQueue public class UpdateCounterSportTaskQueue { public static void updateCounterSportTask(final Long id, final int counter) { TaskOptions taskOptions = TaskOptions.Builder.withUrl( "/api/task/updateCounterSport"); taskOptions.param("id", String.valueOf(id)); taskOptions.param("counter", String.valueOf(counter)); QueueFactory.getDefaultQueue().add(taskOptions); } }
  • 22. UpdateCounterSportWorker @Controller @RequestMapping("/task/updateCounterSport") public class UpdateCounterSportWorker { @Autowired private SportDao sportDao; @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.ACCEPTED) @Transactional(propagation = Propagation.REQUIRES_NEW) public void execute(@RequestParam long id, @RequestParam int counter) { Sport sport = sportDao.findById(id); sport.setCounter(counter); sport.setUpdatedDate(new Date()); sportDao.save(sport); } }
  • 23. Version Control - GIT Decentralization Distributed Version Control Systems take advantage of the peer-to-peer approach. Clients can communicate between each other and maintain their own local branches without having to go through a Central Server/Repository. Then synchronization takes place between the peers who decide which changesets to exchange.
  • 24. GIT + Dropbox I think that git on dropbox is great. I use it all of the time. I have multiple computers (two at home and one elsewhere) that I use dropbox as a central bare repo. Since I don't want to host it on a public service and I don't have access to a server that I can always ssh to, Dropbox takes care of this by syncing (very quickly) in the background. Setup is something like this: http://stackoverflow.com/questions/1960799/using-gitdropbox-together-effectively
  • 25. Thank you for your kind attention busy busy ...