Spring BOOT Notes

 PROJECT FLOW

  1.  Ask Questions after getting screen Requirements, raise points you don’t know.
  2.  SVN update daily basis.
  3.  Code always start from init() method.
  4.  Install – Node.js than GRUNT – package.json in a project must be there before running GRUNT command.
  5.  GRUNT Commands in CMD – grunt, grunt build, grunt watch.
  6.  Authentication token fail – code mismatch, we write the code using SVN backup – SNDVIVA project – BaseApplication.java – Run.
  7.  If setting new SVN project, maven clean and install, build. grunt not working – copy – node and node-modules folder and paste.
  8.  Redis DB used for storing cache to Database, written in application.properties.
  9.  _Template – less used. JS/Template.js – converts HTML to JS(String) function. _methods internal work.
  10.  Repository class don’t use SND keyword for Repository table name, use only in Entity and POJO.
  11.  After project refresh JS->controllerOrg.js shift the file to scripts folder.
  12.  Flow of auto drop-down data : (in js append(method) example refer) PaymentDialog.js(Receipt DialogTemplate.html) => this.loadBanks(); => $.extend({banks:this.banks}, this.options.data);
  13.  Calls Table field value from Repo class.
  14.  Bundle shows list of inventory in future it will sale using Bundle. Sim, Wrapper, Phone.
  15.  Mapping in between the tables, just like zone tables SalesChannel.
  16.  DATA ERROR – modify the table values to meet the requirements.

SND WORKFLOW

1. Vendor(Apple, Samsung, Sim) -> WareHouse(Telcom) -> Distributor -> Fos -> Seller.
2. Inventory -> Serialized(Y) and Non-Serialized(N).
snd_inventory_master -> Auto_Renewal_flag(Y,N)

snd_inventory_master.inventory_type_id = snd_inventory_detail.inventory_type.
snd_inventory_status_master – contains the status of SIM, where it is right now.

Inventory Sales Channel – virtual shop –
snd_user_detail
snd_user_login_detail
snd_sales_channel

* in snd_inventory_detail, retailer return to fos or distributor and after approval by upper management table fields should be null(retailer_id, fos_id, distributor_id).

* Inventory Master -> products insert.

PO
distributor -> via system raise -> to Warehouse.
Distributor -> inventory allocation -> FOS/Seller/Retailer.

Status of Inventory Transfer in Zain:
Inventory Allocation
Inventory Transfer
Inventory Return
Inventory WriteOff
Inventory Reverse WriteOff

+ security user create user after that we have to map user via saleschannel to make it approve.
+ User creation -> Workflow(request approval) -> Finance -> Area Manager -> Distributor -> FOS -> Retailer
request goes from lower to upper management.

+ Assemble – bundle order with new serial number by merging bundle products serial numbers. unable to transfer single product using serial no.
+ DeAssemble – single serail number, converting from Assemble to DeAssemble. Able to transfer single product using serial no.

