Select2 – Jquery Plugin – examples

This post has been moved to http://srinichekuri.com/2016/01/09/select2-jquery-plugin/

**********************************************************************

Select2 is famous Jquery plugin that allows customization of select component with support for searching, tagging, remote data sets, infinite scrolling etc.

I had a chance to work on select2 plugin off late and I was able to use it with using various options. I faced some serious issues while working on these options and realized that there were lot of developers who inquired on web on how to use select2 in these scenarios but there are no proper responses/documentation with examples for these scenarios.

Below are the various examples for select2 that I have published.
Select2 3.5.2 version was used for below examples. Be advised to read through specs before you process any further.

Below are Select2 Parameters that I have used for examples :

  • minimumInputLength: minimum number of characters before starting a search.    Eg: 2.
  • minimumResultsForSearch: limit on the results to be displayed.
  • placeHolder: Place holder to be shown when there are no selections made.           Eg: ‘Select Employee’
  • tokenSeparators: Character set that can be used as delimeters to enter multiple values. Eg: [‘,’]
  • Multiple: Boolean value to indicate if multiple values can be selected
  • Id: function used to get id from the object that is selected
  • Ajax: Option to be used for built in ajax query selection.
    • url: url to make ajax call.
    • datatype: data type of request. Eg: ‘json’
    • params: Extra paramters to be passed on in request. Eg: ‘{contentType: “application/json”}’
    • data: query parameters for ajax request
    • results: builds query result object from ajax response.
  • formatSelection: format the selection that is shown.
  • formatResult:  Function used to render a result that is shown to user for selection. Eg: results that are shown in dropdown.

Select2 – Tags (Click Here for working code):select2_ajax_tags_selections

 

<div id="maincontainer" class="clearfix">
    <!-- main content s-->
    <div id="contentwrapper">
        <div class="main_content">
            <div class="row-fluid">
                <div class="span6" id="employeeColumn">
                    <div class="control-group">
                        <label class="control-label">Employee Name: </label>
                        <div class="controls">
                            <input type="text" class="tags" id="select2_tags_id" />
                        </div>
                    </div>
                    <!--control group -->
                </div>
                <!-- Employee Column -->
                <button id="loadDataButton" class="btn" type="submit"><i class="icon-plus" alt="OK"></i> Load Data </button>
            </div>
            <!-- row-fluid -->
        </div>
        <!-- main_content -->
    </div>
    <!-- content wrapper -->
</div>

Java script for Select2 Tags.

$(document).ready(function() {
    $('#select2_tags_id').select2({
        tokenSeparators: [','],
        tags: true,
        maximumSelectionSize: 10,
        minimumResultsForSearch: Infinity,
        multiple: true,
        dropdownCss: {
            display: 'none'
        }
    });

    $('#loadDataButton').on('click', function() {
        $('#select2_tags_id').select2('val', ['Srinivas', 'Robert']);
    });
});

 

Select2 – Ajax – Single Selection (Click Here for working code):

select2_ajax_single_selections

 

Below code is for dynamic search using Ajax and for single selection.

<div id="maincontainer" class="clearfix">
    <!-- main content s-->
    <div id="contentwrapper">
        <div class="main_content">
            <div class="row-fluid">
                <div class="span6" id="employeeColumn">
                    <div class="control-group">
                        <label class="control-label">Employee Name (String): </label>
                        <div class="controls">
                            <input type="text" id="select2_ajax_simple_id" />
                        </div>
                    </div>
                    <!--control group -->
                </div>
                <!-- Employee Column -->
                <button id="preselectSimpleDataButton" class="btn" type="submit"><i class="icon-plus" alt="OK"></i> PreSelect Simple Data </button>
                <label>Selects String - Srinivas Chekuri </label>
            </div>
            <!-- row-fluid -->

            <!--Code for Select2 Object -->
            <div class="row-fluid">
                <div class="span6" id="employeeComplexColumn">
                    <div class="control-group">
                        <label class="control-label">Employee Name (Object): </label>
                        <div class="controls">
                            <input type="text" id="select2_ajax_complex_id" />
                        </div>
                    </div>
                    <!--control group -->
                </div>
                <!-- Employee Column -->
                <button id="preselectObjectDataButton" class="btn" type="submit"><i class="icon-plus" alt="OK"></i> PreSelect Object</button>
                <label>Selects Object - Srinivas Chekuri With Role </label>
            </div>
            <!-- row-fluid -->
        </div>
        <!-- main_content -->
    </div>
    <!-- content wrapper -->
</div>

