Wednesday 1 March 2017

Spring MVC tutorial



Spring MVC


Spring MVC provides model-View-controller framework for developing web applications and RESTful websites.The applications thus are loosely coupled as we separate view part from the business logic written in controllers.

Spring MVC revolves mainly around Dispatcher servlet. Dispatcher servlet is a servlet which dispatches the incoming requests to a controller for processing. Dispatcher servlet is an expression of front controller design pattern. 



Spring MVC Architechture

It is also responsible for resolving views to be rendered on browser (based on the view name returned from the controller). It provides support for locale and theme resolution.


Saturday 9 April 2016

Apache Spark RDD

RDD - Resilient Distributed Dataset

RDD forms the basic entity of spark. There are 4 characteristics of RDD:

1. Fault Tolerance - it means that RDD can recompile itself in case of a node failiure. Each RDD has a lineage using which it can recompute itself. This lineage stores the initial dataset and all the transformations to be applied on it. Following example of map function can describe in detail how lineage is created  inherently.

2. Distributed - Spark is a distributed computing framework and so is RDD. RDD comprises of a array of partitions which in turn are representation of data in memory on differs nodes. Computations are applied in these partitions.

3. Cacheable- we can cache/ persist RDD if we choose to. This makes the program quite efficient and we can reuse the the same RDD again if needed by reading from the persisted RDD.

4. Immutable- Immutability is the basic concept of BigData. This  is quite logical too, Actually no one would ever want to change the nth line in a 1 TB data.  Also immutable data is the perfect candidate for caching. RDDs are immutable, that means whenever we perform any transformation on a RDD, it creates a new RDD.

5. Type-Inferred - This is something which comes from functional programming. It means that compiler can throw the semantic error during compilation time only. We do not have to worry about the data type, spark can automatically infer it from the underlying data.




Saturday 22 September 2012

Re-ordering of portal pages in WebSphere Portal Server

WebSphere Portal Server maintains the portal pages in a hierarchy. They are arranged as a tree hierarchy with Content Root as the top. Each node, called content node, in the tree can be a page, a label, or a URL (internal or external). Pages and labels can be created by using out of the box portlet : Manage Pages portlet. 

By default after login, portal server picks the first child in the hierarchy, and if that child is a label (say A) then it fetches the fist child of A. The pages or labels can be reordered either using Manage Pages portlet or XMLAccess scripting interface provided by portal server.

  Re-Ordering using Manage Pages portlet.

 To reorder open the Portal Administration console and click on Manage pages link on left navigation. In manage pages portlet navigate to the page/label to be reordered. Then click on up or down arrow to move the page up or down in hierarchy.

 Re-Ordering pages using XMLAccess.

To use this method the creation of pages needs to be done using XMLAccess tool provided by portal server. Sample XMLs can be located on portal installation directory at following path:
\/docs/xml-samples/

 The position of a content node under a parent node in the hierarchy can be ranked by its ordinal, an integer. The smaller the ordinal, the higher the rank. The display and rendering of the content tree in Portal is according to the page ordinals.

When you add a node, you can specify its ordinal which can take the following values
first: this puts the content-node at the top of the hierarchy;
last: this puts the content-node at the bottom of the hierarchy;
• an integer: this puts the content-node by comparing the ordinals of those currently in the system and inserting it in the proper position;
• an hash mark "#" followed by an integer: this puts the page to the absolute location by counting the top one as 0, the second 1, and so on. Thus, "#12" will put the new content node to the 13th position in the current hierarchy.

Monday 28 May 2012

IBM WebSphere Portlet Factory: IPC Error - EJPKB0991E


WebSphere Portlet Factory: Property Broker Error while IPC - EJPKB0991E

Eventing is a wonderful feature provided by JSR 286 for Inter-portlet Communication. In IBM WebSphere Portlet Factory 6.1.5 onwards, there are 2 builders provided to achieve Inter portlet Communication (JSR 286 way). These builders are:

· Cooperative Portlet Source builder
· Cooperative Portlet Target builder

Cooperative Source builder is added in model which is going to publish the event. Cooperative target builder is added in model which is going to Consume the events.

Apart from using these 2 builders, we need to wire the source and target portlets, so that IBM WPS Property Broker can determine from where to send the event and to whom.

Sometimes a weird error comes whenever we perform inter-portlet communication. The error that comes is:

[5/16/12 14:45:09:043 IST] 0000004c PropertyDispa E com.ibm.wps.propertybroker.dispatch.PropertyDispatcherImpl dispatchSourceEvents EJPKB0991E: The propertybroker encountered a problem finding a communication source with name MyEvent for portlet definition PortletDefinition: com.ibm.wps.datastore.impl.PortletDescriptorImpl@50f73720
objectID: [ObjectIDImpl '3_P3668B1A001P70ITIMHLOS2084', PORTLET_DEFINITION, VP: 0, [Domain: rel], DB: 0000-791883565000847C80ECD2C68AB90088]
created: 1336999629870
lastModified: 1337153197840
portletName: SourcePortlet
isActive: true
expires: null
isShared: null
applicationDescriptorObjectID: [ObjectIDImpl '2_P3668B1A001P70ITIMHLOS2004', PORTLET_APPLICATION_DEFINITION, VP: 0, [Domain: rel], DB: 0000-791883565000847C80ECD2C68AB90080]
defaultLocale: en
servletDescriptorObjectID: [ObjectIDImpl 'V_P3668B1A001P70ITIMHLOS2080', SERVLET_DEFINITION, VP: 0, [Domain: rel], DB: 0000-791883565000847C80ECD2C68AB90008]
wspIsProvided: false
initParameters: {}
localeData: Supported locales=[ar ca cs da de el en es fi fr hr hu it iw ja ko nl no pl pt pt_BR ro ru sk sl sv th tr uk zh zh_TW ] Loaded locales=[en: Source Portlet Title, Source Portlet , Source Portlet Title, null, ]
preferences: {}

The error message states that Property Broker could not find source for MyEvent event. The problem appears because of class files present in /WEB-INF/classes folder in application.

To rectify it delete all the java class present files in /WEB-INF/classes folder, also delete WPF model class files (if present) under genjava directory in /WEB-INF/classes folder. Restart the application after deletion.

Hope this solution helps.

Please post your comments on this article.

Saturday 10 December 2011

Highlight alternate rows in WebSphere portlet factory (WPF)

Often, there is a need to highlight alternate rows when displaying the data using page automation builders like data page builder. Highlighting alternate rows also provide better visual presentation for your page and increases readability of the data table.

IBM WebSphere portlet factory provides a very simple technique to add attributes to alternate rows in data table.


You can build this functionality into an HTML template. On any XML node for which an alternating attribute is desired, simply prefix the attribute name with sequence_ (with the underscore) and list the different values for the attribute in a comma-separated list.

For example, in a

tag, to alternate between the HTML class names OddRow and EvenRow, add the following: 

< tr sequence_class="OddRow,EvenRow">
.........

</tr>

This would highlight the alternate rows in the data table. Similarly we, can add any attribute for alternate rows in a data table using page automation builders.

Saturday 26 November 2011

Inter Portlet Communication in IBM WebSphere Portlet factory

While developing any portal application, we need to make portlets talk to each other and exchanging some data between each other.
 In Websphere portlet factory there are several ways to make portlet talk to each other. One of the way to achieve this is Inter Portlet Communication using Property Broker.

Cooperative portlet source builder is used in the source builder to declare the event to be published by source portlet model and Cooperative Portlet target builder is used in Target portlet model .

So for example if we consider a library management portal page having 2 portlets:
  • Books List portlet: This portlet shows a table containing all the fiction books. On clicking on the book label , details of the clicked book is displayed in the books detail portlet.
  • Books Details portlet: This portlet shows the details of the book.

Tuesday 12 July 2011

Fetching nth row in DB2

Few days back I was facing a problem of fetching a large number of rows (approx.70 000) on a very slow client network. So as a solution I decided to fetch rows in small chunks. In DB2 there is a function  row_number() .
An OLAP function ROW_NUMBER() provides consecutive numbers to rows in a result set .For Example:-
SELECT ROW_NUMBER() OVER(), TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA='DB2ADMIN'

1 TABNAME
-------------------------------------------
1 CONSECUTIVE_NUMS
2 DATES
3 EXPLAIN_ARGUMENT
4 EXPLAIN_INSTANCE
5 EXPLAIN_OBJECT
6 EXPLAIN_OPERATOR
7 EXPLAIN_PREDICATE
8 EXPLAIN_STATEMENT
9 EXPLAIN_STREAM
10 SALES_DETAIL
11 SALES_DETAIL_CLS
11 record(s) selected.

The query to get rows from 11th to 20th row from a table can be:-


Select EMPID, EMPNAME , DESIGNATION from (
select row_number() over (order by EMPID ASC) as EMPID, EMPNAME , DESIGNATION from Employee_data
)where rownumber BETWEEN 10 and 21;


Reference:    Using DB2 OLAP functions

Please provide your feedback on this post by writing comments on this post below.