JAVA

  1. By-default, Spring-Boot will use no context-path, and the default port would be 8080, means your application would be available at localhost:8080.
  2. Static resources like images/css/JS in a Spring boot application are commonly located in a directory called /static (or /public or /resources or /META-INF/resources) in the classpath.
  3. SND_DEALER_ZONE_MAPPING – dealer zone details – Governate – area – block.
  4. workflow – status – 0(new pending), 100(Approved) and -1(rejected).
  5. Always start the grunt (grunt build).
  6. When to use @Entity and @Table in a class – when using simple POJO classes (call only class without Annotation), if creating Entity than have to mention @Entity and @Table.
  7. API Calling and using 3rd party API.
  8. Refresh the project than grunt build – show the JS changes to Browser.
  9. @RequestBody – in controller.java {multidimensional Array Value}, service.js – data is in body.
  10. create a separate POJO and setting the form data in POJO than in serviceImpl.java – getting via for() loop and setting in TableEntity.
  11. warning or error for throw error add try catch block.
  12. Date variable POJO is in String format than parse(String).
  13. set the primary key from D.B. Table auto increment if getting error setting @Id in Entity.
  14. No need to repeat the classes POJO if already define.
  15. AjaxHandler.js -> under common folder define sendRequest() and SendRequestWithData() methods, GET, DELETE, PUT, POST method calls.
  16. Resources folder contains static things.
  17. Compiler compile and runs scripts folder of code.
  18. Never use e.printStackTrace(e); // it will not show the error msg use Logger to print the error to log file.
  19. If value is not going accurately, insert hard coded values.
  20. Debug Error – compile time – windows -> preferences -> java -> compiler -> check -> class file Generation.
  21. While Debug some machine process id’s also pass.
  22. Naming Convention should be take care and relative to the column name and business. Entity Bean – class name should be table name and column name as data member. eg: Table – SND_Customer_SAF should be written as (remove “_” as per the java rule).
  23. Clean the code and extra code remove(S.O.P and console.log()), before handing over.
  24. for updating or select passing one variable condition, we call the Entity Repo method only, for more than one conditions, we write Query.
  25. Serialization UID – used in serialization.
  26. Browser side debug – F8(move out) + F10(move next line).
  27. LOGGER.INFO() – shows the output to console.
  28. How to get the value from the List<EntityClass>? – Using the for(loop) and getEntityMethod().
  29. Convert object to String – using toString().
  30. CrudRepository<EntityTableName, PrimaryID> – contains methods save(S entity), save(Iterable<S> entities), findOne(ID id), exists(ID id), findAll(), findAll(Iterable<ID> ids), count(), delete(ID id), delete(T entity), delete(Iterable<? extends T> entities), deleteAll().
  31. 500 Error – NullPointerException (log path and file) check.
  32. Debug the project only in Java mode in Debug mode.
  33. Error Handling – Logger.info(“Error message”); throw new RuntimeException(“Error message”);
  34. JS debug from browser side and Java debug from Debugger – IDE.
  35. get[0] – get 1st index value, if getting error in Array.
  36. Where we are using POJO – toString();
  37. for S.O.P(POJO class) – print all data super class method.
  38. What code to place inside of try catch block – code which performs DB operation and calculations.
  39. java when to use exception handling => when we are performing any DB operation of calculation, keep in try catch block.
  40. nullPointer exception => when the variable does not assign any value.
  41. What is SerialVersionUID => During serialization, java runtime associates a version number with each serializable class. This number called serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization.
  42. join query code example in clusterMapping module – write in serviceimpl.java.
  43. Java8 Stream
    iterate over a list of objects stream and hold it to the different object stream.
    List<ZoneTypeDetail> clusterList = sndZoneTypeDetail.stream().map(e -> {
    ZoneTypeDetail zm = zoneTypeDetailServiceImpl.entityToBean(e);
    return zm;
    }).collect(Collectors.toList());
    java.util.stream.Collectors;
    java.util.stream.StreamSupport;

    Stream methods
    map() – converts an list of object stream to different object stream.
    collect() – get stuff out of stream. uses Collector interface toList() method.
    Stream.of() – create a stream from individual objects using Stream.of().
    filter() – it filters the stream depending upon certain conditions.
    findFirst() – returns the first stream.
    flatMap() – flatten the data structure to simplify further operations.
    peek() – is an intermediate operation.
    sorted() – sort the elements depending upon the comparator passed.
    min() & max() – returns minimum and maximum element in the stream.
    distinct() – eliminates duplicates and return the stream.