Java script for Select2 configuration and selection for simple data (String).

 $('#select2_ajax_simple_id').select2({
            minimumInputLength: 1,
            placeholder: "Search Employee",
            //data:o,
            id: function(i) {
                return i;
            },
            initSelection: function(element, callback) {

            },
            ajax: {
                type: 'post',
                url: "/echo/json/",
                allowClear: true,
                dataType: 'json',
                delay: 250,
                params: {
                    contentType: "application/json"
                },
                data: function(term, page) {
                    //Code for dummy ajax response
                    return {
                        json: simple_employee_response,
                        delay: 0
                    };
                },
                results: function(data, page) {
                    return {
                        results: data
                    };
                },
                cache: false
            },
            formatResult: function(i) {
                return ' < div > '+i+' < /div>

                '; }, // Formats results in drop down
                formatSelection: function(i) {
                    return ' < div > '+i+' < /div>

                    '; }, //Formats result that is selected
                    dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
                        escapeMarkup: function(m) {
                            return m;
                        } // we do not want to escape markup since we are displaying html in results
                });

Java script for Select2 configuration and selection based on Objects.
Note: Html is the same as shown above.

$('#select2_ajax_complex_id').select2({
            minimumInputLength: 1,
            placeholder: "Search Employee",
            //data:o,
            id: function(i) {
                return i;
            },
            initSelection: function(element, callback) {

            },
            ajax: {
                type: 'post',
                url: "/echo/json/",
                allowClear: true,
                dataType: 'json',
                delay: 250,
                params: {
                    contentType: "application/json"
                },
                data: function(term, page) {
                    //Code for dummy ajax response
                    return {
                        json: complex_employee_response,
                        delay: 0
                    };
                },
                results: function(data, page) {
                    return {
                        results: data
                    };
                },
                cache: false
            },
            formatResult: function(i) {
                return ' < div > '+i.name+' ('+i.role+')
                '+' < /div>

                '; }, // Formats results in drop down
                formatSelection: function(i) {
                    return ' < div > '+i.name+' ('+i.role+')
                    '+' < /div>

                    '; }, //Formats result that is selected
                    dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
                        escapeMarkup: function(m) {
                            return m;
                        } // we do not want to escape markup since we are displaying html in results
                })

                $('#preselectSimpleDataButton').on('click', function() {
                // alert('I am here');
                $('#select2_ajax_simple_id').select2('data', 'Srinivas Chekuri');
            });

            $('#preselectObjectDataButton').on('click', function() {
                // alert('I am here');
                var o = new Object;
                o.id = "1";
                o.name = "Srinivas Chekuri";
                o.role = "Architect";
                $('#select2_ajax_complex_id').select2('data', o);
            });

Select2 – Ajax – Single Selection (Click Here for working code):

select2_ajax_multiple_selections

 

Below code is for dynamic search using Ajax and to have multiple selections.

<div id="maincontainer" class="clearfix">
    <!-- main content s-->
    <div id="contentwrapper">
        <div class="main_content">
            <div class="row-fluid">
                <div class="span6" id="employeeColumn">
                    <div class="control-group">
                        <label class="control-label">Employee Name (String): </label>
                        <div class="controls">
                            <input type="text" class="tags" id="select2_ajax_simple_id" />
                        </div>
                    </div>
                    <!--control group -->
                </div>
                <!-- Employee Column -->
                <button id="preselectSimpleDataButton" class="btn" type="submit"><i class="icon-plus" alt="OK"></i> PreSelect Simple Data </button>
                <label>Selects String - Srinivas Chekuri </label>
            </div>
            <!-- row-fluid -->

            <!--Code for Select2 Object -->
            <div class="row-fluid">
                <div class="span6" id="employeeComplexColumn">
                    <div class="control-group">
                        <label class="control-label">Employee Name (Object): </label>
                        <div class="controls">
                            <input type="text" class="tags" id="select2_ajax_complex_id" />
                        </div>
                    </div>
                    <!--control group -->
                </div>
                <!-- Employee Column -->
                <button id="preselectObjectDataButton" class="btn" type="submit"><i class="icon-plus" alt="OK"></i> PreSelect Object</button>
                <label>Selects Object - Srinivas Chekuri With Role </label>
            </div>
            <!-- row-fluid -->
        </div>
        <!-- main_content -->
    </div>
    <!-- content wrapper -->
</div>

Java script for Select2 configuration and selection for simple data (Strings) with multiple selections.

 $('#select2_ajax_simple_id').select2({
    tags: true,
    maximumSelectionSize: 10,
    minimumResultsForSearch: Infinity,
    multiple: true,
    minimumInputLength: 1,
    placeholder: "Search Employee",
    //data:o,
    id: function(i) {
        return i;
    },
    initSelection: function(element, callback) {

    },
    ajax: {
        type: 'post',
        url: "/echo/json/",
        allowClear: true,
        dataType: 'json',
        delay: 250,
        params: {
            contentType: "application/json"
        },
        data: function(term, page) {
            //Code for dummy ajax response
            return {
                json: simple_employee_response,
                delay: 0
            };
        },
        results: function(data, page) {
            return {
                results: data
            };
        },
        cache: false
    },
    formatResult: function(i) {
        return ' < div > ' + i + ' < /div>

        ';
    }, // Formats results in drop down
    formatSelection: function(i) {
        return ' < div > ' + i + ' < /div>

        ';
    }, //Formats result that is selected
    dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
    escapeMarkup: function(m) {
            return m;
        } // we do not want to escape markup since we are displaying html in results
});

$('#preselectSimpleDataButton').on('click', function() {
    $('#select2_ajax_simple_id').select2('data', ['Srinivas Chekuri']);
});

Java script for Select2 configuration and selection based on Objects.
Note: Html is the same as shown above.

 $('#select2_ajax_complex_id').select2({
    tags: true,
    maximumSelectionSize: 10,
    minimumResultsForSearch: Infinity,
    multiple: true,
    minimumInputLength: 1,
    placeholder: "Search Employee",
    //data:o,
    id: function(i) {
        return i;
    },
    initSelection: function(element, callback) {

    },
    ajax: {
        type: 'post',
        url: "/echo/json/",
        allowClear: true,
        dataType: 'json',
        delay: 250,
        params: {
            contentType: "application/json"
        },
        data: function(term, page) {
            //Code for dummy ajax response
            return {
                json: complex_employee_response,
                delay: 0
            };
        },
        results: function(data, page) {
            return {
                results: data
            };
        },
        cache: false
    },
    formatResult: function(i) {
        return ' < div > ' + i.name + ' (' + i.role + ')
        ' + ' < /div>

        ';
    }, // Formats results in drop down
    formatSelection: function(i) {
        return ' < div > ' + i.name + ' (' + i.role + ')
        ' + ' < /div>

        ';
    }, //Formats result that is selected
    dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
    escapeMarkup: function(m) {
            return m;
        } // we do not want to escape markup since we are displaying html in results
})

$('#preselectObjectDataButton').on('click', function() {
    var _array = []
    var o = new Object;
    o.id = "1";
    o.name = "Srinivas Chekuri";
    o.role = "Architect";
    _array.push(o);
    $('#select2_ajax_complex_id').select2('data', _array);
});
Advertisements

Expanding root of tree in flex

This post is moved to http://srinichekuri.com/2014/02/21/expanding-root-of-tree-in-flex/

**********************************************************************

If you ever want to expand a tree (<mx:Tree>) immediately after setting dataprovider then follow this procedure. The challenge here is tree will not be ready to expand as it takes sometime for it to set data and render.

One common suggestion found on web is to use callLater() to call a function that has code to expand tree. This didn’t work for me (possibly because my code ran into same issue that I highlighted above). But following below method should definetly work as validateNow() method will make sure that all properties are set and will get the tree ready before expanding.

myTree.validateNow();
myTree.expandChildrenOf(_xml,true);

Cannot use javahl, JavaSVN nor command line svn client

This post has been moved to http://srinichekuri.com/2014/02/14/cannot-use-javahl-javasvn-nor-command-line-svn-client/

*********************************************************************

I was working on a old project that had all build files that were working fine when coded originally. I tried using the same files and I ran into this issue.

Error: Cannot use javahl, JavaSVN nor command line svn client

Research:
I have googled on this and I was able to find two feasible solutions that apparently worked for others.

  1. javahl.dll or svnjavahl.dll files have to be appended to PATH variable. This solution didn’t work for me. First of all I didn’t find these files and even if would have found them, I wouldn’t have done it as changing PATH variable was not an option for me.
  2. Download a svn client like silksvn and install it. This will put in a PATH variable which will in turn help fixing the issue. This was not an option either as I was not willing to install a software for something that was supposed to work stand alone.

Solution:
After multiple trails this is what worked for me.

  • I downloaded the latest SvnAnt (svn 1.2.x at time of documentation).
  • I replaced svnant.jar, svnClientAdapter.jar, svnjavahl.jar files that were preexisiting and added svnkit.jar.
  • Add these files to classpath in ant script. (No changes done to PATH variables or any other system level variable)
&lt;typedef resource=&quot;org/tigris/subversion/svnant/svnantlib.xml&quot;&gt;
 &lt;classpath&gt;
 &lt;pathelement location=&quot;C:/svnAnt/lib/svnant.jar&quot;/&gt;
 &lt;pathelement location=&quot;C:/svnAnt/lib/svnClientAdapter.jar&quot;/&gt;
 &lt;pathelement location=&quot;C:/svnAnt/lib/svnjavahl.jar&quot;/&gt;
 &lt;pathelement location=&quot;C:/svnAnt/lib/svnkit.jar&quot;/&gt;
 &lt;/classpath&gt;
 &lt;/typedef&gt;

Hope this helps!!!

SCEA/OCMJEA Essay

This post has been moved to http://srinichekuri.com/2013/06/04/sceaocmjea-essay/

**********************************************************************

I gave my Essay in a week after uploading my project. It’s suggested not to have long gap between assignment and essay because project is still fresh in mind and it will help us referencing the filenames in essay. I felt that easy would need you to remember your architecture/design, hardware with its configuration and few filenames.

Suggestions:

  • Try to keep the time between step-2 and step-3 as minimal as possible.
  • Remember the project particularly the technologies, patterns and file names that were used in the project. It will help to reference them in your essay.
  • Prepare for the following questions before you take step-3
    • How does your design handle availability? Why did you choose it? pros and cons of your approach?
    • How does your design handle reliability? Why did you choose it? pros and cons of your approach?
    • How does your design handle scalability? Why did you choose it? pros and cons of your approach?
    • How does your design handle performance? Why did you choose it?  pros and cons of your approach?
    • How does your design handle security? Why did you choose it? pros and cons of your approach?
    • How does your design handle extensibility? Why did you choose it? pros and cons of your approach?
    • How does your design handle maintainability? Why did you choose it? pros and cons of your approach?
    • Set of design patterns on which layer and why?
    • How does your design support session/state handling?
    • How does your design handle persistence?
    • How does your client tier talk to business tier?
    • How does your design handle Qos 5 Sec in peak time?
    • How does your design handle transactions?
    • How does your design handle authentication and authorization?
    • What technology u have used in presentation and business tier why?
    • How many SB’s you used and purpose of them?
    • Why have you chosen framework If any If not why not ?

    Here is my notes that I have prepared

  •  How does your design handle availability? Why did you choose it? pros and cons of your approach?Backup application server: Although primary application server is technically capable of handling 200 users, I chose to add a less powerful backup server to be able to handle case when primary server fail for some reason. Also load balancer will be configured to route traffic to standby box when primary’s CPU spikes.Backup database: Same with database.
  • How does your design handle reliability? Why did you choose it? pros and cons of your approach?Elastic Load balancing provided by Amazon for the cloud is capable of sending routing all traffic to back up server if the primary goes down.Primary application server although serves most of the request, a backup server is added to take traffic if primary goes down.Same with database server.Data Integrity achieved due to multiple security layers which will prevent third party from making any unauthorized changes. All the Entities and EJBs are serializable which would mean that they will be ready for session failover without any data loss. Transactions would make sure that there is data integrity as it is a full commit or a rollback.Authentication and Authorization
  • How does your design handle scalability? Why did you choose it? pros and cons of your approach?Additional application servers can be added.Additional databases can be added.Application is designed to be deployed on multiple servers which can be clustered both vertically and horizontally.
  • How does your design handle performance? Why did you choose it?  pros and cons of your approach?DTO (decrease multiple network calls)Business delegateClient validation (reducing the server calls),Caching.Connection pooling.By not using JSF which are not performance centric.
  • How does your design handle security? Why did you choose it? pros and cons of your approach?Validation – SQL injection decreases denial of attack.Filters to reduce SQL injection, CSS attacks and Script attacks. All secure communications only (Secure Transport layer – secure HTTP using SSL). Fire wall.Authentication and authorization
  • How does your design handle extensibility? Why did you choose it? pros and cons of your approach?The application is designed with separation of concerns- Presentation Tier, Business tier, persistence tier and  Integration tier.Each layer is loosely coupled with each other with good usage of design patterns, interfaces and best practices of Object oriented design like encapsulation, inheritance.So any change to sub systems will have less impact on systems which are using it as long the interfaces remain same. Even if there are changes the impact will be minimal for adapting new changes.
  • How does your design handle maintainability? Why did you choose it? pros and cons of your approach?Due to the layered architecture each layer address a particular need so any enhancement can be made easily. Also each layer is loosely coupled with best design practices which makes understanding functionality and making changes easier.
  • How does your design handle Manageability?Application can be monitored by using websphere monitoring. Logging is in place.
  • How does your design support session/state handling?Distributed session handling is done by stateful session beans. Any session variables which are not serializable are stored in Http Session. All the variables stored in Http Session can be established by application logic on session fail over.
  • How does your design handle persistence?As JPA is a specification, this can be deployed without any further configuration changes in any J2ee compliant servers. Easy development ().Considered:JDBC: No Transactions, Development not easy.Hibernate/iBatis: This brings in tight coupling between frameworks and code. Need developer to have framework knowledge. While deploying we will have to make sure that all the dependencies are taken care of as all J2ee compliant servers might not be able to support these frameworks. Might need extra testing of frameworks when upgrading to new versions of Java/J2ee to make sure that these frameworks will work fine in new environments.
  • How does your client tier talk to business tier?Client here is a browser as this is a web application.Browser(on https) -> load balancer -> Controller -> EJBs.
  • How does your design handle transactions?EJB Transactions and JPA Transactions.I have decided to use bean managed transactions so that I can have more control over when transaction starts and ends inside a method call. All transactions thatDisadvantage of JTA Transactions is that it doesn’t support nested transactions.
  • How does your design handle authentication and authorization?Authentication details and role details are stored in Ldap. Spring’s JAAS (Java Authentication and Authorization Service) is used to control the authentication and authorization in the application. Spring is configured to connect to ldap and control access of user according to the role in the application.   Access to each jsp page is controlled by the spring-security taglib.Authentication is done by HTTP form. Username is the email address all the time. Once the user submits the form with username/password, application checks the details with Ldap.
  • What technology u have used in presentation and business tier why?
    • Presentation Tier:
      Struts 2.0:Shown below
    • Business Tier:
      Stateful and Stateless Session Beans: Easy development for distributed applications. Also provides system level services which helps developer to concentrate on solving business problems. Allows scalability in distributed systems, transactions ensures data integrity.
  • Why have you chosen framework If any If not why not ?Front end:
    • JSF – not good with performance
    • JSP with taglibs: good but not packed with many features that are provided by struts
    • Struts: Advantages below
  • Which design pattern you have used for communicating with external system and why? Proxy Pattern
  • Potential security threats and how your architecture solves this?
    • Phishing – all communication happen through secure channels. Https, smtpsSQL injection – solved by client side validation and server side validation
    • Unwanted access – authentication and authorization.
  • which web framework you are using and why? Advantages of Struts 2
    • POJO forms
    • Validation.
    • POJO Actions
    • Easy Spring integration
    • Easy testing.
    • Interceptors.
    • Less coupling between MVC so easy manageability and extensibility.

    Advantages of Spring:

    • Spring – Ldap functionality
    • Spring – Email transport
    • Spring – Struts Plugin available
    • Dependency Injection
    • Abstract Oriented programming (AOP)

My other posts related to SCEA: SCEA Experience (Step-1), SCEA/OCMJEA Assignment

SCEA/OCMJEA Assignment

This post has been moved to http://srinichekuri.com/2013/06/04/sceaocmjea-assignment/

**********************************************************************

Today I got the magical email that I have passed assignment with a score of 146/160. Needless to say, I was very happy. I am blogging my experience with the hope that future aspirants will benefit from this.

I have submitted Assignment about 10 days before voucher expires.To start I have downloaded the assignment almost immediately after my Step-1 which started my clock(for people who don’t know Step 2 and Step 3 should be done within six months after the assignment is downloaded). Well if the question is did it actually take six month to complete this project, the answer is a big NO. I have started working on it for few hours everyday for 2 weeks. When I understood the assignment well and designed the system, I also drew class diagrams, sequence diagrams on scrap papers and then I stopped. I guess I was thinking that the challenging part is complete and I had to take care of the boring part( documenting it).
When I took up the project again after 5 months, I realized that it was a mistake due to following reasons:

  • The break wiped out project from my memory and I had to start all over again. Ofcourse my design that I scrapped on paper really helped me to get it all back.
  • I have under estimated deployment diagram. I never had to decide on hardware profile before and this turned out to be quite challenging.
  • UML took good chunk of time. By UML I mean deciding on the tool, planning on how you project your diagrams to make evaluation easy and actually drawing them took some time.
  • Documenting did take some time.

The project that was assigned to me was a web application with peak usage of 200 users. The domain diagram had 11 classes.
I have worked on UML diagrams in following order:
Class Diagram:
I have decided to divide my class diagrams into 2 parts by separating out domain classes. Although I started out with a thought to accommodate all the classes into one diagram, I thought that domain classes can be shown separately just to avoid clutter. This worked out pretty well for me. I have used various patterns like MVC, Factory, Business Delegate, Proxy Pattern, Data Access Object, Value Object, Transfer Object and Domain store. I have used following technologies/frameworks:

  •     Struts 2.0 for presentation layer.
  •     EJB 3.0 enterprise beans for session and transaction management.
  •     JPA for persistence.
  •     Java Mail API for email notification.
  •     Spring 3.0 for Authentication and Authorization.
  •     Spring 3.0 for dependency injection, aspect-oriented programming.
  •     Log4j for logging.
  •     WebServices.
  •     Ehcache for Caching (Out of box with Spring 3.0).

My class diagram also included few classes and jsps for user scenarios that were not mentioned in the requirement. For Eg: Maintenance module was not mentioned in my assignment, I have included that after adding proper assumptions.
In all I had 9 jsps, 25 classes and 11 domain objects.
Although I mentioned class names for value objects and transfer Objects, I didn’t show them in my class diagram.

Sequence Diagram:
I had six sequence diagrams in my project. I made sure all the use cases that are mentioned in assignment are addressed here. I had to do some reading for this as I found that UML 2 had good features to represent our views. I have used two opts.

Component Diagram:
I have done this after I was almost done with class diagram and know what to be done in sequence diagrams. This helped me with all the components that would go under various tiers.

Deployment Diagram:
This was a very good learning experience in whole of the project. Having worked for multinational companies all through my career, I never go to involve myself in hardware discussions. I did however have experience working on a projects where I had to make decisions on over all architecture (Firewalls, load balancer, server clustering, hot backups etc). This was the strategy that I have followed before deciding on the hardware profile and the vendor that would host my application

  • In-house hosting costs vs Outsourcing hosting costs
  • Privacy compromises for in-house vs outsourcing.
  • Licensing costs
  • Resource costs for maintenance

For my project, privacy was not a concern (added this to assumption as well) and the cost of hosting in house by buying a server was too high (Eg: Cost of IBM Power 710 Server, 4 core 4.2 Ghz with 8GB RAM, Rack mount 2 x 146 GB SFF Harddisk (IBM AIX 5.3 operating system) is $6255 without other licensing costs and resource costs). I have decided to outsource hosting for my application. The advantage in my case for outsourcing was that maintenance costs(possibly licensing costs) were included in hosting costs.

For Outsourcing I have looked at two options

  • Rent Physical Server: I have looked into multiple providers but the cheapest option was provided by rackspace.com. It costs $262.80/month for box with 4GB RAM, 2 core 160 GB disk space (Linux operating system)
  • Cloud Solution: Again there were multiple that provided cloud solutions but I best I found was Amazon Elastic Compute Cloud (Amazon EC2) service. The price for ‘3 year upfront option’ for ‘M1 Large Instance’ $384.

I have decided to go for Amazon Ec2 as it had other advantages.

Amazon Elastic Compute Cloud (Amazon EC2) services seem to be secure, reliable and have scalability options for increased traffic in future.

  • Load Balancing: This service provides elastic load balancing which automatically distributes incoming application traffic across multiple Amazon EC2 instances. This has capability to detect unhealthy instances within a pool and automatically reroute traffic to healthy instances.
  • Hardware/Software Application Server – Primary: I chose ‘M1 Large Instance’ option which provides 7.5 GB of memory, 4 EC2 Compute units (2 Virtual cores with 2 EC2 compute units each, 850 GB of disk space, 64-bit platform). Operating System is Red Hat Enterprise Linux. Application Server is IBM Websphere.
  • Application Server – Backup:  I chose ‘M1 Medium Instance’ option which provides 3.75 GB of memory, 2 EC2 Compute Units (1 Virtual core with 2 EC2 Compute units each, 410 GB of disk space, 64 bit platform). Operating System is Red Hat Enterprise Linux. Application Server is IBM Websphere.
  • Database (Primary/Backup): The package selected above comes with local installation of database. Following were chosen for this application:
    • Microsoft SQL Server-Standard
    • Windows 2008 R2 6.1 (Operating System)
  • Scalability: Amazon EC2 services provide auto scaling which scales up automatically to maintain performance in case of spikes.
  • Pricing:
    • Application Server+Database(primary) – 3 year upfront option for $384 (Amazon EC2 offers various options but this is the cheapest)
    • Application Server+Database(Backup) – 3 year upfront option for $192
    • Projected operating budget for hardware/software for 3 years = $384 + $192= $576

Assumptions:
I had about 10 assumptions. I have put all assumptions that effected my design/hardware/software decisions.

Risks and Mitigation Plan:
I had about 12-15 risks and mitigations strategies listed. I have sorted the risks in the order of their importance so that the top risk is shown at the top.

Documentation:
I have provided some extensive write-up for each section. I wanted to make sure that all my thoughts were put in there as my main motto was to make sure that evaluator understands everything that I had in mind. A lot of documentation was done as I was doing UML diagrams to diversify my work.

Creating Jar file:
I have zipped all my files and changed the extension to .jar. (We can as well create a jar from command prompt – google it).

SCEA blogs:

Reference Material:

Questions I had and how I addressed them:

  • How detail should class diagram be?
    Pretty detail, but make sure that details like patterns, methods, method parameters are visible. I advice to not include any classes that would add clutter (DTO, Transfer objects, Value Objects etc.). Don’t compromise on quality of class diagram for other factors like restricting class diagram to one page.
  • Do I have to show jsps in class diagram?
    Yes.
  • Should I show DTO/Transfer Objects/Value Objects ?
    You have to decide if this makes any sense to show them. I didn’t show any DTO, Transfer Objects and Value Objects. I just mentioned them as parameters in methods and I did mention them in my write up for class diagram.
  • Should getter/setter methods in a class be shown?
    No.
  • What tool did I use for UML diagrams?
    MS Visio 2010
  • What format of images did I use for UML diagrams?
    I have converted all my UML diagrams to PNG format. I found this format to be more compact in size without any compromise in quality.
  • How did I convert UML diagrams to images?
    I have used SnagIt. SnagIt has settings to capture a scrolling page and later I have cut the unwanted area and saved the image in PNG format.

My other posts related to SCEA: SCEA/OCMJEA Experience (Step-1), SCEA/OCMJEA Essay

SCEA/OCMJEA Experience (Step 1)

This post has been moved to http://srinichekuri.com/2012/11/30/scea-experience-step-1/

**********************************************************************

Few days back I got through SCEA Step-1 with 82%. I wanted to blog my experience for those who are taking this exam and looking for advice.

I have first thought of taking this exam more than a year ago. I have started preparing for this exam about the same time. Also I took a course for SCEA offered through WhizLabs. First thing, I should say is if you have experience working on Java/J2ee technologies you don’t have to take any course. The course that I took didn’t offer me much help expect to let me know that I will have to read before I take this exam. The exam requirements changed after I took this training (now Oracle wants us to take a course before getting certified).

Anyways when I made up my mind to take this exam again couple of months back, I started off with a blank mind researching on how should I get started. After some research I had a plan of action:

Below is detailed description of the preparation for various sections that needs to be prepared:

Section 1: Application Design Concepts and Principles
Mikalai Zaikin’s SCEA Notes
I knew about design concepts but there were few things that I picked up from these notes. Anyways I felt that his notes should be good enough for people who are preparing for exam. Let me caution you that you should understand this chapter in detail as the concepts in this chapter form a base for lot of design questions for exam.

Section 2: Common Architectures
Mikalai Zaikin’s SCEA Notes

Section 3: Integration and Messaging
Adel Almoshaigah SCEA Notes
I made my notes based on Adel’s notes. I had good enough knowledge on Messaging but had to understand JCA in detail and I felt that his notes gave idepth information on JCA.

Section 4: Business Tier Technologies
Adel Almoshaigah SCEA Notes
I made my notes based on Adel’s notes. I knew pretty much all the information in this topic due my experience as developer on this topic. I read EJB3 in Action book to know more details about EJB3. I didn’t go in depth into programming while reading this book.

Section 5: Web Tier Technologies
Adel Almoshaigah SCEA Notes
I made my notes based on Adel’s notes. I knew pretty much all the information in this topic due my experience as developer on this topic.

Section 6: Applicability of Java EE Technology
Adel Almoshaigah SCEA Notes

Section 7: Patterns
Mikalai Zaikin’s SCEA Notes
Core J2EE Patterns
Design Patterns

Mikalai Zaikin notes is based on the prescriped books. There were few patterns that I knew out right from my experience but there we few that were completely new to me and there were few that confused me as they looked the same to me. That’s where books played a big role. Books have a very detailed description on the patterns and when and where they are used. I have made my own notes that made me understand the patterns better.

Section 8: Security
Mikalai Zaikin’s SCEA Notes.

Notes cover all the needed information in detail. Although I knew about few topics in bits and pieces, this section was completely new to me. I had to go through this chapter multiple times to understand few things.

Dos:
Make your own notes for each topic so that you can concentrate more on topics that you are not good yet.
Understand the concept enough to be able to apply the concept in various scenarios.
Train yourself to understand the question enough to choose the right answer. (The gramnmer used in exam is confusing lot of times). I can’t stress on this point enough because there are lot of questions in exams where you need to read and should be able to filter out unnecessary information and make a decision by processing the right information.

Don’ts:
Don’t memorize any concepts because it will only lead to more confusion
Don’t expect exam to use any words/phrases from the prescriped books
Don’t always concentrate on exam objectives, read to gain knowledge. This will help to crack design questions in exam easily and you will be prepared psychologically for any questions that might surprise you in exam.

For practice I bought practice questions from test king. I have bought practice questions from test king for all my certifications and they have never disappointed me. I would recommend test king for SCEA too, it had 300 odd questions for practice and I have done some 250 for practice and they helped me a lot. Practice questions till you are very comfortable with the pace at which you read, able to understand the questions at ease and are able to get reasonable amount of questions correct.

Exam Experience:
I have taken my test in Pearson test center. I reached there 30 minutes early and I was allowed to take the test 15 minutes before my scheduled time. After taking many certifications I trained myself to give equal importance to all the questions and I would suggest everyone to follow the same. When ever I stumbled on some question, I would just give it my best shot, mark the question (if you have taken certification tests earlier, you would know about this feature. You can mark a question for review later) and move on. I was able to complete the test in about 90 minutes. Then I went back to my marked questions, gave them a second thought. I clicked on finish button about 10 min before finishing mark.

My other posts related to SCEA: SCEA/OCMJEA Assignment, SCEA/OCMJEA Essay

Hope this information will help you and all the best for aspirants of SCEA.
thanks,
-Srini.

OutOfMemory Exceptions, WebSphere 6.1

This post has been moved to http://srinichekuri.com/2012/08/30/outofmemory-exceptions-websphere-6-1/

**********************************************************************

OutOfMemory Exceptions, WebSphere 6.1, Windows Server

One common solution suggested when there are OutOfMemory exceptions is to increase the heap size. There is lot of misconception among developers that maximum heap size can be increased to amount of physical memory on which server is running, but this is not true. A lot depends on the Operating system you are running your server on. In this post I will talk about increasing the heapSize for websphere running on windows.

There are two types of configurations depending on the memory space allocated to Java process in Windows:

Windows (32-bit):
With default configuration:
1.8 GB (Max allowed) – 1.5 GB (Max recommended by IBM)
With 3GB Enabled (Look below for procedure to make this change):
1.8 GB (Max Allowed) – 1.8 GB (Max recommended by IBM)

Window (64-bit) –  Memory allocated for Java process in this setup is pretty large so IBM sets no maximum limit.

Source: http://publib.boulder.ibm.com/infocenter/javasdk/tools/index.jsp?topic=%2Fcom.ibm.java.doc.igaa%2F_1vg00014884d287-11c3fb28dae-7ff6_1001.html

 

Enabling 3GB in Windows:

  • Right-click My Computer. Click Properties.
  • In the System Properties dialog box, click the Advanced tab.
  • On the Advanced tab, under Startup and Recovery, click Settings.
  • In the Startup and Recovery dialog box, under System startup, click Edit. The Windows boot.ini file will be opened in Microsoft® Notepad.
  • Create a backup copy of the boot.ini file. Note: Boot.ini files may vary from computer to computer.
  • Select the following line in the boot.ini file:
    multi(0)disk(0)rdisk(0)partition(2)\WINDOWS=”Microsoft Windows XP Professional” /fastdetect
  • Press Ctrl+C to copy the line and then press Ctrl+V to paste it immediately below the original line.
    Note: Your text string may be different from the text string in this solution, so be sure to copy the text string from your boot.ini file, and not the text string included here.
  • Modify the copied line to include “ /3GB”, as shown in the following example:
    multi(0)disk(0)rdisk(0)partition(2)\WINDOWS=”Microsoft Windows XP Professional 3GB” /3GB /fastdetect
    Note: Do not overwrite any existing lines.
  • Save and close the boot.ini file.
  • Click OK to close each dialog box.
  • Restart your computer.

During startup, select the 3GB option. If you do not select the 3GB option, the system will default to the 2GB total memory setting.
Note: If problems occur during startup, you may try to resolve the issue by updating some of your drivers.  However, recall the notice at the beginning of this solutions that note all Windows update or hardware and graphics drivers work with the 3GB switch enabled.

Source:  http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=9583842&linkID=9240697