alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Glassfish example source code file (VersionTemplate)

This example Glassfish source code file (VersionTemplate) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Glassfish tags/keywords

class_name, class_name, description, io, major_version, major_version, minor_version, string, string, stringbuffer, stringbuffer, upgrade_data, version

The Glassfish VersionTemplate source code

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2003-2010 Oracle and/or its affiliates. All rights reserved.
 *
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common Development
 * and Distribution License("CDDL") (collectively, the "License").  You
 * may not use this file except in compliance with the License.  You can
 * obtain a copy of the License at
 * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
 * or packager/legal/LICENSE.txt.  See the License for the specific
 * language governing permissions and limitations under the License.
 *
 * When distributing the software, include this License Header Notice in each
 * file and include the License file at packager/legal/LICENSE.txt.
 *
 * GPL Classpath Exception:
 * Oracle designates this particular file as subject to the "Classpath"
 * exception as provided by Oracle in the GPL Version 2 section of the License
 * file that accompanied this code.
 *
 * Modifications:
 * If applicable, add the following below the License Header, with the fields
 * enclosed by brackets [] replaced by your own identifying information:
 * "Portions Copyright [year] [name of copyright owner]"
 *
 * Contributor(s):
 * If you wish your version of this file to be governed by only the CDDL or
 * only the GPL Version 2, indicate your decision by adding "[Contributor]
 * elects to include this software in this distribution under the [CDDL or GPL
 * Version 2] license."  If you don't indicate a single choice of license, a
 * recipient has the option to distribute your version of this file under
 * either the CDDL, the GPL Version 2 or to extend the choice of license to
 * its licensees as provided above.  However, if you add GPL Version 2 code
 * and therefore, elected the GPL Version 2 license, then the option applies
 * only if the new code is made subject to such option by the copyright
 * holder.
 */

/* Class_Generated_From_VersionTemplate.java
 * This file is not checked in to CVS. So no CVS information.
 * 1. This java class is generated from a template. Please do not modify it
 * by hand.
 * 2. The template used is VersionTemplate in the same package.
 * 3. The creation of this Java Source File is done by the build.
 */
package com.sun.enterprise.admin.jmx.remote.protocol;

import java.io.Serializable;

/**
* This is the generated Version for the JSR 160 implementation in S1AS.
* This class is generated during the build process.
* @version 1.0
*/
public class @CLASS_NAME@ implements Version {

    /* serialVersionUID is not defined in this class because
       we do not want serialization to be affected by that. The basic
       API of the class should not change whatsoever. The additional
       data for future product releases should be packed in the array
       of Strings - upgradeData. Note that it is expected that the API
       or any non-transient metadata of this class is NEVER changed.
       Hopefully the "value" of upgradeData is the only thing that is expected
       to change and that will keep the serialized version unchanged. (I have done
       some basic testing by initializing various values in the upgradeData 
       array and then calculating the value with the serialver command in
       JDK 1.4.2_03).
    */

    /**
    * Version strings populated during build.
    */
    private final int majorVersion          = @MAJOR_VERSION@;
    private final int minorVersion          = @MINOR_VERSION@; 
    private final String description        = "@DESCRIPTION@";
    /** The upgrade data. The only change being made to this class should
    be the "value" of this variable. Currently empty as of Version 1.0. */
    private final String[] upgradeData      = new String[] {@UPGRADE_DATA@};
    
    /**
     * Returns version information as a String.
     */
    public String toString() {
        return (
            new StringBuffer(description).
            append(":").append(majorVersion).append(".").append(minorVersion).
            append(":").append(upgradeData2String()).toString()
            );
    }
    
    private String upgradeData2String() {
        final StringBuffer sb = new StringBuffer();
        for (int i = 0 ; i < upgradeData.length ; i++) {
            sb.append(upgradeData[i]);
            sb.append(":");
        }
        return ( sb.toString() );
    }
    /**
     * Returns Major Version as an int.
     */ 
    public int getMajorVersion() {
    	return majorVersion;
    }

    /**
     * Returns Minor Version as an int.
     */
    public int getMinorVersion() {
    	return minorVersion;
    }

    /** 
     * Returns the Upgrade Data as a String[]. The Strings packed in this array
     * are processed by the Server in a particular manner.
     */
    public String[] getUpgradeData() {
        return ( (String[])upgradeData.clone() );
    }
}

Other Glassfish examples (source code examples)

Here is a short list of links related to this Glassfish VersionTemplate source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.