Sunday, June 05, 2011

JSF 1.2 (Mojarra) Reference Implementation (RI) on Google App Engine

Image representing Google App Engine as depict...Image via CrunchBase
I am working on publishing the various methods for deploying JSF on Google App Engine. This example is deployed using JSF 1.2 reference implementation. I am using NetBeans 6.9.1 with the Google App Engine plugin. The code used is vanilla JSF with no additional frameworks.

The web.xml and Maven pom.xml files are posted on the deployed application which is running on the App Engine itself.

The implementation can be found here: http://gae-jsf12.bluelotussoftware.com/
Enhanced by Zemanta

Saturday, June 04, 2011

Java Architecture for XML Binding (JAXB) Article

I was looking over the Java Architecture for XML Binding (JAXB) By Ed Ort and Bhakti Mehta from March 2003. It is a very good tutorial on JAXB, but it needed a little updating on some of the example code.

I am not sure how to get the code updated so, I will provide my modified version of UsingJAXBTest1. It uses generics, StringBuilder, and an enhanced for loop. I also removed some deprecated methods. Here is my new modified version with the original copyright.

UsingJAXBTest1


/**
 * $Id: UsingJAXBTest1.java,v 1.1 2003/01/01 03:18:32 bhakti Exp $
 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of Sun
 * Microsystems, Inc. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Sun.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 */
package test.jaxb;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.util.List;

/**
 * This shows how to use JAXB to unmarshal an xml file
 * Then display the information from the content tree
 * @author bhakti
 * @author John Yeary
 */
public class UsingJAXBTest1 {

    public static void main(String args[]) {
        try {
            JAXBContext jc = JAXBContext.newInstance("test.jaxb");
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            Collection collection = (Collection) unmarshaller.unmarshal(new File("books.xml"));
            Collection.Books booksType = collection.getBooks();
            List<BookType> bookList = booksType.getBook();
            StringBuilder sb = new StringBuilder();

            for (BookType book : bookList) {
                sb.setLength(0);
                sb.append("Book  details\n");
                sb.append("Item id: ");
                sb.append(book.getItemId());
                sb.append("\n");
                sb.append("Book Name: ");
                sb.append(book.getName().trim());
                sb.append("\n");
                sb.append("Book ISBN: ");
                sb.append(book.getISBN());
                sb.append("\n");
                sb.append("Book Price: ");
                sb.append(book.getPrice().trim());
                sb.append("\n");
                sb.append("Book category: ");
                sb.append(book.getBookCategory());
                sb.append("\n");
                sb.append("Book promotion: ");
                sb.append(book.getPromotion().
                        getDiscount().trim());
                sb.append("\n");
                sb.append("No of Authors ");
                sb.append(book.getAuthors().getAuthorName().size());
                sb.append("\n");

                BookType.Authors authors = book.getAuthors();
                for (int j = 0; j < authors.getAuthorName().size(); j++) {
                    String authorName = authors.getAuthorName().get(j);
                    sb.append("Author Name ");
                    sb.append(authorName.trim());
                    sb.append("\n");
                }
                System.out.print(sb.toString());
            }

        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }
}

Wednesday, June 01, 2011

OSCON 2011- Committee Discount Code

Anyone attending OSCON Java in July will want to use the discount code provided to the committee members.

Please use OS11COM to get a 20% discount for attending the event.

It was an honor and privilege to review papers for OSCON, and OSCON Java, and I hope everyone who attends likes the speakers that we selected to speak. I am excited about the event, and I hope you will be too. This is the inaugural event for OSCON Java and I hope there will be many more.

Popular Posts