Supporting Multi-tenancy Applications with Java EE



Similar documents
Liferay Enterprise ecommerce. Adding ecommerce functionality to Liferay Reading Time: 10 minutes

Arjun V. Bala Page 20

<Insert Picture Here> Java EE 7: the New Cloud Platform

Java EE 6 New features in practice Part 3

Managing Data on the World Wide-Web

Ch-03 Web Applications

Web Development in Java Live Demonstrations (Live demonstrations done using Eclipse for Java EE 4.3 and WildFly 8)

<Insert Picture Here> Java EE 7: the New Cloud Platform

Servlet and JSP Filters

Servlet 3.0. Alexis Moussine-Pouchkine. mercredi 13 avril 2011

Aspects of using Hibernate with CaptainCasa Enterprise Client

Accelerated Java EE Open Source Development with Eclipse CON1905

Integration of Shibboleth and (Web) Applications

An introduction to creating JSF applications in Rational Application Developer Version 8.0

JSR-303 Bean Validation

How to Integrate and Extend Oracle CON3755. Gary Williams Principal Curriculum Developer Mobile Cloud Applications October 2014

Java Servlet 3.0. Rajiv Mordani Spec Lead

Systems Integration in the Cloud Era with Apache Camel. Kai Wähner, Principal Consultant

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

<Insert Picture Here> Michael Hichwa VP Database Development Tools Stuttgart September 18, 2007 Hamburg September 20, 2007

Framework Adoption for Java Enterprise Application Development

This module provides an overview of service and cloud technologies using the Microsoft.NET Framework and the Windows Azure cloud.

Visa Checkout September 2015

Rapid Application Development. and Application Generation Tools. Walter Knesel

Mind The Gap! Setting Up A Code Structure Building Bridges

Java EE 6 development with Eclipse, Netbeans, IntelliJ and GlassFish. Ludovic Champenois Oracle Corporation

Developing an EJB3 Application. on WebSphere 6.1. using RAD 7.5

Spring 3.1 to 3.2 in a Nutshell. Sam Brannen Senior Software Consultant

<Insert Picture Here> Java EE 7. Linda DeMichiel Java EE Platform Lead

IT Exam Training online / Bootcamp

JMS 2.0: Support for Multi-tenancy

The Java EE 6 Platform. Alexis Moussine-Pouchkine GlassFish Team

Spring Security SAML module

White Paper: Why Upgrade from WebSphere Application Server (WAS) v7 to v8.x?

Web Applications. For live Java training, please see training courses at

Single Sign On. SSO & ID Management for Web and Mobile Applications

XAP 10 Global HTTP Session Sharing

EclipseLink. Solutions Guide for EclipseLink Release 2.5

IBM Proof of Technology Discovering business application services, featuring IBM WebSphere Application Server Network Deployment V8

Java EE 6 Ce qui vous attends

Complete Java Web Development

Introduction to Oracle Mobile Application Framework Raghu Srinivasan, Director Development Mobile and Cloud Development Tools Oracle

JVA-122. Secure Java Web Development

The Great Office 365 Adventure

SOA, case Google. Faculty of technology management Information Technology Service Oriented Communications CT30A8901.

Hibernate Language Binding Guide For The Connection Cloud Using Java Persistence API (JAP)

Oracle im Open Source Kontext Abgrenzung GlassFish vs. JBoss und wozu noch WebLogic?

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

The Oracle Fusion Development Platform

How To Write A Web Framework In Java

PicketLink Federation User Guide 1.0.0

Thomas Röthlisberger IT Security Analyst

<Insert Picture Here> Oracle Application Express 4.0

A Standards-based Mobile Application IdM Architecture

Querying Massive Data Sets in the Cloud with Google BigQuery and Java. Kon Soulianidis JavaOne 2014

Cloud Application Development (SE808, School of Software, Sun Yat-Sen University) Yabo (Arber) Xu

Customize Mobile Apps with MicroStrategy SDK: Custom Security, Plugins, and Extensions

Recommended JSF Enhancements

Hadoop Streaming coreservlets.com and Dima May coreservlets.com and Dima May

HOL9449 Access Management: Secure web, mobile and cloud access

Tomcat Servlet/JSP Reference Implementation

Web Anwendungen Entwickeln mit JSF, Spring und Tomcat

OpenLogin: PTA, SAML, and OAuth/OpenID

Safewhere*Identify 3.4. Release Notes

Keycloak SAML Client Adapter Reference Guide

GOA365: The Great Office 365 Adventure

Intellicus Single Sign-on

ITG Software Engineering

Advanced Java Client API

Xiaoming Gao Hui Li Thilina Gunarathne

Course Summary. Prerequisites

Advanced OpenEdge REST/Mobile Security

Copyright Pivotal Software Inc, of 10

What s new in Spring 3.1?

Developing modular Java applications

