Post on 25-May-2015
WELCOME!
Introduction in VMForce
by Alex KrukSkype: alexandrkrukEmail: alex.kruk@parx.com
PARX – Zurich
PARX – ABOUT US
Leading Google Enterprise and Salesforce.com consulting partner in German-speaking Europe
• comprehensive Cloud Computing Services from a single source
• services across the entire value chain: consulting, conception, specifications, development, implementation, training, support, project management
• offices in Zurich, Munich, Dusseldorf and Vienna
• founded in 1998
PARX – ABOUT US
Strategic alliances
• Google Enterprise Partner
• Salesforce.com Consultuing Partner
• Amazon Web Services, Box.net, GoodData & Signavio
• PARX was among the first salesforce.com, Google Enterprise, and Amazon Web Services partners in Europe
PARX – PORTFOLIO
PROGRESS... JOIN US
1960sMainframe
1980sOn-PremiseClient/server
TodayEnterprise Cloud
Computing
THE CLOUD COMPUTING MODEL
Multi-tenant
Automatic Upgrades
Pay-as-you-go
Real-time
5x Faster
SALESFORCE.COM
FORCE.COM - PAAS
FORCE.COM COMPONENTS
VMFORCE IS COMING?
DATABASE.COM SDK
• Use Database.com to store your application data
• Interact with data already written to Database.com
• Leverage the Database.com user security model to manage data access for your application
• Extend existing Force.com applications with Java logic
DATABASE.COM SDK COMPONENTS
• API Connector
• JPA Provider
• OAuth Authentication and Authorization
• Spring Security Plugin
• Spring MVC Project Template
• Code Generation Plugin
JPA PROVIDER
• Implements a subset of the JPA 2.0 specification
• Based on DataNucleus platform
• Supports most of DN annotations + some custom.
• Supports additional functionality (SOQL, etc.)
• Based on Web Services API and Metadata API
API CONNECTOR
<persistence-unit name="forceDatabase"> <provider>com.force.sdk.jpa.PersistenceProviderImpl</provider> <properties> <property name="datanucleus.storeManagerType" value="force" /> <property name="datanucleus.connectionURL" value="${CONN_URL}" /> <property name="datanucleus.autoCreateSchema" value="true" /> <property name="datanucleus.validateTables" value="false" /> <property name="datanucleus.validateConstraints" value="false" /> <property name="datanucleus.Optimistic" value="false" /> <property name="datanucleus.datastoreTransactionDelayOperations" value="true" /> <property name="datanucleus.jpa.addClassTransformer" value="false" /> <property name="datanucleus.cache.level2.type" value="none" /> <property name="datanucleus.detachAllOnCommit" value="true" /> <property name="datanucleus.copyOnAttach" value="false" /> </properties> </persistence-unit>
JPA PROVIDER
• Data types. Standard + custom (Phone, URL, etc.)
• Primary Keys. String, GenerationType.IDENTITY, non-composit.
• Relationships. @ManyToOne and @OneToMany
• Standard/Custom annotations
• Transactions
• Queries
• Limits
STANDARD/CUSTOM ANNOTATIONS
• Standard JPA annotations
• Custom JPA annotations
• @CustomObject (enableFeeds, readOnlySchema )
• @CustomField (childRelationshipName, description,
label, precision, scale, type, etc…)
• @PicklistValue
• @JoinFilter (alias="w", value="w.name LIKE 'Chateau
%'")
CREATING, UPDATING, AND DELETING DATA
EntityManagerFactory factory = Persistence.createEntityManagerFactory(persistenceUnitName);EntityManager em = factory.createEntityManager();
Albom anAlbom = new Albom();anAlbom.setName("ABC");
EntityTransaction tx = em.getTransaction();tx.begin();em.persist(anAlbom);tx.commit();
QUERYING WITH JPQL
EntityManagerFactory aFactory = Persistence.createEntityManagerFactory(persistenceUnitName);EntityManager em = aFactory.createEntityManager();
String aQuerySt = "SELECT acc FROM Account acc WHERE u.Name = :fName";
Query aQuery = em.createQuery(aQuerySt);aQuery.setParameter("fName", "noname");
List<Account> results = (List) aQuery .getResultList();
QUERYING WITH JPQL
• Bulk Delete and Queries
• JPQL Date (Temporal) Functions
• JPQL Joins• Implicit Joins• Explicit Joins (SELECT p FROM Parent p JOIN p.childs c WHERE c.name =
‘examp’)• IN Joins (SELECT p FROM Parent p IN (o.childs) c WHERE c.name = 'sample1')• Semi-Joins and Anti-Joins • Child-Map Joins• Relationship Joins (SELECT c FROM Child c WHERE c.Parent.name in
('Parent1', 'Parent2'))• MEMBER OF Comparison Operator
QUERYING WITH SOQL
Returning SObject Records
String aQS = "SELECT Email, Phone FROM Account WHERE Name = ‘Apple'";Query aQ = em.createNativeQuery(soqlQuery);List<SObject> results = q.getResultList();
Query aQuery = em.createNativeQuery(soqlQuery, User.class);List<User> results = aQuery.getResultList();
String aQS = "SELECT id, name, (SELECT id, Name FROM Parent_Childs__r)” + + “FROM Parent__c";
Query aQuery = em.createNativeQuery(aQS, Parent.class);List<SObject> results = aQuery.getResultList();ArrayList<ChildEntity> childs = (ArrayList<Child>) results.get(0).getChilds();
Returning Typed-Object Records
Relationship Queries
OAUTH AUTHENTICATION
<filter> <filter-name>AuthFilter</filter-name> <filter-class>com.force.sdk.oauth.AuthFilter</filter-class> <init-param> <param-name>url</param-name> <param-value>URL or a ${Java system property} or ${environment variable}</param-value> </init-param></filter><filter-mapping> <filter-name>AuthFilter</filter-name> <url-pattern>/*</url-pattern></filter-mapping>
OAUTH AUTHENTICATION
• Filter parameters• securityContextStorageMethod• secure-key-file• storeUsername• logoutFromDatabaseDotCom• logoutUrl
• Spring Security Support
OTHER
• Limits (DBDC, Force.com, SDK)
• Native connections
• Retrieving User Data
• Spring MVC Project Template
• Code Generation Plugin
BYE-BYE LAPTOP
HELLO WORLD
• Maven 3.0
• Get Force.com/Database.com instance.
• Open API access to user, get security token
• mvn archetype:generate -DarchetypeGroupId=com.force.sdk
-DarchetypeArtifactId=springmvc-archetype
• FORCE_FORCEDATABASE_URL=force://login.salesforce.com?user=test@ciklumjava.com^&password=mypassAndSS
• mvn tomcat:run-war
HELLO WORLD
• Add oAuth
• Add Entities files.
• Use Code Generation Plugin
• Perform SOQL/JPQL queries.
• Add/modify data using Transactions
• Founded in 2008,
• Initially PaaS for Ruby.
• Now supports Ruby, Node.js, Clojure, Python, and Scala.
• Since September 2011 supports Java.
WHAT DO WE NEED?
• Maven 3.0
• JDK 1.6+
• Heroku account
• Installed Heroku env. (inc. Git, Foreman)
• Java application built on Maven.
NEXT STEP
• Configure application using pom.xml
• Configure Procfile to declare how you want your application executed• web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT
target/*.war
• Run locally. “foreman start”
• “git add .”
• git commit -m “Are you sure???“
• heroku create --stack cedar
• git push heroku master
HEROKU IS AWESOME
• Built-for-Deployment Applications
• Version Control is the Central Distribution Mechanism.
• No Need to Externalize Configuration From Your Code
• Deployment is a Highly Automated Pipeline Process
• How do Applications use JEE APIs Without a Container?• Servlets and JSPs by Tomcat or Jetty.• JSF and other rendering frameworks by Mojarra or MyFaces• Mail services by SendGrid.• JDBC to connect to Heroku Postgres service or Amazon RDS• Hibernate or DataNucleus JPA to provide an ORM persistence
HEROKU IS AWESOME
• Deployment “git push heroku master”
• Start/Stop/Restart “heroku restart”
• Deployment of Changes
• Clustering (scaling) “heroku scale web=2 worker=4”
• Load-balancing
• Logging
SOMETHING ELSE ABOUT HEROKU
• Dyno???• Isolation by subvirtualization technologies• One request at a time• 512MB of memory• Web/worker dynos.• $0.05 per hour
• Payment• Dynos• Database• Add-ons
Database.com SDKHEROKU for Java
THANK YOU!
by Alex KrukSkype: alexandrkrukEmail: alex.kruk@parx.com