1 / 33

Building Social Software on Top of Java EE 7 with DaliCore [CON4103]

Building Social Software on Top of Java EE 7 with DaliCore [CON4103]. Mission. In this session, you will learn how to use the open-source framework DaliCore in order to integrate social media concepts and information into (existing) Java Enterprise applications. Outline.

Download Presentation

Building Social Software on Top of Java EE 7 with DaliCore [CON4103]

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building Social Software on Top of Java EE 7 with DaliCore [CON4103]

  2. Mission In this session, you will learn how to use the open-source framework DaliCore in order to integrate social media concepts and information into (existing) Java Enterprise applications

  3. Outline 1. Java EE and Social media 2. Introducing DaliCore 3. Users, Content, OnlineAccount and demos 4. More functionality 5. Implementation Details

  4. Java EE 7 • Enterprise applications require an enterprise infrastructure • The Java EE 7 platform provides many of the required foundations for developing business applications (i.e. persistence, transactions, messaging) • Scalability and performance are best guaranteed using Java EE 7

  5. Social Software • Social Software is often seen as “nice to have” • Often isolated from the enterprise applications • Different departments inside a company • Really focuses on the end user, less on the company

  6. Why the combination? • Value obtained via social media can be huge • The infrastructure requirements for social software can be large (scalable and performant) • Common functionality (security, authentication) with intranet applications

  7. How to combine? • Isolated • Using JavaScript • Backend doesn't know who visited • Backend can't influence FB LIKES RETWEET Company website Company enterprise apps

  8. How to combine? • Integrated • Use the power of the social networks: the large amount of users and their interactions • Keep the added value inside your business application FB API Twitter API Company website Company enterprise apps

  9. DaliCore • A number of concepts and services that are often returning while developing social software • Integrated with Java EE 7 functionality in order to provide stability, performance, scalability and to provide an integrated developer experience • Open-source, contributing to different technologies (Jersey, WebSocket) • Influenced by many mistakes made by LodgON (aka lessons learned)

  10. DaliCore examples • Real-world examples: • musicians community, where bands and organizers of contests/festivals meet • Cultural project, where users gain points by attending cultural events and share this with their peers on Facebook/Twitter • Voting advice: users compare themselves with local politicians and facebook friends

  11. DaliCore examples • Voting sites, the numbers: • Peak moments: national news broadcast, 20K concurrent visitors (source: Google Analytics) • Total completed surveys: 1.5 million • Initial traction via traditional media • Later traction via social media (users can post their results on their timeline and invite friends to do the survey)

  12. DaliCore examples

  13. DaliCore Architecture • Clear separation between API and implementations • Third parties are building applications using the API and want to benefit from implementation enhancements without changing their application • Different project have different infrastructural requirements • Implementations differ in underlying technologies they use

  14. DaliCore API Services Implementation Storage Search Entities {User, Content, Group, Permission, OnlineAccount} Services JPA-SQL JPA-SQL Mongo Mongo ElasticSearch

  15. User Extendable class with basic, neutral properties: public class User extends DaliCoreData implements Principal, Serializable { private String screenName; private String firstName; private String lastName; private String email; private String password; private Long lastLoginDate; private String depiction; }

  16. UserService User create(User user) User update(User user); void setPassword(User user, String password); void delete(User user); User getByUid(String applicationKey, String uid) User getByScreenName(String applicationKey, String screenName) User getByEmail(String applicationKey, String email) User validateUidAndPassword(String applicationKey, String uid, String password) User validateScreenNameAndPassword(String applicationKey, String screenName, String password) User validateEmailAndPassword(String applicationKey, String email, String password) List<? extends User> findByType(String applicationKey, Integer type, Integer offset, Integer count); List<? extends User> search(String applicationKey, SearchParams searchParams);

  17. Example: create User • Web application (WAR) • Jsp with a form • REST Handler handling requests and talking to DaliCore services

  18. Example (show in netbeans) @ManagedBean @Path("user") public class UserHandler { @Inject UserService userService; @POST @Path("create") public Response createUser (@FormParam("name") String name , @FormParam("email") String email, @FormParam("password") String password) throws DaliCoreException {; User user = new User(); user.setEmail(email); user.setScreenName(name); User created = userService.create(user); userService.setPassword(created, password); System.out.println("Created: "+created); return Response.ok().build(); } …

  19. Example (switch to netbeans?) … @POST @Path("validate") public Response validateUser(@FormParam("email") String email, @FormParam("password") String password) throws DaliCoreException { System.out.println("email = "+email+" and pwd = "+password); User me = userService.validateEmailAndPassword("", email, password); System.out.println("Validated? "+me); return Response.ok().build(); } }

  20. OnlineAccount • Some projects require specific user accounts • Other projects do not want any user information and rely on social media users • Most projects want to combine information in a social network with project-specific information • The OnlineAccount class links a specific user of a specific social network with an extendable DaliCore User

  21. OnlineAccount • Show java code

  22. OnlineAccount • SocialHandler facilitates the authentication flow for external networks • OnlineAccount is created when a user uses the service the first time • Optionally, a coupling with DaliCore User is created • Built-in support for Twitter, Facebook, Google+ and LinkedIn • Extendable: • ExternalNetworkLocator can be injected

  23. Content • Public class Content {...} • Contains some basic fields (e.g. title, content, score) • Type field (extendability) • Relational fields: • author (User) • Parent (Content) → allows hierarchical services

  24. ContentService public interface ContentService { Content create(Content content) throws DaliCoreException; Content update(Content content); void delete(Content content, boolean cascade); Content getByUid(String applicationKey, String uid) throws DaliCoreException; Content getByUid(String applicationKey, String uid, FetchType fetchType) throws DaliCoreException; Long countByType(String applicationKey, Integer type); List<? extends Content> findByType(String applicationKey, Integer type, Integer offset, Integer count, FetchType fetchType); List<? extends Content> findByAuthor(User author, Integer type, Integer offset, Integer count, FetchType fetchType); List<? extends Content> findByGroup(Group group, Integer type, Integer offset, Integer count, FetchType fetchType); List<? extends Content> findByParent(Content parent, Integer type, Integer depth, Integer offset, Integer count, FetchType fetchType); List<? extends Content> search(String applicationKey, SearchParams searchParams, FetchType fetchType); }

  25. Content Demo • Authenticated User can create Content • Authors of Content can remove their content • Authenticated User can add comment to Content • Root Content → type 1 • Comment Content → type 2

  26. Voting • Vote on Content • Decide how to manipulate scores

  27. Voting DEMO

  28. We didn't cover Content.parent allows for hierarchical trees, not for graphs → use Group for graphs Entities (User, Content, Group) are extendable via Fields • Permissions. • Can be assigned to user, group, content. • DaliCore does not define a policy model, but allows the applications to define one

  29. We didn't cover (2) Content-integration with social networks: ExternalNetwork interface defines basic functionality that is implemented by e.g. TwitterExternalNetwork, FacebookExternalNetwork • GetFriends() • getStream()

  30. Implementation Requirements • Performance • Scalability • Modularity • Multi-tenancy

  31. Multi-tenancy • Use the same infrastructure for a number of projects • Each Entity has an ApplicationKey • All Services allow to check on Application Key • Each project has an isolated storage

  32. Internals Service implementations rely on storage and serach services stateless UserServiceImpl UserStorage UserSearch JPA-SQL JPA-SQL Mongo Mongo ElasticSearch

  33. More information • Java EE 6 based code on java.net: http://java.net/projects/dalicore Java EE 7 based code on bitbucket: http://lodgon.com Twitter: @johanvos johan@lodgon.com

More Related