Recent Notes
Displaying keyword search results 1 - 10
Created by Dr. Xi on March 22, 2013 12:18:39
Last update: March 22, 2013 12:18:39
This is a step-by-step guide to create a "contract-first" web service with Apache CXF. It's a lot easier than doing the same thing with Spring-WS. The project uses standard Maven directory layout. Define the data types ( src/main/resources/hello.xsd ):
<xs:schema xmlns:xs="http://www.w3.org/200... Define the service ( src/main/resources/hello.wsdl ): <?xml version='1.1' encoding='UTF-8'?> <wsdl:de... Create pom.xml : <project xmlns="http://maven.apache.org/POM/4.... Generate jaxb bindings: $ mvn generate-sources Code the web service ( src/main/java/com/example/cxfdemo/HelloPortImpl.java ): package com.example.cxfdemo; import javax.j... Declare the CXF servlet in web.xml ( src/main/webapp/WEB-INF/web.xml ): <?xml version="1.0" encoding="UTF-8"?> <web-app... Wire up the web service implementation ( src/main/webapp/WEB-INF/cxf-servlet.xml ): <?xml version="1.0" encoding="UTF-8"?> <beans x... Build the WAR: $ mvn clean package After the webapp is deployed (Tomcat running on port 8080), the web service (WSDL) is available via...
Created by Fang on January 04, 2013 08:00:37
Last update: January 04, 2013 08:00:37
This is a Maven POM that prints out some built-in project properties:
<project
xmlns="http://maven.apache.org/PO...
Output:
$ mvn validate
[INFO] Scanning for projects.....
Created by zhidao on August 09, 2012 14:44:08
Last update: August 09, 2012 14:44:08
Create a directory src/jaxws alongside src/main and create a bindings file bindingx.xml with the <serializable> customization:
<jaxb:bindings
xmlns:jaxb="http://java.sun....
Reference : JAX-WS wsimport Maven plugin documentation
Created by Fang on March 05, 2012 20:11:56
Last update: March 05, 2012 20:11:56
This is a bare bones Maven project to get started with Java JSR 303 bean validation.
Directory structure:
./pom.xml
./src
./src/main
./src/main/jav...
pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...
which includes dependencies on JUnit, Java bean validation API and the Hibernate validator reference implementation.
Created by Fang on January 10, 2010 00:19:30
Last update: January 31, 2012 16:28:42
Maven is a powerful yet complex tool. When I started learning Maven, the first obstacle was, of course, its complexity. The second, was the lack of documentation that can get me off the ground quickly. This tutorial is an attempt to create a pragmatic guide that aims to get you familiar with Maven in the quickest way possible. The main theme is to get you on some hands on experience to start out and lead you through the creation of a simple Java EE project as quickly as possible. Instead of trying to give you a good read, I try to get you on the journey right away. The topics are roughly ordered by the logical sequence but you can jump around in any way...
Created by Fang on January 31, 2012 15:40:34
Last update: January 31, 2012 15:41:28
This is a simple Hello World application with Spring 3 MVC. Like the default Apache HTTPd welcome page, it displays " It works! " when successfully deployed. The sole purpose is to show the minimum elements needed to setup Spring 3 MVC.
I use Maven since it's so much easier than downloading the dependencies manually.
Directory layout:
./src
./src/main
./src/main/webapp
./src/...
pom.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project...
WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app...
WEB-INF/applicationContext.xml (empty, but needed):
<?xml version="1.0" encoding="UTF-8"?>
<beans x...
WEB-INF/spring-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans x...
WEB-INF/jsp/home.jsp :
<!DOCTYPE html>
<html>
<head>
<title>H...
Build with:
mvn clean package
The resulting webapp is target/springmvc.war .
Created by Fang on January 28, 2012 13:24:09
Last update: January 28, 2012 13:31:22
This is a simple JSP custom tags library with tag body. Just like the JSF counterpart , it splits a string and repeats the body for each word, i.e., with this markup:
<%@ taglib uri="http://custom.tag.com/demo" prefix...
output:
<html>
<body>
<p>Hello Tigger!</p>
<p>H...
With Maven, this is the directory structure:
./src
./src/main
./src/main/resources
./s...
There are three files to write:
pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...
src/main/java/tagdemo/IterateTag.java :
package tagdemo;
import java.io.IOException...
src/main/resources/META-INF/demotag.tld :
<?xml version="1.0" encoding="UTF-8"?>
<!DO...
Build with:
mvn clean install
To use it as a dependency in other Maven projects:
<dependency>
<groupId>tag-demo</groupId>
...
Created by lokf on January 13, 2012 14:10:42
Last update: January 13, 2012 14:10:42
For some reason I don't know writing to files in Android is very complicated and tedious. Here is some code for those who might need it. Apps should write in the SD in the directory /Android/data/package_name/files/ so that it is deleted with the app uninstall. package randomname; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.ByteBuffer; import android.content.Context; import android.os.Environment; import android.util.Log; public class FileIOLibrary { String packageName; boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; FileIOLibrary(String packageNamep) { this.packageName=packageNamep; } public boolean isExternalStorageAvailable() { updateExternalStorageState(); return mExternalStorageAvailable; } public boolean isExternalStorageWritable() { updateExternalStorageState(); return mExternalStorageWriteable; } /** * writes the current state of SD card to the corresponding variables */ void updateExternalStorageState() {...
Created by Dr. Xi on January 06, 2012 14:02:09
Last update: January 06, 2012 14:02:09
In Java, the OS temporary directory is identified by the system property java.io.tmpdir :
public class TmpDir {
public static void ma...
Created by nogeek on December 30, 2011 13:25:28
Last update: December 30, 2011 13:57:37
By default, tomcat uses an enhanced java.util.logging implementation called JULI, which can be configured at two different levels: Globally, with the ${catalina.base}/conf/logging.properties file. Per web application, with WEB-INF/classes/logging.properties . The configuration file is a normal Java properties file: Logging handlers are specified with the handlers property.
handlers = 1catalina.org.apache.juli.FileHandler, ... The root logger can define its set of handlers using the .handlers property. .handlers = 1catalina.org.apache.juli.FileHandler,... A prefix may be added to handler names. The prefix starts with a digit and ends with a dot ( . ), for example: # 1catalina. is a prefix 1catalina.org.apache.j... System property replacement is performed for property values which contain ${systemPropertyName} . Each handler can have its own specific properties: 3manager.org.apache.juli.FileHandler.level = FINE ... Loggers can define their own...