APAC WebLogic Suite Workshop Oracle Parcel Service Overview. Jeffrey West Application Grid Product Management

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

CHAPTER 9: SERVLET AND JSP FILTERS

Course Number: IAC-SOFT-WDAD Web Design and Application Development

The Google Web Toolkit (GWT): The Model-View-Presenter (MVP) Architecture Official MVP Framework

Securing JAX-RS RESTful services. Miroslav Fuksa (software developer) Michal Gajdoš (software developer)

Load Testing Ajax Apps using head-less browser tools. NoVaTAIG April 13, 2011 Gopal Addada and Frank Hurley Cigital Inc.

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

You Are Hacked End-to-End Java EE Security in Practice. Karthik Shyamsunder, Principal Technologist Phani Pattapu, Engineer

Understanding class paths in Java EE projects with Rational Application Developer Version 8.0

Python and Google App Engine

PA165 - Lab session - Web Presentation Layer

The Java EE 7 Platform and Support for the PaaS Model

White Paper. JavaServer Faces, Graphical Components from Theory to Practice

EclipseLink. Developing Persistence Architectures Using EclipseLink Database Web Services Release 2.5. April Beta Draft

JBoss Seam Performance and Scalability on Dell PowerEdge 1855 Blade Servers

<Insert Picture Here> Oracle Mobile Enterprise Application Platform Overview

ACM Crossroads Student Magazine The ACM's First Electronic Publication

Transcription:

Supporting Multi-tenancy Applications with Java EE Rodrigo Cândido da Silva @rcandidosilva JavaOne 2014 CON4959

About Me Brazilian guy ;) Work for Integritas company http://integritastech.com Software Architect Java Platform JUG Leader of GUJavaSC http://gujavasc.org Twitter @rcandidosilva Personal http://rodrigocandido.me

Agenda Cloud Services Model SaaS Market Multi-tenancy Challenges Pros and Cons Implementation Types Java EE + Multi-tenancy Security + Multi-tenancy Cloud + Multi-tenancy Multi-tenancy at JVM

Cloud Services Model

SaaS Market

Multi-tenancy One application instance to multiple clients (tenant) Inverse of the multiple instances architecture

Multi-instances vs. Multi-tenant

Cloud!= Multi-tenancy

Challenges Data separation UI and business rules customization Access control by tenant Resource provisioning Integration Application update Failover tolerance

Pros and Cons Pros Low maintenance cost Same source code for all customers High scalability Sharing resources between customers Cons High complexity Separation by tenant-id More failure risks If code breaks -> breaks to all customers Low flexibility available to the customers

Multi-tenancy Implementation levels Level 1 (Customized) [N] applications and [N] databases Level 2 (Configurable) [1] application and [N] databases Level 3 (Efficient) [N] applications and [1] database Level 4 (Scalable) [1] application and [1] database

Level 1 - Customized [N] applications and [N] databases

Level 2 - Configurable [1] application and [N] databases

Level 3 - Efficient [N] applications and [1] database

Level 4 - Scalable [1] application and [1] database

Java EE + Multi-tenancy Database JPA + Multi-tenancy Customized UI JSF + Multi-tenancy Security Java EE 8 with Cloud support

JPA + Multi-tenancy EclipseLink Multi-tenancy support using @Multitenant Multitenant strategies @Multitenant(SINGLE_TABLE) default @Multitenant(TABLE_PER_TENANT) @Multitenant(VPD) Shared Cache by tenant

