The purpose of life is not to win. The purpose of life is to grow and to share. When you come to look back on all that you have done in life, you will get more satisfaction from the pleasure you have brought into other people's lives than you will from the times that you outdid and defeated them.
Showing posts with label Technology. Show all posts
Showing posts with label Technology. Show all posts

How to freeze Rails to a older version?

Navigate to project directory and issue the below command.

rake rails:freeze:gems VERSION=x.x.x

Installing MySQL with Ruby Gem

Most of the official guides would recommend to install MqSQL database as
$gem install mysql

This won't work for sure in Windows platform. First setup your proxy. To know more please visit Rails Sucks. And finally after proxy setting setup issue the below command.

$gem install mysql -- --with-mysql-lib=/usr/local/mysql/lib

XML Parsers

Five types of XML Parsers.

Event based push: SAX, XNI
Event based pull: StAX, XMLPull
Tree: DOM, JDOM , dom4j
Data Binding: JAXB, Castor
Query API: TrAX

Source: http://www.artima.com/intv/xmlapis2.html

Push APIs have a number of advantages. They are very fast. You don't need to read to the end of the document before you start working with the beginning of the document. They use very little memory, because the entire document isn't in memory at once. Instead, you just see sort of a peephole into the document, just the current thing you're looking at. Typically in a push API the work goes into building up some data structure and gradually filling it from the input document until there is enough information there to act on. If you're document is, for example, a collection of articles, a list of records, something for which there are clear chunks in the data and you can process each chunk individually, a push API works very well.

On the other hand, the whole callback interface observer design pattern can be less than ideal for some developers. This brings us to the second major style of XML API, and the newest style: a pull API. A pull API is still streaming, still very fast, still very memory efficient. But instead of the parser being in control, telling the client application when it has some new information, the client application is in control, and it asks the parser to give it the next piece of information when it wants it. But the basic advantages of a pull API are the same as with a push API, except maybe the pull API is little simpler. The implementations of the various pull APIs are not very mature yet. When you actually look at the ones out there—NekoPull, XMLPULL—they have a lot of idiosyncracies both with respect to Java and XML. That's mostly just a function of maturity. There's nothing fundamentally wrong with the idea of a pull API. They're not just fully baked yet. With a little time, in a year or two, I expect pull APIs will be a very popular style of XML parsing.

The third style of XML parsing, and perhaps the most obvious style to most programmers, is a tree-based API. In a tree-based API, an XML document is read by a parser, and the parser constructs an object model, typically around a tree with nodes for elements , attributes, comments, processing instructions, text, and so forth. The entire document is stored in memory. You use the methods of the object to query the document, to navigate the document, to change and modify the document, and so forth. There are more tree-based APIs than any other kind of API: DOM, JDOM, DOM4J, Sparta, ElectricXML, and my own XOM are all tree-based APIs.

The fourth style of API, which is also a fairly recent style, is a data-binding API. It is similar to tree APIs in that the entire document is parsed and an object model is built, but in a data binding API rather than having classes which represent XML concepts, like element and processing instructions, you have classes that represent the concepts the XML represents. So a book element might become a Book object. An employee element might become an Employee object. Typically, some form of schema is compiled to produce these classes automatically. Either a W3C XML schema language schema, a DTD, or a special purpose binding schema written just for that purpose in some special purpose schema language.

And then finally the fifth kind of API is what I would refer to as a query API. These would typically be things like TrAX for transforming with XSLT, or various APIs like Jaxen for searching with XPath. There are no real standards here, but there is some interesting work being done. Generally there the real focus, the real code, goes into the XPath or XSLT query, which we merely call from Java or some other language. It's like using SQL from inside a Java program using JDBC.

BPEL vs XPDL

BPEL:

BPEL is an execution language for Business Process which it achieves via Web service interactions.

Pros:

1. BPEL is powerful since it is based on orchestration mechanism. Since there are lot of WS* specifications, BPEL is tipped to support WS* specs more effectively than XPDL, due to the fact that BPEL itself is based on Web service interactions.
2. Even though XPDL and BPEL are open standards, BPEL is embraced by more vendors, like IBM Websphere Process Server, Oracle BPA, jBPM.
3. BPEL evangelists claim that a BPEL generated by one tool can be executed in any of the process engines. I'm not sure whether this is possible always.

Cons:

1. BPEL spec is too difficult to understand and complicated.
2. The time taken to develop a BPEL process takes more time than BPMN+XPDL process.
3. Not human friendly - however BPEL4People/WS-HumanTask are intended to help BPEL.

BPMN + XPDL:

XPDL schema transforms BPMN representation to process engine executable language.

Pros:

1. BPMN is human readable. Captures, process semantics and graphical details.
2. XPDL is easily extendable. Provides more scope for BPM product vendors since, XPDL is easily extendable to provide proprietary add-ons.
3. Even though not embraced like BPEL, its immensely popular among the best selling BPM products, like Savvion, Aqua Logic, iProcess, Global 360, EMC, Adobe, Cape Vision.

Cons:

1. Vision for support on WS* specs are very poor.
2. XPDL is becoming very product dependent, since product vendors extend it by putting add-ons.

My personal opinion is both XPDL and BPEL are still immature and we have to wait and watch, which among these two become widely adopted. BPEL process getting executed on any process engine is still not a reality. Its like EJB being deployable on any App server promised by J2EE spec, but the reality is lot deviated from the stated premise.

Why BPEL Matters?

Top 5 reasons to choose Rails

