is it giving u goose bump?
come play with me by *DaStafiZ on deviantART
I almost wish I hadn't gone down that rabbit-hole — and yet — and yet — it's rather curious, you know, this sort of life!
Sunday, December 23, 2007
Saturday, December 22, 2007
struts2+Spring workflow
1. An initial request goes to the Servlet container (such as Jetty or Resin) which is passed through a standard filter chain.
2. the required FilterDispatcher is called, which in turn consults the ActionMapper to determine if the request should invoke an action.
3. The ActionMapper interface provides a mapping between HTTP requests and action invocation requests and vice-versa.
4. The ActionProxy consults the framework Configuration Files manager (initialized from the struts.xml file).
5. the ActionProxy creates an ActionInvocation, which is responsible for the command pattern implementation. This includes invoking any Interceptors (the before clause) in advance of invoking the Action itself.
6. Once the Action returns, the ActionInvocation is responsible for looking up the proper result associated with the Action result code mapped in struts.xml.
7. The result is then executed, which often (but not always, as is the case for Action Chaining) involves a template written in JSP or FreeMarker to be rendered.
8. While rendering, the templates can use the Struts Tags provided by the framework.
9. All objects in this architecture (Actions, Results, Interceptors, and so forth) are created by an ObjectFactory.
This ObjectFactory is pluggable. We can provide our own ObjectFactory
A popular ObjectFactory implementation uses Spring as provided by the Spring Plugin.
Normally, in struts.xml you specify the class for each Action. When using the default SpringObjectFactory, the framework will ask Spring to create the Action and wire up dependencies as specified by the default auto-wire behavior.
10. Interceptors are executed again (in reverse order, calling the after clause).
11. Finally, the response returns through the filters configured in the web.xml.
N.B:
don't know how to setup simple struts2 project? see simple setup
2. the required FilterDispatcher is called, which in turn consults the ActionMapper to determine if the request should invoke an action.
3. The ActionMapper interface provides a mapping between HTTP requests and action invocation requests and vice-versa.
When given an HttpServletRequest, the ActionMapper may return null if no action invocation request matches, or it may return an ActionMapping that describes an action invocation for the framework to try.
If the ActionMapper determines that an Action should be invoked, the FilterDispatcher delegates control to the ActionProxy.4. The ActionProxy consults the framework Configuration Files manager (initialized from the struts.xml file).
5. the ActionProxy creates an ActionInvocation, which is responsible for the command pattern implementation. This includes invoking any Interceptors (the before clause) in advance of invoking the Action itself.
6. Once the Action returns, the ActionInvocation is responsible for looking up the proper result associated with the Action result code mapped in struts.xml.
7. The result is then executed, which often (but not always, as is the case for Action Chaining) involves a template written in JSP or FreeMarker to be rendered.
8. While rendering, the templates can use the Struts Tags provided by the framework.
9. All objects in this architecture (Actions, Results, Interceptors, and so forth) are created by an ObjectFactory.
This ObjectFactory is pluggable. We can provide our own ObjectFactory
A popular ObjectFactory implementation uses Spring as provided by the Spring Plugin.
Normally, in struts.xml you specify the class for each Action. When using the default SpringObjectFactory, the framework will ask Spring to create the Action and wire up dependencies as specified by the default auto-wire behavior.
10. Interceptors are executed again (in reverse order, calling the after clause).
11. Finally, the response returns through the filters configured in the web.xml.
N.B:
don't know how to setup simple struts2 project? see simple setup
Monday, December 10, 2007
The 5 stages of grief
1. Denial: The initial stage: "It can't be happening."
2. Anger: "Why ME? It's not fair!" (either referring to God, oneself, or anybody perceived, rightly or wrongly, as "responsible")
3. Bargaining: Now the grieving person may make bargains with God, asking, "If I do this, will you take away the loss?"
4. Depression: "I'm so sad, why bother with anything?"
5. Acceptance: "It's going to be OK."
Kübler-Ross model
Wednesday, December 05, 2007
SCP using java api
same as SFTP example except use ScpClient in place of SFTPClient
syntax highlighted by Code2HTML, v. 0.9.1
ScpClient client = ssh.openScpClient();
// Open the SCP channel
String localFile = "localPath";
String remoteFile = "remotePath";
//
//get method signature
//public void get(java.lang.String localFile,
// java.lang.String remoteFile,
// boolean recursive,
// FileTransferProgress progress)
// throws SshException,
// ChannelOpenException
//
client.get(localFile,remoteFile,true);
syntax highlighted by Code2HTML, v. 0.9.1
SFTP using java api
Librery used SSHTools-J2SSH
Tutorial help from David Hayes
syntax highlighted by Code2HTML, v. 0.9.1
Tutorial help from David Hayes
1
2 String userName = "someuser";
3 String password = "somepwd";
4
5 String host = "host_ip";
6 int port = 22;
7
8 String destinationPath = "<your_dest>";
9 String sourcePath = "<your_src>";
10
11 SshClient ssh = new SshClient();
12
13 try{
14 ssh.connect(host, port);
15
16 // Authenticate
17 PasswordAuthenticationClient passwordAuthenticationClient =
18 new PasswordAuthenticationClient();
19
20 passwordAuthenticationClient.setUsername(userName);
21 passwordAuthenticationClient.setPassword(password);
22
23 int result = ssh.authenticate(passwordAuthenticationClient);
24 if(result != AuthenticationProtocolState.COMPLETE){
25
26 throw new FTPException("Login to " + host + ":"
27 + port + " " + userName + "/" + password + " failed");
28
29 }
30
31 // Open the SFTP channel
32 SftpClient client = ssh.openSftpClient();
33 //change local directory where file would be copied
34 client.lcd(destination);
35 // download file
36 client.get(sourceFilePath);
37
38 client.quit();
39 ssh.disconnect();
40
41 }
42 catch(IOException e)
43 {
44
45 // file transfer failed
46 e.printStackTrace();
47 }
syntax highlighted by Code2HTML, v. 0.9.1
Tuesday, December 04, 2007
Writing pdf file using java
Librery used iText
syntax highlighted by Code2HTML, v. 0.9.1
check other tutorials
// Step 1: Create an instance of com.lowagie.text.Document:
Document document = new Document();
//Step 2: Create a Writer (for instance com.lowagie.text.pdf.PdfWriter)
//that listens to this document and
//writes the document to the OutputStream of your choice:
PdfWriter.getInstance(document, new FileOutputStream("HelloWorld.pdf"));
//Step 3: Open the document:
document.open();
//Step 4: Add content to the document:
document.add(new Paragraph("Hello World"));
//Step 5: Closes the document:
document.close();
syntax highlighted by Code2HTML, v. 0.9.1
check other tutorials
Subscribe to:
Posts (Atom)