EclipseLink SINGLE_TABLE @Entity @Table(name= EMP ) @Multitenant(SINGLE_TABLE) @TenantDiscriminatorColumn(name = TENANT_ID, contextproperty = tenant-id ) public class Employee {... } HashMap properties = new HashMap(); properties.put("tenant.id", "707");... EntityManager em = Persistence.createEntityManagerFactory( "multi-tenant,properties).createentitymanager(); <persistence-unit name="multi-tenant">... <properties> <property name="tenant.id" value="707"/>... </properties> </persistence-unit>

EclipseLink TABLE_PER_TENANT <entity class="employee"> <multitenant type="table_per_tenant"> <tenant-table-discriminator type="schema" contextproperty="eclipselink.tenant-id"/> </multitenant> <table name="emp">... </entity> @Entity @Table(name= EMP ) @Multitenant(TABLE_PER_TENANT) @TenantTableDiscriminator(type=SCHEMA, contextproperty="eclipselink.tenant-id") public class Employee {... }

EclipseLink VPD <properties> <property name="eclipselink.session.customizer" value="example.vpdsessioncustomizer" /> <property name="eclipselink.session-event-listener" value="example.vpdsessioneventadapter" /> <property name="eclipselink.jdbc.exclusive-connection.mode" value="always" /> </properties> CALL DBMS_RLS.ADD_POLICY ('SCOTT', 'TASK', 'todo_list_policy', 'SCOTT', 'ident_func', 'select, update, delete')); @Entity @Multitenant @TenantDiscriminatorColumn(name = "USER_ID", contextproperty = "tenant.id") @Cacheable(false) public class Task implements Serializable {...

JPA Caching Shared Cache disabled

JPA Caching Shared Cache by tenant

JSF + Multi-tenancy Flexible software architecture Artifacts packaged in separated JAR s Composition at runtime Templates and contracts Resource library Look-and-feel customization RenderKit support Localization support

JSF Facelets Template File name _template.html Site Navigation The Facelets Gazette Insertion points Events Docs Forums About Contact Site Map Resources css classes, scripts, images

JSF Multi-templating <web-app-root>/contracts contracta Declared contractb Templates Declared Insertion Points Declared Declared contractc Resources Templates Declared Insertion Points Declared Declared Resources Templates Declared Insertion Points Declared Resources JAR files in WEB-INF/lib contractd Declared contracte Templates Declared Insertion Points Declared Declared contractf Resources Templates Declared Insertion Points Declared Declared Resources Templates Declared Insertion Points Declared Resources <web-app-root>/contracts JAR files in WEB-INF/lib contracta Declared contractb Templates Declared Insertion Points Declared Declared contractc Resources Templates Declared Insertion Points Declared Declared Resources Templates Declared Insertion Points Declared Resources contractd Set of available contracts Declared contracte Templates Declared Insertion Points Declared Declared contractf Resources Templates Declared Insertion Points Declared Declared Resources Templates Declared Insertion Points Declared Resources faces-config.xml Facelet 1 Facelet 2 Facelet 3

JSF Multi-templating <html xmlns="http://www.w3.org/1999/xhtml xmlns:h="http://java.sun.com/jsf/html xmlns:ui="http://java.sun.com/jsf/ facelets"> <body> <ui:composition template="#{template} >... </ui:composition> </body> </html> <?xml version="1.0" encoding="utf-8"?> <web-app> <context-param> <param-name>javax.faces.view.template</paramname> <param-value>mybusiness</param-value> </context-param> </web-app>

Security + Multi-tenancy PicketLink Java EE security framework Identity Management (IDM) Federation support (SAML, OAuth2, OpenID) Social Login support Multi-tenancy support

Picketlink

Picketlink @Named public class RealmSelector implements Serializable { @Inject private PartitionManager partitionmanager; private Realm realm; } @Produces @PicketLink public Realm select() { return this.realm; } @RequestScoped public class LoginController { @Inject private Identity identity; public String login() { this.identity.login(); } } public String logout() { this.identity.logout(); return "/home.xhtml"; } public class Resources { public enum REALM {acme, umbrella, wayne} @Produces @Named("supportedRealms") public Enum[] supportedrealms() { return REALM.values(); }

Cloud + Multi-tenancy Namespace API com.google.appengine.api.namespacemanager Cloud services support Google Datastore Memcached Task Queue Search

Namespace API // Assuming there is a logged in user. namespace = UserServiceFactory.getUserService().getCurrentUser().getUserId(); NamespaceManager.set(namespace); // Filter to set the Google Apps // domain as the namespace. public class NamespaceFilter implements javax.servlet.filter { @Override public void dofilter(servletrequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { // Make sure set() is only called if the current namespace is not already set. if (NamespaceManager.get() == null) { NamespaceManager.set(NamespaceManager.getGoogleAppsNamespace()); } } } <filter> <filter-name>namespacefilter</filter-name> <filter-class>package.namespacefilter</filter-class> </filter> <filter-mapping> <filter-name>namespacefilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

Namespace API Search // Set the current namespace to "aspace" NamespaceManager.set("aSpace"); // Create a SearchService with the namespace "aspace" SearchService searchservice = SearchServiceFactory.getSearchService(); " Memcached // Create a MemcacheService that uses the namespace "abc". MemcacheService explicit = MemcacheServiceFactory.getMemcacheService("abc"); explicit.put("key", value); // stores value in namespace "abc" " Task Queue // Increment the count for the current namespace asynchronously. QueueFactory.getDefaultQueue().add( TaskOptions.Builder.url("/_ah/update_count").param("countName", "SomeRequest"));

Demo Java EE Multi-tenancy sample

Questions?

References http://msdn.microsoft.com/en-us/library/aa479086.aspx https://developers.google.com/appengine/docs/java/multitenancy/ http://www.ibm.com/developerworks/java/library/j-multitenant-java/index.html http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_multitenant.htm http://2012.con-fess.com/sessions/-/details/122/jsf-and-javaee-7-for-multi-tenantapplications http://jdevelopment.nl/jsf-22/ http://picketlink.org https://developers.google.com/appengine/docs/java/multitenancy/ http://www.jboss.org/quickstarts/picketlink/picketlink-authentication-idm-multi-tenancy/ http://wiki.eclipse.org/eclipselink/examples/mysports

Thank you! @rcandidosilva rodrigocandido.me