Recent Notes
Displaying keyword search results 1 - 10
Created by Fang on March 30, 2012 10:23:21
Last update: March 30, 2012 10:23:21
These bean types are essential for the Spring MVC framework. I copied them here from the Spring Documentation for quick reference. Bean type Explanation HandlerMapping Maps incoming requests to handlers and a list of pre- and post-processors (handler interceptors) based on some criteria the details of which vary by HandlerMapping implementation. The most popular implementation supports annotated controllers but other implementations exists as well. HandlerAdapter Helps the DispatcherServlet to invoke a handler mapped to a request regardless of the handler is actually invoked. For example, invoking an annotated controller requires resolving various annotations. Thus the main purpose of a HandlerAdapter is to shield the DispatcherServlet from such details. HandlerExceptionResolver Maps exceptions to views also allowing for more complex exception handling code. ViewResolver Resolves logical String-based...
Created by Dr. Xi on May 02, 2011 15:59:37
Last update: February 25, 2012 09:16:37
This code snippet gets the default keystore used by the Java keytool and displays the list of aliases along with the key type (certificate or private key).
import java.io.File;
import java.io.FileInputSt...
The default keystore used by the above code is: $HOME/.keystore .
Created by Fang on February 21, 2012 20:33:58
Last update: February 21, 2012 20:33:58
You can customize Tomcat error page with error code:
<error-page>
<error-code>404</error-code>
...
or Java exception type:
<error-page>
<exception-type>java.lang.Throwab...
Either error-code or exception-type is required, but not both. There's no way to aggregate error codes, such as:
<!-- This does not work! -->
<error-page>
...
Customizing error pages is about the only way to suppress the default stack trace in Tomcat in case of an unhandled exception.
Created by Fang on November 10, 2011 09:26:12
Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines!
<?xml version="1.0" encoding="UTF-8"?>
<xsd:sch...
Created by Fang on September 07, 2009 20:44:15
Last update: November 03, 2011 14:43:19
Step 1: Repackage a web app as EAR A Java EE application is a multimodule Maven project. At the very least you'll need to package a WAR and an EAR. To get started, I'll simply re-package the simple webapp as an EAR. Create a directory named javaee-app Copy the webapp from here to javaee-app . Rename struts1app to webapp . Create pom.xml under javaee-app :
<project> <modelVersion>4.0.0</modelVersion>... Create a directory named ear under javaee-app . Create pom.xml under ear : <project> <modelVersion>4.0.0</modelVersion>... Modify pom.xml in the webapp directory so that it looks like this: <project> <modelVersion>4.0.0</modelVersion> ... Build with " mvn package " in the javaee-app directory. You can see that ear-1.0.ear is successfully generated in javaee-app/ear/target . Maven successfully resolves dependencies between the sub-projects....
Created by freyo on May 13, 2011 15:45:29
Last update: September 20, 2011 08:08:12
This is an Android app that dumps any binarized xml file as plain text - to the sdcard on the device or emulator.
build.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project...
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<man...
res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<Lin...
res/values/strings.xml :
<?xml version="1.0" encoding="utf-8"?>
<res...
src/com/android/xmltool/DumpXml.java
package com.android.xmltool;
import java.ut...
Screenshot
Pre-built APK can be downloaded from: http://code.google.com/p/android-binxml-dump/
Created by magnum on September 11, 2011 21:31:45
Last update: September 11, 2011 21:32:00
The warning message was emitted by the gcc compiler with the " -Wdeclaration-after-statement " switch:
$ gcc -Wdeclaration-after-statement hello.c
for the following code:
#include <stdio.h>
int main(int argc, char* arg...
There were no warnings without the " -Wdeclaration-after-statement " switch. GCC manual says:
-Wdeclaration-after-statement (C and Objective-C only)
Warn when a declaration is found after a statement in a block. This construct, known from C++, was introduced with ISO C99 and is by default allowed in GCC. It is not supported by ISO C90 and was not supported by GCC versions before GCC 3.0.
Created by alfa on June 02, 2011 15:26:37
Last update: June 02, 2011 15:26:37
While doing some Java reflection code, I noticed the method Class.isSynthetic() , which the JavaDoc says returns " true if and only if this class is a synthetic class as defined by the Java Language Specification". However, there's no definition of "synthetic class" in the JLS ! The only thing that I can find that remotely resembles a definition is in the JVM spec , where it defines the synthetic attribute : "The Synthetic attribute is a fixed-length attribute in the attributes table of ClassFile (§4.1), field_info (§4.5), and method_info (§4.6) structures. A class member that does not appear in the source code must be marked using a Synthetic attribute." By this definition, a default constructor, which does not appear in the source code, should...
Created by alfa on June 02, 2011 13:04:18
Last update: June 02, 2011 13:04:18
Some javap usage examples.
Start from HelloWorld.java :
@Deprecated
public class HelloWorld {
pu...
javap -c HelloWorld outputs:
Compiled from "HelloWorld.java"
public class He...
javap -v HelloWorld outputs ( -v for verbose mode):
Compiled from "HelloWorld.java"
public class He...
The output consists of:
" Compiled from... " header
Class attributes. For the HelloWorld example, there are two: SourceFile and Deprecated .
Minor and major class file version
Constant pool
Disassembled code
LineNumberTable for debugging purposes.
javap by default only prints package/protected/public members. To display all members including private, use the -p switch.
javap -v -p HelloWorld
Created by freyo on May 27, 2011 12:57:46
Last update: May 27, 2011 12:58:27
The uses-library tag specifies a shared library that the application must be linked against. This element tells the system to include the library's code in the class loader for the package.
All of the android packages (such as android.app , android.content , android.view , and android.widget ) are in the default library that all applications are automatically linked against. However, some packages (such as maps ) are in separate libraries that are not automatically linked.
To get a list of available library names:
String[] libraryNames = getPackageManager().getSys...