JS

  1. Refer previous code of flow to implement.
  2.  Folder -> JS -> common -> index.min.js, BaseView.js use for new screen.
  3.  Every modules have separate folders.
  4.  ControllerOrg.js (Org – identify main class in require.js).
  5.  Under ControllerOrg.js – var variableName loads runtime And dependencies (services.js and details.js(secondary screen code)) loads compile time.
  6.  JavaScript is Asynchronous – single event call (not wait for the same method getting the data from DB, start executing next line code.).
  7.  Why we use Callback in JS function. – Too complete the one process 1st than next line code execute in DB operation.
  8.  Using this.method() – makes the JS Synchronous (not move next line unless it completes).
  9.  JS Prototype (contains predefined methods, just like object class) – inheritance.
  10.  Promise use nesting URL calling (URL1 -> URL2 -> URL3). Promise – internal methods call for .done(), .error(last define like catch).
  11.  .map() and foreach() methods is used to fetch the Array list of data not a single object. And populate.js is used for populate the data.
  12. var cgiList=[]; // creating array.
  13.  Exception Handle in Project – ErrorHandler.js.
  14.  JQuery – PopUp – modal(“show”);
  15.  BaseViewWithForm.js – contains JS code of setting and getting data.
  16.  BaseViewWithFormNew.js – init() form method.
  17.  enableRowClick() -> RowClick() -> fieldinitializer.writeFormFields(); – in JS to able to edit on click of Row.
  18.  Generic DropDown – code of dropdown values code auto.
  19.  Field initializer – contains code of drop down values code auto in JS file.
  20.  chainTo() – to set drop down dependency via <select> tag in JS file.
  21. BaseController.call(this, “gpsMapBtn”, “clusterGPSMapFormDiv”,
    “closeDetailBtn”, “mapCgiInsert”, “clusterGPSMapTableDiv”,
    “clusterGPSMapFormDiv”, “clusterCGIMapTable”);BaseController.call(this, “addButtonId”, “FormIdtoSubmit”, “closeButtonId”, “formSubmitButtonId”, “divIdofwholeForm”, “form1Id”, “formTableId”);
  22. ClusterMappingController.prototype.init = function () {}
  23. _this.excelToJson = new ExcelToJson.ExcelToJson(“safFileUpload”);
  24. e.preventDefault(); //preventDefault() cancel the event either form submit or <a> link.
  25. $(‘#showDivGpsSingle’).addClass(‘hidden’);
  26. $(“#uploadSafBtn”).removeClass(‘disabled’);
  27. if ($(option).hasClass(‘ALL’)) {}
  28. .show();
  29. gpsFiles.push(entry); //push each entry in gpsFiles array.
  30. console.log(JSON.stringify(callBack)); //print the json response data.
  31. toastr.success();
  32. toastr.remove();
  33. toastr.warning(‘Enter all the details!!!’,’Warning’);
  34.  ViewResolver.refreshPage(); // in JS refresh the page.
  35. $(‘#clusterMapId’).empty();
  36. dialog.confirm();
  37. mediator.subscribe(‘clusterGPSMapTable_PreEditor’, function(object, row, column){}
  38. mediator.subscribe(‘clusterGPSMapTable_Validator’, function(e, object, row){}
  39. mediator.subscribe(‘clusterGPSMapTable_Deletor’,function(object, row){}
  40. mediator.subscribe(‘clusterGPSMapTable_Updator’, function(object, row, column){});
  41. _this.masterTable.destroy();
  42. ClusterMappingController.prototype.destroy = function () {}
  43. #id.text() // get the name of file connected with id.
  44. $(‘#downloadErrorLink’).attr(‘href’,’master/distributor/downloadBulkSafError/’+callBack); // adds the link to particular <a> tag id.
  45. var clusterId = $(‘#clusterId’).val(); // .val() get the value of id.
  46. $(‘#clusterMapId’).append(options); // adds the options tag values to particular select tag #clusterMapId.— // getting the callback with data and setting in Table.
  47. _this.service.loadClusterCgiByClusterId(clusterId, function(clusterCgiList) {
    $(‘#parent’).attr(‘required’,false);
    _this.cgiList=[];
    console.log(‘Preparing CGI List.’);
    _this.cgiList = clusterCgiList.map(r => {
    let obj = $.extend({}, r);
    obj.id = r.id;
    obj.clusterId = r.zoneDesc + ” (” + r.zoneCode + “)”;
    obj.cgiId = r.cgiId;
    obj.cgiDescription = r.cgiDescription;
    obj.startDate = r.startDate;
    obj.endDate = r.endDate;
    obj.clusterName = r.clusterName;
    $(‘#parent’).attr(‘required’,true);
    return obj;
    });
    console.log(‘Prepared CGI List successfully.’,_this.cgiList);
    _this.createMapTable(_this.cgiList,’cgi’);
    });
  48. //with in a table provide operation functionality:
    “editEnabled”: true,
    “deleteEnabled”: true,
    “addEnabled”: false,
    “enableRowClick”: true
  49. var ajaxHandler = require(‘AjaxHandler’); //ajaxHandler.sendRequestWithData() and ajaxHandler.sendRequest();
  50.  fieldsInitializer – contains group of methods for calling and getting or updating the records.
  51. chainedTo – $(“#menu2_District”).chainedTo(“#menu2_Province”); // used for dependency of dropdown.
  52. RESTFUL Resources
    REST – designing networked applications. REST uses HTTP for all four CRUD. REST is done through a URL. Use a Uniform Resource Identifier(URI). It uses :
    GET method – get or list the resources.
    POST method – create a resource.
    PUT method – update or replace a resource.
    DELETE method – removing the resource.
    @PathVariable – for parameterized URL’s that have variable input as part of their path. eg: http://localhost:8080/SND/Distributor/saf/12 <- @PathVariable
    @RequestBody – To receive the data as an object, the handler method parameter is annotated with @RequestBody. eg: public void getSafNo(@RequestBody String safNo)
    + with GET resource no need to use sendRequestWithData, sendRequest also pass data.
  53.  _this.showSecondaryPage(“”); //show secondary screen on click of edit or button(refer sample code).

SPRING BOOT PROJECT

  1. S.No. Tables Description
    1 SND_CUSTOMER_SAF_TRANS entry of SAF details.
    2 SND_MENU_DETAIL entry of menu manually.
    3 SND_ROLE_MENUS entry of menu manually.
    4 SND_CLUSTER_GPS_MAP entry of clustter mapping GPS data via excel.
    5 SND_CLUSTER_CGI_MAP entry of clustter mapping CGI entry via form.
    6 SND_SALES_CHANNEL_MASTER entry of sales channel entry.
    7 SND_INVENTORY_DETAIL contains inventory details.
    8 SND_SALES_CHANNEL_USER_MAP entry of sales channel users.
    9 SND_INVENTORY_MASTER get product names with ID, inventory_type, inventory_subtype.
    10 SND_SALES_CHANNEL_SIM_INFO get mobile_no for API sending.
    11 SND_SALES_ORDER_MASTER get POSORDERID, POS fields.
    12 TAX_PLAN_ASSIGNMENT get Tax details fields.
    13 SND_VTU_Accounts for invSubType=”L”, value greater Balance.
    14 SND_User_detail zone, subType, user_id, address fields available.
    15 SND_User_login user_id, user_password fields available.
    16 FDS_M_MODULE_PARAM entry of username and password.
    17 SND_PARTNER_PERIODIC_QUOTA Quota adjustment entry, status, payment method, Quota where dealer_id = 132.
    18 SND_ZONE_TYPE_MASTER Contains clusterName, clusterID.
    19 SND_ZONE_TYPE_DETAILS zone_id, zone_code, zone_parent.
    20 CINM_EMAIL entry of new email template.
    21 CIN_T_SMS_QUEUE After email, SMS – entry goes here.
    22 SND_USER_ROLE_MAPPING user_type, SND_USER_DETAIL.
    23 SND_USER_SUSPEND_MASTER Module_Param, Description.
    24 SND_USER_LOGIN_DETAIL Contains user_id and details.
    25 SND_DEALER_ZONE_MAPPING Contains salesChannelid, ZoneTypeid, Zoneid.

     

Useful List of Annotations:

  1. @RequestMapping – is used to map URL such as /dispatcher/saf onto an entire class or a particular handler method.
  2. @Transactional – on a method or class.
  3. @RequestParam – used for accessing the query parameter values from the request.
  4. @ModelAttribute – can be used either as a method parameter or at the method level.
  5. @Override – means that the method is override from a super class.
  6. @PathVariable – for parameterized URL’s that have variable input as part of their path.
  7. @Qualifier – This annotation can be used to control which bean should be auto wired on a property. eg: @Qualifier(“author”)
  8. @Autowiredno need to use the new keyword for object creation directly use. used for automatic dependency injection.
  9. @Component – marks the java class as a bean, Indicates that the class defines a spring component.
  10. @Controller – Indicates that the class defines a spring MVC controller. beans marked with it are automatically imported into the DI container. When we add the @Controller annotation to a class, we can use another annotation i.e. @RequestMapping;
  11. @Repository – Indicates that the class defines a data repository of DAO component in the persistent layer. needs to have exception translation applied transparently on it. It means only service layer has to deal with exceptions from Spring DataAccessException hierarchy.
  12. @Service – Indicates that the class defines a service of Business layer.
  13. @Id – The primary key of current entity.
  14. @BeforeRuns before the match method execution. uses an in-place pointCut expression to indicate when this advice executes. eg: @Before(“execution (*com.springforbeginners.aop.product.multiply(..))”)
  15. @AfterAfter advice runs however a matched method execution exits. eg: @After(“execution(* com.springforbeginners.aop.product.multiply(..))”)
  16. execution – This is the most common and most used designate. It is used for matching method execution join points.
  17. @Target(org.springframework.transaction.annotation.Transactional) – Any join point where the target object has an @Transactional annotation.
  18. @Args(com.xyz.security.classified) – Any joinPoint which takes a single parameter and where the runtime type of the argument passed has @classified annotation.
  19. @PersistentContext – A persistent context is a set of managed entity instances in which for any persistent entity identity there is a unique entity instance.
  20. @Around – Spring AOP – @Around annotated methods run before and after the all methods matching with pointcut expression. @Around(“execution(* com.comviva.pacs.snd.downstream.allocation.InventoryAllocationServiceImpl.returnByAgent(java.util.List))
  21. @NamedQuery – use to define single name query.
  22. @TableGenerator – uses a dedicated table to keep track of sequence of values.
  23. @GeneratedValue – like a auto increment attribute of MYSQL.
  24. @RestController – This annotation is a stereotype annotation, this annotation tells spring to render the result back to the caller.
  25. @JsonFormat – it formats the content.
  26. @EnableAutoConfiguration – This annotation tells the Spring Boot to configure the application based on the dependencies added. Since spring-boot-starter-web has added Tomcat and Spring MVC, auto-configuration will setup a web based application.
  27. @Table(schema=”DatabaseName”) – Schema represent the Database Name.
  28. @RequestPart
  29. @Modifying – If we don’t wish to clear the outdated entity automatically, we set @Modifying before @Query.
  30. @Query – helps us to create the query.
  31. @Param – use for parameter of methods.
  32. @Temporaluse in date, time and timestamp precision.
  33. @Embeddableembed one entity into another entity.
  34. @Access(AccessType.PROPERTY) – used to force access hierarchy of an entity methods and fields. type AccessType.PROPERTY and AccessType.FIELD.
  35. @DynamicUpdate – whether to include unmodified properties in the SQL UPDATE statement.
  36. @SessionAttributes – name of model attributes, which should be stored in a session.
  37. @PreAuthorize – we can authorize or deny a functionality
    @Transactional
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void removeContact(Integer id) {
      contactDAO.removeContact(id);
    }
  38. @ResponseBodyProcess the data and send it to back.
  39. @RequestBody – to get the data.

Useful Hibernate Annotation Methods:

  1. save()stores an object into the database.
  2. createQuery() – HQL whose syntax are quite similar to database SQL language.
  3. list() – Hibernate returns all the records from the customer entity class, which needs to be stored.
  4. load() – returns the persistence instance of the customer entity class with the customerId identifier, assuming that the instance exists.
  5. delete()removes a persistence instance from the data store.
  6. persist()inserts records if the identifier does not exists, else it will throw error.
  7. getResultList()executes a SELECT query and returns the query result as a List.
  8. getReference()gets an instance, whose state may be lazily fetched.
  9. remove()removes the entity instance.
  • Entities are nothing but POJO’s that do not extend any class nor implement any interface.
  • To make annotation work, the component auto scanning feature needs to be enabled.
  • One of the core responsibilities of Hibernate Template is to manage Hibernate sessions which involves opening and closing sessions as well as ensuring one session per transaction.
  • HQL uses : class name instead of table name. Property names instead of column name.
  • TransactionManager – This class binds a Hibernate session from the specified factory to the thread, potentially allowing for one thread session per factory.

JSON points:

  1. JSON is a simple data exchange format.
  2. Data is in name/value pairs.
  3. Data is separated by comma.
  4. curly brackets hold {objects}.
  5. square bracket holds array.
  6. JSON Parser : JSON data into objects.
  7. JSON text into an objecteval” function is used.
  8. DataType – number, string boolean, array, object, null.
  9. JSON.stringify() converts an object into a JSON text and saves that JSON text in an String.
  10. MIME type of JSON text is ”application/json”.
  11. put method adds a name/value pair to an object.
  12. Generate/send JSON data at the client side – Use POST HTTP method.
  13. push() method to add object to your array. eg: var favorites = [];
    favorites.push( myObj );
  14. JSON callbacks (function(callback)) – It provides the JSON response. The callback parameter is used to implement JSONP, The URI(Uniform resource Identifier) is expected to return a call to the function specified in the callback parameter, passing the data as a parameter.

TOAD Shortcuts

  1. Ctrl+Enter – run the query and shows the output.
  2. Shift+F9 – run the query.
  3. Ctrl+F9 – parse the query without executing.
  4. F8 – brings last executed Query.
  5. F5 – executes the selected script or whole script.
  6. F4 – shows the table columns.
  7. Ctrl+Z – Undo.
  8. Ctrl+Shift+Z – Redo.
  9. Ctrl+. – complete the table name.
  10. Ctrl+Tab – Cycle through the Window Editor to Schema Browser.
  11. Ctrl+T – Table alias dropdown.
  12. F2 – open Data Grid.
  13. F2+Shift – Open Data Grid Full.
  14. ‘–‘ – comment symbol ‘–‘ .

ORACLE SQL DEVELOPER 
+ Ctrl+space – to search the table in Oracle Developer worksheet.
+ COMMIT; // commit the changes.

IJ – IntelliJ ShortCuts
*create your own shortcut via keymap.
A test 1. Ctrl+K OR F3 – search simillar selected words.
Done 2. sout + tab – print full System.out.println();
Done 3. Ctrl+D – Delete a line.
Done 4. Ctrl+Shift+Space – complete instance.
Done 5. Alt+Insert – Getter Setter.
Done 6. Shift + Click – Close.
7. Ctrl+H – Find.
8. Ctrl+Shift+O –
Done 9. Ctrl+E OR Ctrl+Tab – open files.
Done 10. Ctrl + W – Close a file.
Done 11. Ctrl+Shift+W – Close all files.
Done 12. Ctrl+Shift+F – format code.
13. Ctrl+/ – comment.
14. Ctrl+Shift+N – open resource search a file.
15. ctrl+b, ctrl + click – declaration.
16. ctrl+alt+b -implementation.

SVN

  1. Take checkout of SVN in a new folder.
  2. clean break locks – to remove previous credentials.
  3. create patch -> desktop and create folder.
  4. Review Codebetter.comviva.com
  5. create review -> project -> MLS IPACS -> Upload patch -> Start Review.
  6. Commit mention URL Review ID + module name.

Moving project SVN update

  1. SVN update folder.
  2. Copy node and Node_modules folder.
  3. Maven install in SND_Parent.
  4. Maven clean and Maven Build.
  5. if JDK and JRE is not set, than set.
  6. SNDXL – Spring Boot App <- Run.

JS Promise

A promise is a special JavaScript object that links the “producing code”(perform some task and takes time) and the “consuming code”(wants the result of producing code) together.

let promise = new Promise(function(resolve, reject) {

  // executor (the producing code, “singer”)

});

new Promise is called the executor.

The resulting promise object has internal properties:

state — initially “pending”, then changes to either “fulfilled” or “rejected”,

result — an arbitrary value, initially undefined.

 New Promise (State-pendig, Result-undefined) -> resolve(state-fulfilled, result-value)

New Promise (State-pendig, Result-undefined) -> reject(state-reject, result-error)

 Consumers: then, catch, finally

consuming function can be registered using methods .then, .catch, .finally.

promise.then(

  result => alert(result), // shows “done!” after 1 second

  error => alert(error) // doesn’t run

);

 Catch – if we are tracking the errors. promise.catch(alert); // shows “Error: Whoops!” after 1 second

finally – just like finally block of java exception.

.finally(() => stop loading indicator)

.then(result => show result, err => show error)

Spring Transaction Management benefits:

  1. It is very easy to use.
  2. It does not require any underlying transaction API knowledge.
  3. The transaction management code is independent of the transaction technology.
  4. Supports both annotation based and XML based configuration.
  5. It does not require to run on a server. eg: there is no need of server.
  6. @Transactional is the annotation on the business logic method on @service class, which can be used on any method of any bean and on the bean itself.

JPA (Java Persistence API)

Object/Relational mapping tools.

Java Persistence consists of three areas:

  1. The Java Persistence API.
  2. Object/Relational mapping metadata.
  3. The Query language.
  • Entity Manager – It provides the main interface to perform actual database operation.
  • JTA Transaction ManagerJTA (Java Transaction API) transaction manager is used to manage the transactions of the customer details application.

RESTFUL Resources

REST designing networked applications. REST uses HTTP for all four CRUD. REST is done through a URL. Use a Uniform Resource Identifier(URI). It uses :

  1. GET method – get or list the resources.
  2. POST method – create a resource.
  3. PUT method – update or replace a resource.
  4. DELETE method – removing the resource.
  5. @PathVariable – for parameterized URL’s that have variable input as part of their path. eg: http://localhost:8080/SND/Distributor/saf/12    <- @PathVariable
  6. @RequestBody – To receive the data as an object, the handler method parameter is annotated with @RequestBody. eg: public void getSafNo(@RequestBody String safNo)

 

  • Colon “:” is used in HQL Hibernate Query Language to signify that there is a parameter involved.

+ ajaxHandler.sendRequest() method parameter values ?

DI (Dependency Injection) or IOC (Inversion of Control)

Using DI, the framework acts as an object factory to build service objects. DI or IOC container is one of the best ways to implement loosely coupled (getter and setter) applications.

The client POJO automatically obtains the correct service object, when it is required. The IOC container manages the POJO’s and its dependencies in the application.

Tight couplingdepending on another class or object.

Loosely coupling – using getter and setter can be done.

AOP (Aspect Oriented Programming)

It is like Triggers in SQL, created for a specific action such as INSERT, Update, Delete on a Table. AOP captures functionality that is used throughout the application in reusable components. eg: @Aspect – just like “interceptors”.

Join Points – An application may have plenty of points for the Advice to be applied. These points are known as Join Points.

Annotations

Can be applied to variables, parameters, fields type declarations, methods and constructors.

Configuration => XML

Configuration => Annotation

Annotation => Hibernate

Annotation => JPA => Hibernate Template

Auto Wiring – Spring automatically figures out how to wire bean dependencies.

Auto Scanning – Spring automatically figures out which class should be configured as spring beans, reducing the need for <bean> tags.

<context: annotation-config> – tag in XML. informs spring that this application uses annotation based wiring.

<context: component-scan>looks for classes that are annotated with one of @component, @controller, @Repository, @Service and register @controller annotation.

Kinds of AutoWiring annotations – AutoWiring helps reduce the need for <property> and <constructor-arg>.  Spring 3 supports the following kinds of annotations for autowiring:-

  • @Autowired annotation
  • @Inject annotation
  • @Resource annotation

Autowiring and Auto-scanning together noticeably reduce the amount of XML spring configuration.

Q. Why we use Maven pom.xml – whats its use ?

A. calling the dependencies.

REQUIREJS

  1. all your JavaScript files in a “scripts” folder in your project.
  2. Add require.js to the scripts directory.
  3. don’t write the JS in HTML page, keep the inline link of require.js in HTML only.
  4. It includes all the dependencies in one .js file, which improve its performance.

Defining Functions with Dependencies

define(["./mnc", "./startup"], function(mnc, startup) {

      return {

         state: "karnataka",

         city: "bangalore",

         addCompany: function() {

            mnc.decrement(this);

            startup.add(this);

         }
      }
   }
);

 
var myteam = require("./team"); // calls the team.js file in a defining file.

optimizer is a component of the r.js adapter. It is developed to be a part of a build process and not for the development process.

GOTO Technologies

  1. Exception Handling, subtype, Hierarchy, Resource with try catch.
  2. Thread pool
  3. Java 1.8 – function, marker, streaming concept for iteration, Hibernate criteria

POSTMAN 

Postman is a Google Chrome app for interacting with HTTP APIs.

Facebooktwittergoogle_plusredditpinterestlinkedinmail
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...