Your SlideShare is downloading. ×
  • Like
  • Save
Javascript Framework for Backend as a service- 1st Review
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Javascript Framework for Backend as a service- 1st Review

  • 687 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
687
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 1st Review JavaScript Framework for Backend as a service Ashwin Skantha S, Krishnan V, Mukundan S advised by Balasubramanian V SSN College of Engineering,Kalavakkam Jan 17, 2013Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 2. Abstract 1 Most of the web applications developed today use one or more of the cloud services available to store their data in an scalable manner. 2 Integrating these services into their web application is a highly cumbersome process. 3 It requires a thorough understanding of the providers architecture and SDK. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 3. Abstract We propose to create a JavaScript Framework 1 Brings together the most widely used cloud services 2 Provides all the server side functionality that the developers need to create rich web applications using the front end code itself. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 4. Overview Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 5. Existing Systems-Parse JavaScript Frameworks 1 Parse provides a proprietary Javascript framework for storing in their cloud (AWS database storage). 2 This framework is written by extending the functionalities provided by an open source framework known as Backbone.js. 3 On Parse, you create an App for each of your mobile applications. Each App has its own application id and JavaScript client key that you apply to your web app. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 6. Existing Systems-Parse JavaScript Frameworks 1 JavaScript SDK does not require any external libraries. The only exception is the Parse.View class, which requires that you provide jQuery or a jQuery compatible Dollar method 2 Has API functions for Objects, Collections Queries Users, Roles Facebook Users Error Handling 3 High level web applications can be created easily with Parse Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 7. Novel Idea 1 Providing an open source JavaScript framework for cloud storage with local object storage. 2 This framework allows the user to integrate with their own Cloud Service (Amazon/Google) account , hence removing any dependency the developer might have on any proprietary service provider. 3 This framework also provides API calls for maintaining data in Relational Database. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 8. Proposed System 1 An API using JavaScript is provided such that any web developer with knowl- edge in Javascript can use these API calls to utilize the power of cloud services. 2 Javascript is the most widely used language for client side processing in any web application.For this reason we extend available open source Backbone.js framework to include code for user authentication,object creation,specification of roles and ACLs,database querying and session storage. 3 Our proposed system provides a server side application as a middleware for communication between the front-end code and the cloud service. A server is needed by this framework only because Amazon/Google does not provide Javascript APIs for cloud database access. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 9. Modules Split-Up 1 First BackBone.js framework is extended to include Objects and Users. 2 The next part of the project involves addition of user authentication, adding roles and Access Control Lists ACLs 3 The next part involves Building up the server side application which accesses and stores data from AWS Database 4 The next part of the project includes addition of Querying capability to the JS Framework Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 10. Modules Split-Up 1 Next Error Handling capability is included. 2 Finally the project is made more generic by adding credentials and urls files and also by writing up automated configuration scripts for modifying them 3 The various modules that can be built include Objects, Collections Queries Users, Roles Facebook Users Error Handling Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 11. Detailed Design-Cross Origin Resource Sharing (CORS) At present none the above mentioned cloud providers allow CORS(Cross Origin Resource Sharing). There are three different methods to overcome this problem. They are 1 Using a server side proxy An AJAX call is made to the server side script on the same server. From the script HTTP request is made to required server. 2 Using JSONP This is only supported by a few browsers and is still under standardisation. 3 Using a Pre-Request Header The requesting page will first send the request to the required server with only the Header. The server will reply if the requesting client is allowed to access the resource. Then a normal request is sent to the server. This causes the network to be flooded with redundant requests. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 12. Detailed Design-Cross Origin Resource Sharing (CORS) 1 We use a CORS filter in our server side code to filter out the domain and the server from which the request originates thus hiding the fact that it has come from another domain. 2 We configure the server to accept all the incoming requests from any domain and thus we process the request normally. 3 Instead of sending the request data as JSON which is a security threat (browserwarning) we are using plain text which can be encrypted. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 13. Detailed Design-Cross Origin Resource Sharing (CORS) Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 14. Detailed Design-Models 1 The Backbone.js framework contains objects for Model, View and Collections. But the front-end structure provided by Backbone.js is not associated with any code in the backend. 2 As in any other MVC frameworks, Model is container to store data. Using the Model object provided by Backbone.js, we can extend and create new models with the same basic structure as provided by Backbone.js. Backbone.js provides 26 functions for the Model object. 3 Creating Model Normal Syntax to create a Model var M = Backbone.Model.extend ( properties,[classProperties] ) // Model Definition var L = new M() // Creating and Object of type M Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 15. Detailed Design-Models 1 Modified Syntax to create a Model and associate with back-end var M = Backbone.Model.extend ( className, properties, [classProperties] ) //Model Definition var L= new M() className - relates the current model to the back-end table associated with it. 2 Properties of Model Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 16. Model Properties-Save 1 Default Method When invoked, it checks if an attribute called id is present for the invoking model and then if present it sends a PUT AJAX call with the data in JSON format. If the attribute is not present then a POST AJAX call. The reply must also contain the request data in JSON format with the id attribute set and the model object is set automatically by Backbone.js using the parse method which cannot be called explicitly. 2 Modified Method We are not using JSON format for data transfer due to the security warnings issued by browsers. A separate intermediary method is written. If the className specified in the Model is not already present then that table is created automatically with all the specified attributes as varchar type. 3 Syntax model.save ( [attributes] , [options] ) options success,error etc. 1st Review Ashwin Skantha S, Krishnan V, Mukundan S
  • 17. Detailed Design-Collections Collections is an object offered by Backbone.js for easy manipulation of an array of objects. Around 34 methods are provided by Backbone.js for the Collections object of which we have modified few of the methods. 1 Creating Collections var L = Backbone.Collections.extend ( model:M ) var F = new L() Most of the methods have been rewritten so as to use plain text instead of the JSON format. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 18. Detailed Design-Queries,Views 1 Query This object is not provided by Backbone.js and is written from scratch. It allows the user to create a SQL type query which retrieves the data from the back-end in the form of Models based on the constraints. Multiple constraints can be given for the same query. Example constraints : equalTo, notEqualTo, greaterThan, lesserThan etc. var query = Backbone.Query (model) query.equalTo (key,value) query.fetch(success : function(collection), newline error : function(collection,errorcode)) 2 Views This is used to bind a HTML DOM element with the model so as to structure the Javascript code effectively. The View methods have not been modified and used as such. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 19. Detailed Design-Users This object is also not provided by Bakcbone.js. It extends Backbone.Model to provide functionalities such as 1 Sign Up 2 Log In 3 Current User (Session Maintenance) 4 Log Out HTML 5s local storage is used to maintain session. Syntax var user = Backbone.User () user.logIn(username : ,password : ,success : function (User) ,error : function ()) Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 20. Detailed Design-SMS 1 This provides a CORS enabled method to access the Twilio Cloud Service to send SMS message to any mobile phone. 2 Syntax var sms = Backbone.sms (key,auth) key,auth : Twilio Authorization and Authentication key sms.sendSms( from : 0000000000, to : 0000000000, body : , success : function (),error : function () ) Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 21. Detailed Design Back-End The programming language used for server side coding is Java.Frameworks used in the server : 1 Jersey/JAX-RS for restful web service 2 Apache HTTP Commons and HTTP Core Client Libraries for HTTP Request Response 3 Apache Jackson for JSON parsing 4 Maven for Twilio Cloud Service 5 Twilio Java SDK 6 CORS Filter 7 MySQL Connector Java Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 22. Scriptless Java Class 1 This is the only Java class which has access to the outside network. All the other classes are Plain Old Java Classes which are accessed from this class. This class uses Jersey Annotations to create the restful service and JAX-RS for parsing. 2 Base path for the Scriptless class is given using the annotation @Path(/..../....) 3 For different types of requests different Jersey annotations are given as required. For Example @GET, @PUT, @Consumes, @Produces 4 Each request is mapped to the corresponding method via the Jersey library and based on the request the operations are performed. 5 Data which is sent as text from the front-end is converted back to JSON for ease of use and the reply is again sent back as text. st Ashwin Skantha S, Krishnan V, Mukundan S 1 Review
  • 23. Helper Classes 1 ClassCreationDAO As of now this function is dependent on the front-end UI provided. When the user has to create a new table which is represented as a class object, he click on the control provided and enters the name of the class. An AJAX call is sent to the the Web Service Scriptless.java which then invokes this class which creates a table in the database based on the schema provided. 2 ClassManipulationDAO To change the schema of the table/class object, this is the class that is called which runs the required DDL commands on the database. 3 ClassQuerySearchDAO All the functionality provided in the Backbone.Query object is provided by this class. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 24. Helper Classes 1 ConnectionHelper This class helps to connect to the various cloud services. As of now this class is used to connect to the local MySQL database server. 2 NewClass This is a bean class for storing and accessing the schema of a new table. 3 TwilioSender This is the class which is accessed by the Backbone.sms object to send SMS message using the Twilio Cloud Services. Ashwin Skantha S, Krishnan V, Mukundan S 1st Review
  • 25. References 1 Brett Cannon - Automated object persistence for JavaScript 2 Parse JavaScript SDK Documentation. https://parse.com/docs/js/ 3 Amazon Web Services http://aws.amazon.com/ 4 HTML5 Web Storage http://dev.w3.org/html5/webstorage/ 5 Backbone.js http://backbonejs.org 6 Underscore.js http://underscorejs.org 7 Jersey Framework http://jersey.java.net 8 Twilio Cloud Services http://twilio.com 9 Jackson JSON Processor st Ashwin Skantha S, Krishnan V, Mukundan S 1 Review