I've worked on Rails to a certain extent and my top 5 reasons why I would choose rails to design my next app are,
1. Convention over configuration. This enables to set up the application, database configurations, and MVC stuff literally in minutes.
2. Active Record - Built in ORM. Domain object model can be configured easily and can be translated to Database. In J2EE or .Net this would require a lot of XML configurations and corresponding database mappings.
3. Support for REST (Representational state transfer). Rails have an implicit support for REST unlike J2EE and .Net.
4. Test Unit - Embraces test driven development.
5. Every dependency is a gem - Project related dependencies/libraries can be easily downloaded as gem install XXX.
However, the main criticism for Rails being scalability and non-availability of standard tool-set for development. My bet on Rails would be for trivial applications web apps.

How to crack the SCDJWS ?..

The wikipedia says SCDJWS is the toughest and the most respected Sun Certification.
http://en.wikipedia.org/wiki/Sun_Certified_Professional#Sun_Certified_Developer_for_Java_Web_Services_.28SCDJWS.29
Very true indeed.

I scored 79% (55/69). Here's the split up.

XML Web Service Standards 80%
SOAP 1.1 Web Service Standards 83%
Describing and Publishing (WSDL and UDDI) 100%
JAX-RPC 85%
SOAP and XML Processing APIs (JAXP, JAXB and SAAJ) 100%
JAXR 75%
J2EE Web Services 71%
Security 75%
Developing Web Services 66%
General Design and Architecture 50%
Endpoint Design and Architecture 80%

Preparation Plan

1. RMH Book for XML Basics, Namespaces, Schemas, SOAP, WSDL
2. Rest of the chapters - MZ notes. - javaboot
3. xyzws.com mock exams

The questions in the real exam were little tough than xyzws mocks. It wasn't that straight forward, but with little thinking it can be answered.

I did practise a little with all the APIs. I hosted a Web Service using JAX-RPC, wrote some schemas and compiled it. I used the tomcat for java web services developer pack.

CSV Parser in Java

public class CSVParser {

public static final String CSV_REGEX_PATTERN = "\"([^\"]+?)\",?([^,]+),?,";
public static final String TSV_REGEX_PATTERN = "\t{1}";
public static Pattern csvRE;
public static Pattern tsvRE;

static {
csvRE = Pattern.compile(CSV_REGEX_PATTERN);
tsvRE = Pattern.compile(TSV_REGEX_PATTERN);
}

private List parse(String line) {

List list = new ArrayList();
Matcher m = csvRE.matcher(line);

// For each field
while (m.find()) {
String match = m.group();
if (match == null)
break;
//this will remove trailing , - comment this out if we dont want that affect
if (match.endsWith(",")) {
match = match.substring(0, match.length() - 1);
}
if (match.startsWith("\"")) {
match = match.substring(1, match.length () - 1);
}
if (match.length() == 0)
match = null;
list.add(match);
}

return list;
}

}

How to configure JMeter for your Web Application ?..

How to start ?..
From intranet network, we need to pass through the proxy, and here is the command to start JMeter via proxy.
Please navigate to the bin of the JMeter root directory and fire the following command
C:\project\jakarta-jmeter-2.2\jakarta-jmeter-2.2\bin>jmeter -H proxy.network.net -P 8080 -u -a
Create a Test Plan
1. The JMeter's left side pane contains a Test Plan and WorkBench Item.
2. Click on Test Plan Item.
3. Type in an appropriate name in the Test Plan name text box.
Add a Thread Group
1. Right click on the Test Plan Item
2. Naviagate to Add menu item.
3. Click on Thread Group
4. Name the thread group appropriately.
5. Enter the number of threads (users), ramp up count and loop count appropriately.
Add a Http Request Defaults
1. Right click on the Thread Group which has been created.
2. Naviagate to Add menu item.
3. Navigate to Config Element menu item.
4. Click on Http Request Defaults
Configure Http Request Defaults
1. Click on Http Request Defaults which has been newly created.
2. Enter the following details.
Name: give one
Server Name or IP: stage.com
Port Number:
Protocol: https
Path: /

Add Http Cookie Manager
1. Right click on the Thread Group which has been created.
2. Naviagate to Add menu item.
3. Navigate to Config Element menu item.
4. Click on Http Cookie Manager
Why do we need this ? - to be updated later
Add a Http Request
1. Right click on the Thread Group which has been created.
2. Naviagate to Add menu item.
3. Navigate to Sampler menu item.
4. Click on Http Request
Configure Http Request
1. Click on the Http Request item which has been created.
2. Enter the following details.
Name: Login
Method: Choose POST
Path: /security.AuthenticationServlet.serv
Follow Redirects: Check it.
3. Click on the Add button, to add request parameters.
Name Value Encode Include Equals
j_username hello_bosss no yes
j_password password yes yes
Add Results
1. Right click on the Thread Group which has been created.
2. Naviagate to Add menu item.
3. Navigate to Listener menu item.
4. Click on View Results Tree
Configure SSL Manager
1. Download the digital certificate.
2. Goto STAGE URL from the browser window.
3 Click on View button, when the security window pops up.
4. Goto Details tab
5. Click on Copy to File .. button.
6. Save the file to disk.
7. Navigate Options Menu in JMeter dialog screen.
8. Click on SSL Manager.
9. Enter the digital certificate file name with the path in the File Name: text box.
10. Click Open button.
11. Click Ok/Cancel if ask for a KeyStore password. The default password is 'changeit'
Run Test
1. Navigate to Run menu.
2. Click on the Start menu item.
3. Click on the View Results Tree which you created to see the results.