dev@glassfish.java.net

Re: svn commit: r18361 - trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher

From: Byron Nevins <Byron.Nevins_at_Sun.COM>
Date: Fri, 29 Feb 2008 14:24:09 -0800

No problem. NetBeans did most of the work for me!

Jerome Dochez wrote:
> Thanks Byron
>
> Jerome
>
> On Feb 29, 2008, at 12:31 PM, bnevins_at_dev.java.net wrote:
>
>> Author: bnevins
>> Date: 2008-02-29 20:31:05+0000
>> New Revision: 18361
>>
>> Added:
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherFactory.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherMain.java
>>
>> Modified:
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/AttributeManager.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFDomainLauncher.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncher.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherException.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherInfo.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherUtils.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.properties
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStringsImpl.java
>>
>>
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/MiniXmlParser.java
>>
>>
>> Log:
>> reformatted
>> added javadoc
>> added cddl with year=2008
>>
>>
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/AttributeManager.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/AttributeManager.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/AttributeManager.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/AttributeManager.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/AttributeManager.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/AttributeManager.java
>> 2008-02-29 20:31:05+0000
>> @@ -1,49 +1,61 @@
>> /*
>> - * To change this template, choose Tools | Templates
>> - * and open the template in the editor.
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (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/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> + *
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> + *
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> */
>> -
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>>
>> import java.util.*;
>>
>> /**
>> - *
>> + * Simple helper class for MiniXmlParser.
>> + * No publics
>> * @author bnevins
>> */
>> -class AttributeManager
>> -{
>> - void add(String name, String value)
>> - {
>> +class AttributeManager {
>> +
>> + void add(String name, String value) {
>> atts.add(new Attribute(name, value));
>> }
>>
>> - void dump()
>> - {
>> - for(Attribute att : atts)
>> - {
>> + void dump() {
>> + for (Attribute att : atts) {
>> System.out.println(att.name + " = " + att.value);
>> }
>> }
>> -
>> - String getValue(String name)
>> - {
>> - for(Attribute att : atts)
>> - {
>> - if(att.name.equals(name))
>> +
>> + String getValue(String name) {
>> + for (Attribute att : atts) {
>> + if (att.name.equals(name)) {
>> return att.value;
>> + }
>> }
>> return null;
>> }
>> -
>> - private static class Attribute
>> - {
>> - Attribute(String n, String v)
>> - {
>> +
>> + private static class Attribute {
>> +
>> + Attribute(String n, String v) {
>> name = n;
>> value = v;
>> }
>> -
>> String name;
>> String value;
>> }
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFDomainLauncher.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFDomainLauncher.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFDomainLauncher.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFDomainLauncher.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFDomainLauncher.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFDomainLauncher.java
>> 2008-02-29 20:31:05+0000
>> @@ -18,30 +18,25 @@
>> * you own identifying information:
>> * "Portions Copyrighted [year] [name of copyright owner]"
>> *
>> - * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> */
>> -
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>> +
>> import java.util.*;
>> +import com.sun.enterprise.glassfish.bootstrap.Main;
>>
>> /**
>> * GFDomainLauncher
>> - *
>> + * This class is a package-private subclass of GFLauncher designed for
>> + * domain launching
>> * @author bnevins
>> */
>> +class GFDomainLauncher extends GFLauncher {
>>
>> -public class GFDomainLauncher
>> -{
>> - public static void main(String[] args)
>> - {
>> - // TODO code application logic here
>> - }
>> -
>> -
>> ///////////////////////////////////////////////////////////////////////////
>>
>> -
>> - public void setInfo(java.util.Properties props)
>> - {
>> -
>> + void internalLaunch() throws GFLauncherException {
>> + getInfo().setup();
>> + Main main = new Main();
>> + main.run(new String[]{"-domaindir",
>> getInfo().domainRootDir.getPath()});
>> }
>> }
>>
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncher.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncher.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncher.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncher.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncher.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncher.java
>> 2008-02-29 20:31:05+0000
>> @@ -1,22 +1,3 @@
>> -
>> -package com.sun.enterprise.glassfish.bootstrap.launcher;
>> -
>> -/**
>> - *
>> - * @author bnevins
>> - */
>> -public abstract class GFLauncher
>> -{
>> - GFLauncherInfo getInfo()
>> - {
>> - return info;
>> - }
>> -
>> -
>> -
>> - private GFLauncherInfo info = new GFLauncherInfo();
>> -}
>> -
>> /*
>> * The contents of this file are subject to the terms
>> * of the Common Development and Distribution License
>> @@ -37,5 +18,58 @@
>> * you own identifying information:
>> * "Portions Copyrighted [year] [name of copyright owner]"
>> *
>> - * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> */
>> +package com.sun.enterprise.glassfish.bootstrap.launcher;
>> +
>> +/**
>> + * This is the main Launcher class designed for external and
>> internal usage.
>> + * Each of the 3 kinds of server -- domain, node-agent and instance
>> -- need
>> + * to sublass this class.
>> + * @author bnevins
>> + */
>> +public abstract class GFLauncher {
>> +
>> + /**
>> + *
>> + * @return The info object that contains startup info
>> + */
>> + public final GFLauncherInfo getInfo()
>> + {
>> + return info;
>> + }
>> +
>> + /**
>> + * An info object is created automatically use this method to
>> set your own
>> + * instance.
>> + * @param info the info instance
>> + */
>> + public final void setInfo(GFLauncherInfo info)
>> + {
>> + this.info = info;
>> + }
>> +
>> + abstract void internalLaunch() throws GFLauncherException;
>> +
>> + /**
>> + * Launches the server. Any fatal error results in a
>> GFLauncherException
>> + * No unchecked Throwables of any kind will be thrown.
>> + *
>> + * @throws
>> com.sun.enterprise.glassfish.bootstrap.launcher.GFLauncherException
>> + */
>> + public void launch() throws GFLauncherException
>> + {
>> + try {
>> + internalLaunch();
>> + }
>> + catch (GFLauncherException gfe) {
>> + throw gfe;
>> + }
>> + catch (Throwable t) {
>> + // hk2 might throw a java.lang.Error
>> + throw new GFLauncherException("unknownError", t);
>> + }
>> + }
>> + private GFLauncherInfo info = new GFLauncherInfo();
>> +}
>> +
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherException.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherException.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherException.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherException.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherException.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherException.java
>> 2008-02-29 20:31:05+0000
>> @@ -1,30 +1,79 @@
>> +/*
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (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/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> + *
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> + *
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> + */
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>>
>> /**
>> - *
>> + * The one and only type of Exception that will be thrown out of
>> this package.
>> + * I18N is wired in. If a String message is found in the resource
>> bundle, it will
>> + * use that String. If not, it will use the String itself.
>> * @author bnevins
>> */
>> -public class GFLauncherException extends Exception
>> -{
>> - public GFLauncherException(String msg)
>> +public class GFLauncherException extends Exception {
>> +
>> + /**
>> + *
>> + * @param msg The message is either pointing at a I18N key in
>> the resource
>> + * bundle or will be treated as a plain string.
>> + */
>> + public GFLauncherException(String msg)
>> {
>> super(strings.get(msg));
>> }
>>
>> - public GFLauncherException(String msg, Object... objs)
>> + /**
>> + *
>> + * @param msg The message is either pointing at a I18N key in
>> the resource
>> + * bundle or will be treated as a plain string that will get
>> formatted with
>> + * objs.
>> + * @param objs Objects used for formatting the message.
>> + */
>> + public GFLauncherException(String msg, Object... objs)
>> {
>> super(strings.get(msg, objs));
>> }
>>
>> - public GFLauncherException(String msg, Throwable t)
>> + /**
>> + *
>> + * @param msg The message is either pointing at a I18N key in
>> the resource
>> + * bundle or will be treated as a plain string.
>> + * @param t The causing Throwable.
>> + */
>> + public GFLauncherException(String msg, Throwable t)
>> {
>> super(strings.get(msg), t);
>> }
>>
>> - public GFLauncherException(String msg, Throwable t, Object... objs)
>> + /**
>> + *
>> + * @param msg The message is either pointing at a I18N key in
>> the resource
>> + * bundle or will be treated as a plain string that will get
>> formatted with
>> + * objs.
>> + * @param t The causing Throwable.
>> + * @param objs Objects used for formatting the message.
>> + */
>> + public GFLauncherException(String msg, Throwable t, Object... objs)
>> {
>> super(strings.get(msg, objs), t);
>> }
>> -
>> private final static LocalStringsImpl strings = new
>> LocalStringsImpl(GFLauncherException.class);
>> }
>>
>> Added:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherFactory.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherFactory.java?view=auto&rev=18361
>>
>> ==============================================================================
>>
>> --- (empty file)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherFactory.java
>> 2008-02-29 20:31:05+0000
>> @@ -0,0 +1,56 @@
>> +/*
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (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/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> + *
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> + *
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> + */
>> +package com.sun.enterprise.glassfish.bootstrap.launcher;
>> +
>> +/**
>> + *
>> + * @author bnevins
>> + */
>> +public class GFLauncherFactory {
>> +
>> + /**
>> + * An enum for specifying the three kinds of servers.
>> + */
>> + public enum ServerType
>> + {
>> +
>> + domain, nodeAgent, instance
>> + };
>> + /**
>> + *
>> + * @param type The type of server to launch.
>> + * @return A launcher instance that can be used for launching
>> the specified
>> + * server type.
>> + * @throws
>> com.sun.enterprise.glassfish.bootstrap.launcher.GFLauncherException
>> + */
>> + public static GFLauncher getInstance(ServerType type) throws
>> GFLauncherException
>> + {
>> + switch(type)
>> + {
>> + case domain:
>> + return new GFDomainLauncher();
>> + default:
>> + throw new GFLauncherException("Only domain launching
>> is currently supported.");
>> + }
>> + }
>> +}
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherInfo.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherInfo.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherInfo.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherInfo.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherInfo.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherInfo.java
>> 2008-02-29 20:31:05+0000
>> @@ -18,9 +18,8 @@
>> * you own identifying information:
>> * "Portions Copyrighted [year] [name of copyright owner]"
>> *
>> - * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> */
>> -
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>>
>> import com.sun.enterprise.module.bootstrap.ArgumentManager;
>> @@ -28,175 +27,162 @@
>> import java.util.*;
>> import java.util.logging.Level;
>> import java.util.logging.Logger;
>> +
>> /**
>> * @author bnevins
>> */
>> -public class GFLauncherInfo
>> -{
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - public static void main(String[] args)
>> - {
>> - try
>> - {
>> - LocalStringsImpl lsi = new
>> LocalStringsImpl(GFLauncherInfo.class);
>> - System.out.println("FOO= " + lsi.get("foo"));
>> - System.out.println("FOO2= " + lsi.get("foo2", "xxxxx",
>> "yyyy"));
>> - GFLauncherInfo gfli = new GFLauncherInfo();
>> - gfli.finalSetup();
>> - }
>> - catch (GFLauncherException ex)
>> - {
>> -
>> Logger.getLogger(GFLauncherInfo.class.getName()).log(Level.SEVERE,
>> null, ex);
>> - }
>> - }
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> - // TEMP TEMP TEMP TEMP TEMP
>> -
>> -
>> -
>> -
>> -
>> +public class GFLauncherInfo {
>> +
>> + /**
>> + * Add the string arguments in the order given.
>> + * @param args The string arguments
>> + */
>> public void addArgs(String... args)
>> {
>> - for(String s : args)
>> + for (String s : args) {
>> argsRaw.add(s);
>> + }
>> }
>>
>> - void setup() throws GFLauncherException
>> - {
>> + void setup() throws GFLauncherException {
>> setupFromArgs();
>> finalSetup();
>> }
>> -
>> - private void setupFromArgs()
>> - {
>> +
>> + private void setupFromArgs() {
>> argsMap = ArgumentManager.argsToMap(argsRaw);
>> -
>> +
>> File f = null;
>> String s = null;
>> Boolean b = null;
>> -
>> +
>> // pick out file props
>> // annoying -- cli uses "domaindir" to represent the parent
>> of the
>> // domain root dir. I'm sticking with the same syntax for
>> now...
>> - if((f = getFile("domaindir")) != null)
>> + if ((f = getFile("domaindir")) != null) {
>> domainParentDir = f;
>> -
>> - if((f = getFile("instancedir")) != null)
>> + }
>> +
>> + if ((f = getFile("instancedir")) != null) {
>> instanceDir = f;
>> -
>> - if((f = getFile("domainrootdir")) != null)
>> + }
>> +
>> + if ((f = getFile("-domainrootdir")) != null) {
>> domainRootDir = f;
>> -
>> + }
>> +
>> // Now do the same thing with known Strings
>> - if((s = getString("domain")) != null)
>> + if ((s = getString("domain")) != null) {
>> domainName = s;
>> -
>> + }
>> +
>> // the Arg processor may have set the name "default" to the
>> domain name
>> // just like in asadmin
>> - if(!GFLauncherUtils.ok(domainName) && (s =
>> getString("default")) != null)
>> + if (!GFLauncherUtils.ok(domainName) && (s =
>> getString("default")) != null) {
>> domainName = s;
>> -
>> - if((s = getString("instancename")) != null)
>> + }
>> +
>> + if ((s = getString("instancename")) != null) {
>> instanceName = s;
>> + }
>>
>> // finally, do the booleans
>> - if((b = getBoolean("debug")) != null)
>> + if ((b = getBoolean("debug")) != null) {
>> debug = b;
>> + }
>>
>> - if((b = getBoolean("verbose")) != null)
>> + if ((b = getBoolean("verbose")) != null) {
>> verbose = b;
>> + }
>>
>> - if((b = getBoolean("embedded")) != null)
>> + if ((b = getBoolean("embedded")) != null) {
>> embedded = b;
>> + }
>> }
>> -
>> - private void finalSetup() throws GFLauncherException
>> - {
>> +
>> + private void finalSetup() throws GFLauncherException {
>> installDir = GFLauncherUtils.getInstallDir();
>>
>> - if(!GFLauncherUtils.safeIsDirectory(installDir))
>> + if (!GFLauncherUtils.safeIsDirectory(installDir)) {
>> throw new GFLauncherException("noInstallDir", installDir);
>> -
>> + }
>> +
>> // check user-supplied args
>> - if(domainParentDir != null)
>> - {
>> + if (domainParentDir != null) {
>> // if the arg was given -- then it MUST point to a real dir
>> - if(!GFLauncherUtils.safeIsDirectory(domainParentDir))
>> + if (!GFLauncherUtils.safeIsDirectory(domainParentDir)) {
>> throw new GFLauncherException("noDomainParentDir",
>> domainParentDir);
>> + }
>> }
>>
>> setupDomainRootDir();
>> -
>> - if(!GFLauncherUtils.safeIsDirectory(domainRootDir))
>> +
>> + if (!GFLauncherUtils.safeIsDirectory(domainRootDir)) {
>> throw new GFLauncherException("noDomainRootDir",
>> domainRootDir);
>> -
>> + }
>> +
>> configDir = new File(domainRootDir, CONFIG_DIR);
>> -
>> - // if we made it here -- we're in pretty good shape!
>> +
>> + if (!GFLauncherUtils.safeIsDirectory(configDir)) {
>> + throw new GFLauncherException("noConfigDir", configDir);
>> + }
>> +
>> + configFile = new File(configDir, CONFIG_FILENAME);
>> +
>> + if (!GFLauncherUtils.safeExists(configFile)) {
>> + throw new GFLauncherException("noConfigFile", configFile);
>> + }
>> +
>> + // if we made it here -- we're in pretty good shape!
>> }
>>
>> - private void setupDomainRootDir() throws GFLauncherException
>> - {
>> + private void setupDomainRootDir() throws GFLauncherException {
>> // if they set domainrootdir -- it takes precedence
>> - if(domainRootDir != null)
>> - {
>> + if (domainRootDir != null) {
>> domainParentDir = domainRootDir.getParentFile();
>> domainName = domainRootDir.getName();
>> return;
>> }
>> -
>> +
>> // if they set domainParentDir -- use it. o/w use the
>> default dir
>> - if(domainParentDir == null)
>> - {
>> + if (domainParentDir == null) {
>> domainParentDir = new File(installDir,
>> DEFAULT_DOMAIN_PARENT_DIR);
>> }
>> -
>> +
>> // if they specified domain name -- use it. o/w use the one
>> and only dir
>> // in the domain parent dir
>> -
>> - if(domainName == null)
>> - {
>> +
>> + if (domainName == null) {
>> domainName = getTheOneAndOnlyDomain();
>> }
>> -
>> +
>> domainRootDir = new File(domainParentDir, domainName);
>> }
>>
>> - private String getTheOneAndOnlyDomain() throws GFLauncherException
>> - {
>> + private String getTheOneAndOnlyDomain() throws
>> GFLauncherException {
>> // look for subdirs in the parent dir -- there must be one
>> and only one
>> -
>> - File[] files = domainParentDir.listFiles(new FileFilter()
>> - {
>> - public boolean accept(File f)
>> - {
>> - return GFLauncherUtils.safeIsDirectory(f);
>> +
>> + File[] files = domainParentDir.listFiles(new FileFilter() {
>> +
>> + public boolean accept(File f) {
>> + return GFLauncherUtils.safeIsDirectory(f);
>> }
>> });
>> -
>> - if(files == null || files.length == 0)
>> +
>> + if (files == null || files.length == 0) {
>> throw new GFLauncherException("noDomainDirs",
>> domainParentDir);
>> -
>> - if(files.length > 1)
>> + }
>> +
>> + if (files.length > 1) {
>> throw new GFLauncherException("tooManyDomainDirs",
>> domainParentDir);
>> -
>> + }
>> +
>> return files[0].getName();
>> }
>> -
>> - private Boolean getBoolean(String key)
>> - {
>> +
>> + private Boolean getBoolean(String key) {
>> // 3 return values -- true, false, null
>> - if(argsMap.containsKey(key))
>> - {
>> + if (argsMap.containsKey(key)) {
>> String s = argsMap.get(key);
>> //argsMap.remove(key);
>> return Boolean.valueOf(s);
>> @@ -204,21 +190,17 @@
>> return null;
>> }
>>
>> - private File getFile(String key)
>> - {
>> - if(argsMap.containsKey(key))
>> - {
>> + private File getFile(String key) {
>> + if (argsMap.containsKey(key)) {
>> File f = new File(argsMap.get(key));
>> //argsMap.remove(key);
>> return f;
>> }
>> return null;
>> }
>> -
>> - private String getString(String key)
>> - {
>> - if(argsMap.containsKey(key))
>> - {
>> +
>> + private String getString(String key) {
>> + if (argsMap.containsKey(key)) {
>> String s = argsMap.get(key);
>> //argsMap.remove(key);
>> return s;
>> @@ -227,21 +209,22 @@
>> }
>>
>> // yes these variables are all accessible from any class in the
>> package...
>> - boolean verbose = false;
>> - boolean debug = false;
>> - boolean embedded = false;
>> - File installDir;
>> - File domainParentDir;
>> - File domainRootDir;
>> - File instanceDir;
>> - File configDir;
>> - String domainName;
>> - String instanceName;
>> -
>> - private boolean valid = false;
>> - private Map<String,String> argsMap;
>> - private ArrayList<String> argsRaw = new ArrayList<String>();
>> + boolean verbose = false;
>> + boolean debug = false;
>> + boolean embedded = false;
>> + File installDir;
>> + File domainParentDir;
>> + File domainRootDir;
>> + File instanceDir;
>> + File configDir;
>> + File configFile; // domain.xml
>> + String domainName;
>> + String instanceName;
>> + private boolean valid = false;
>> + private Map<String, String> argsMap;
>> + private ArrayList<String> argsRaw = new ArrayList<String>();
>> private final static String DEFAULT_DOMAIN_PARENT_DIR = "domains";
>> - private final static String CONFIG_DIR = "config";
>> + private final static String CONFIG_DIR = "config";
>> + private final static String CONFIG_FILENAME = "domain.xml";
>> }
>>
>>
>> Added:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherMain.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherMain.java?view=auto&rev=18361
>>
>> ==============================================================================
>>
>> --- (empty file)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherMain.java
>> 2008-02-29 20:31:05+0000
>> @@ -0,0 +1,49 @@
>> +/*
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (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/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> + *
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> + *
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> + */
>> +package com.sun.enterprise.glassfish.bootstrap.launcher;
>> +
>> +import java.util.logging.Level;
>> +import java.util.logging.Logger;
>> +
>> +/**
>> + *
>> + * @author bnevins
>> + */
>> +public class GFLauncherMain {
>> +
>> + /**
>> + * JAVADOC IS PENDING FINAL API OF THE ARGS
>> + * @param args
>> + */
>> + public static void main(String[] args)
>> + {
>> + try {
>> + GFLauncher launcher =
>> GFLauncherFactory.getInstance(GFLauncherFactory.ServerType.domain);
>> + launcher.getInfo().addArgs(args);
>> + launcher.launch();
>> + }
>> + catch (GFLauncherException ex) {
>> +
>> Logger.getLogger(GFLauncherMain.class.getName()).log(Level.SEVERE,
>> null, ex);
>> + }
>> + }
>> +}
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherUtils.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherUtils.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherUtils.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherUtils.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherUtils.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/GFLauncherUtils.java
>> 2008-02-29 20:31:05+0000
>> @@ -1,115 +1,94 @@
>> /*
>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (the License). You may not use this file except in
>> + * compliance with the License.
>> *
>> - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
>> + * You can obtain a copy of the license at
>> + * https://glassfish.dev.java.net/public/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> *
>> - * 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.html
>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>> the specific
>> - * language governing permissions and limitations under the License.
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> *
>> - * When distributing the software, include this License Header
>> Notice in each
>> - * file and include the License file at
>> glassfish/bootstrap/legal/LICENSE.txt.
>> - * Sun designates this particular file as subject to the "Classpath"
>> exception
>> - * as provided by Sun in the GPL Version 2 section of the License
>> file that
>> - * accompanied this code. If applicable, add the following below
>> the License
>> - * Header, with the fields enclosed by brackets [] replaced by your own
>> - * identifying information: "Portions Copyrighted [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.
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> */
>> -
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>>
>> import java.io.*;
>> import java.net.*;
>> import java.util.*;
>>
>> -
>> /**
>> - *
>> + * Package private static utility methods
>> * @author bnevins
>> */
>> -class GFLauncherUtils
>> -{
>> - private GFLauncherUtils()
>> - {
>> - // all static methods
>> +class GFLauncherUtils {
>> +
>> + private GFLauncherUtils() {
>> + // all static methods
>> }
>>
>> - static boolean ok(String s)
>> - {
>> + static boolean ok(String s) {
>> return s != null && s.length() > 0;
>> }
>>
>> - static boolean safeExists(File f)
>> - {
>> + static boolean safeExists(File f) {
>> return f != null && f.exists();
>> }
>> -
>> - static boolean safeIsDirectory(File f)
>> - {
>> +
>> + static boolean safeIsDirectory(File f) {
>> return f != null && f.isDirectory();
>> - }
>> + }
>>
>> - static File absolutize(File f)
>> - {
>> - if(f == null)
>> + static File absolutize(File f) {
>> + if (f == null) {
>> return null;
>> + }
>>
>> - try
>> - {
>> + try {
>> return f.getCanonicalFile();
>> }
>> - catch(Exception e)
>> - {
>> + catch (Exception e) {
>> return f.getAbsoluteFile();
>> }
>> - }
>> -
>> - static File getInstallDir()
>> - {
>> - String resourceName =
>> GFLauncherUtils.class.getName().replace(".","/")+".class";
>> + }
>> +
>> + static File getInstallDir() {
>> + String resourceName =
>> GFLauncherUtils.class.getName().replace(".", "/") + ".class";
>> URL resource =
>> GFLauncherUtils.class.getClassLoader().getResource(resourceName);
>> -
>> - if (resource==null)
>> +
>> + if (resource == null) {
>> return null;
>> + }
>>
>> - if (!resource.getProtocol().equals("jar"))
>> + if (!resource.getProtocol().equals("jar")) {
>> return null;
>> -
>> - try
>> - {
>> + }
>> +
>> + try {
>> JarURLConnection c = (JarURLConnection)
>> resource.openConnection();
>> URL jarFile = c.getJarFileURL();
>> File f = new File(jarFile.toURI());
>> -
>> +
>> f = f.getParentFile(); // <install>/modules
>> -
>> - if(f == null)
>> +
>> + if (f == null) {
>> return null;
>> + }
>>
>> f = f.getParentFile(); // <install>/
>> -
>> +
>> return absolutize(f);
>> - }
>> - catch (Exception e)
>> - {
>> + }
>> + catch (Exception e) {
>> return null;
>> }
>> }
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.java
>> 2008-02-29 20:31:05+0000
>> @@ -1,8 +1,25 @@
>> /*
>> - * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
>> - * Use is subject to license terms.
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (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/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> + *
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> + *
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> */
>> -
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>>
>> /**
>> @@ -35,23 +52,20 @@
>> *
>> * @author bnevins
>> */
>> -public class LocalStrings
>> -{
>> - private LocalStrings()
>> - {
>> +public class LocalStrings {
>> +
>> + private LocalStrings() {
>> }
>> -
>> +
>> /**
>> * Get a String from the caller's package's LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the String from LocalStrings or the supplied String if
>> it doesn't exist
>> */
>> -
>> - public static String get(String indexString)
>> - {
>> + public static String get(String indexString) {
>> return new LocalStringsImpl().get(indexString);
>> }
>> -
>> +
>> /**
>> * Get and format a String from the caller's package's
>> LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> @@ -59,41 +73,36 @@
>> * @return the String from LocalStrings or the supplied String if
>> it doesn't exist --
>> * using the array of supplied Object arguments
>> */
>> - public static String get(String indexString, Object... objects)
>> - {
>> + public static String get(String indexString, Object... objects) {
>> return new LocalStringsImpl().get(indexString, objects);
>> }
>> -
>> +
>> /**
>> * Get a String from the caller's package's LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the String from LocalStrings or the supplied default
>> value if it doesn't exist
>> */
>> - public String getString(String indexString, String defaultValue)
>> - {
>> + public String getString(String indexString, String defaultValue) {
>> return new LocalStringsImpl().get(indexString, defaultValue);
>> }
>> -
>> +
>> /**
>> * Get an integer from the caller's package's
>> LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the integer value from LocalStrings or the supplied
>> default if
>> * it doesn't exist or is bad.
>> */
>> -
>> - public static int getInt(String indexString, int defaultValue)
>> - {
>> + public static int getInt(String indexString, int defaultValue) {
>> return new LocalStringsImpl().getInt(indexString, defaultValue);
>> }
>> -
>> +
>> /**
>> * Get a boolean from the caller's package's LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the integer value from LocalStrings or the supplied
>> default if
>> * it doesn't exist or is bad.
>> */
>> - public boolean getBoolean(String indexString, boolean defaultValue)
>> - {
>> + public boolean getBoolean(String indexString, boolean
>> defaultValue) {
>> return new LocalStringsImpl().getBoolean(indexString,
>> defaultValue);
>> - }
>> + }
>> }
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.properties
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.properties?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.properties&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.properties&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.properties
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStrings.properties
>> 2008-02-29 20:31:05+0000
>> @@ -9,3 +9,6 @@
>> pointing to a directory. This is what I was looking for: [{0}]
>> noDomainDirs=No domains exist in {0}
>> tooManyDomainDirs=There is more than one domain in {0}. Try again
>> but specify the domain name as the last argument.
>> +unknownError=Unknown Fatal Error encountered during launch
>> +noConfigDir=Corrupt domain. The config directory does not exist. I
>> was looking for it here: {0}
>> +noConfigFile=The main Glassfish configuration file is missing. This
>> is where it is supposed to be: {0}
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStringsImpl.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStringsImpl.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStringsImpl.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStringsImpl.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStringsImpl.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/LocalStringsImpl.java
>> 2008-02-29 20:31:05+0000
>> @@ -1,11 +1,34 @@
>> /*
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (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/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> + *
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> + *
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> + */
>> +
>> +/*
>> * LocalStringsImpl.java
>> *
>> * Created on December 3, 2005, 5:26 PM
>> *
>> */
>> -
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>> +
>> import java.util.ResourceBundle;
>> import java.text.MessageFormat;
>>
>> @@ -35,64 +58,58 @@
>> *
>> * @author bnevins
>> */
>> -public class LocalStringsImpl
>> -{
>> +public class LocalStringsImpl {
>> +
>> /**
>> * Create a LocalStringsImpl instance.
>> * Automatically discover the caller's LocalStrings.properties file
>> */
>> - public LocalStringsImpl()
>> - {
>> + public LocalStringsImpl() {
>> setBundle();
>> }
>> -
>> +
>> /**
>> * Create a LocalStringsImpl instance.
>> * use the proffered class object to find LocalStrings.properties.
>> * This is the constructor to use if you are concerned about getting
>> * the fastest performance.
>> */
>> - public LocalStringsImpl(Class clazz)
>> - {
>> + public LocalStringsImpl(Class clazz) {
>> setBundle(clazz);
>> }
>>
>> - /**
>> + /**
>> * Create a LocalStringsImpl instance.
>> * use the proffered String. The String is the FQN of the
>> properties file,
>> - * without the '.properties'. E.g. 'com.elf.something.LogStrings'
>> + * without the '.properties'. E.g. 'com.elf.something.LogStrings'
>> */
>> - public LocalStringsImpl(String packageName, String propsName)
>> - {
>> - this.propsName = propsName;
>> - int len = packageName.length();
>> -
>> - // side-effect -- make sure it ends in '.'
>> - if(packageName.charAt(len - 1) != '.')
>> - packageName += '.';
>> -
>> + public LocalStringsImpl(String packageName, String propsName) {
>> + this.propsName = propsName;
>> + int len = packageName.length();
>> +
>> + // side-effect -- make sure it ends in '.'
>> + if (packageName.charAt(len - 1) != '.') {
>> + packageName += '.';
>> + }
>> +
>> setBundle(packageName);
>> }
>> -
>> +
>> /**
>> * Get a String from the caller's package's LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the String from LocalStrings or the supplied String if
>> it doesn't exist
>> */
>> -
>> - public String get(String indexString)
>> - {
>> - try
>> - {
>> + public String get(String indexString) {
>> + try {
>> return getBundle().getString(indexString);
>> }
>> - catch (Exception e)
>> - {
>> + catch (Exception e) {
>> // it is not an error to have no key...
>> return indexString;
>> }
>> }
>> -
>> +
>> /**
>> * Get and format a String from the caller's package's
>> LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> @@ -100,143 +117,117 @@
>> * @return the String from LocalStrings or the supplied String if
>> it doesn't exist --
>> * using the array of supplied Object arguments
>> */
>> - public String get(String indexString, Object... objects)
>> - {
>> + public String get(String indexString, Object... objects) {
>> indexString = get(indexString);
>> -
>> - try
>> - {
>> +
>> + try {
>> MessageFormat mf = new MessageFormat(indexString);
>> return mf.format(objects);
>> }
>> - catch(Exception e)
>> - {
>> + catch (Exception e) {
>> return indexString;
>> }
>> }
>> +
>> /**
>> * Get a String from the caller's package's LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the String from LocalStrings or the supplied default
>> value if it doesn't exist
>> */
>> -
>> - public String getString(String indexString, String defaultValue)
>> - {
>> - try
>> - {
>> + public String getString(String indexString, String defaultValue) {
>> + try {
>> return getBundle().getString(indexString);
>> }
>> - catch (Exception e)
>> - {
>> + catch (Exception e) {
>> // it is not an error to have no key...
>> return defaultValue;
>> }
>> }
>> +
>> /**
>> * Get an integer from the caller's package's
>> LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the integer value from LocalStrings or the supplied
>> default if
>> * it doesn't exist or is bad.
>> */
>> -
>> - public int getInt(String indexString, int defaultValue)
>> - {
>> - try
>> - {
>> + public int getInt(String indexString, int defaultValue) {
>> + try {
>> String s = getBundle().getString(indexString);
>> return Integer.parseInt(s);
>> }
>> - catch (Exception e)
>> - {
>> + catch (Exception e) {
>> // it is not an error to have no key...
>> return defaultValue;
>> }
>> }
>> +
>> /**
>> * Get a boolean from the caller's package's LocalStrings.properties
>> * @param indexString The string index into the localized string
>> file
>> * @return the integer value from LocalStrings or the supplied
>> default if
>> * it doesn't exist or is bad.
>> */
>> -
>> - public boolean getBoolean(String indexString, boolean defaultValue)
>> - {
>> - try
>> - {
>> + public boolean getBoolean(String indexString, boolean
>> defaultValue) {
>> + try {
>> return new Boolean(getBundle().getString(indexString));
>> }
>> - catch (Exception e)
>> - {
>> + catch (Exception e) {
>> // it is not an error to have no key...
>> return defaultValue;
>> }
>> }
>> -
>> +
>>
>> ///////////////////////////////////////////////////////////////////////////
>>
>> -
>>
>> ///////////////////////////////////////////////////////////////////////////
>>
>> -
>> - private ResourceBundle getBundle()
>> - {
>> + private ResourceBundle getBundle() {
>> return bundle;
>> }
>> -
>> +
>>
>> ///////////////////////////////////////////////////////////////////////////
>>
>> -
>> - private void setBundle()
>> - {
>> + private void setBundle() {
>> // go through the stack, top to bottom. The item that is
>> below the LAST
>> // method that is in the util framework is where the logfile is.
>> // note that there may be more than one method from util in
>> the stack
>> // because they may be calling us indirectly from
>> LoggerHelper. Also
>> // note that this class won't work from any class in the util
>> hierarchy itself.
>> -
>> - try
>> - {
>> +
>> + try {
>> StackTraceElement[] items =
>> Thread.currentThread().getStackTrace();
>> int lastMeOnStack = -1;
>> -
>> - for(int i = 0; i < items.length; i++)
>> - {
>> +
>> + for (int i = 0; i < items.length; i++) {
>> StackTraceElement item = items[i];
>> - if(item.getClassName().startsWith(thisPackage))
>> + if (item.getClassName().startsWith(thisPackage)) {
>> lastMeOnStack = i;
>> + }
>> }
>> -
>> +
>> String className = items[lastMeOnStack + 1].getClassName();
>> setBundle(className);
>> }
>> - catch(Exception e)
>> - {
>> + catch (Exception e) {
>> bundle = null;
>> }
>> }
>>
>>
>> ///////////////////////////////////////////////////////////////////////////
>>
>> -
>> - private void setBundle(Class clazz)
>> - {
>> + private void setBundle(Class clazz) {
>> setBundle(clazz.getName());
>> }
>> -
>> +
>>
>> ///////////////////////////////////////////////////////////////////////////
>>
>> -
>> - private void setBundle(String className)
>> - {
>> - try
>> - {
>> + private void setBundle(String className) {
>> + try {
>> String props = className.substring(0,
>> className.lastIndexOf('.')) + "." + propsName;
>> bundle = ResourceBundle.getBundle(props);
>> }
>> - catch(Exception e)
>> - {
>> + catch (Exception e) {
>> bundle = null;
>> }
>> - }
>> + }
>>
>>
>> ///////////////////////////////////////////////////////////////////////////
>>
>> -
>> - private ResourceBundle bundle;
>> - private String propsName =
>> "LocalStrings";
>> - private static final String thisPackage =
>> "com.elf.util";
>> + private ResourceBundle bundle;
>> + private String propsName = "LocalStrings";
>> + private static final String thisPackage = "com.elf.util";
>> }
>>
>> Modified:
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/MiniXmlParser.java
>>
>> Url:
>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/MiniXmlParser.java?view=diff&rev=18361&p1=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/MiniXmlParser.java&p2=trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/MiniXmlParser.java&r1=18360&r2=18361
>>
>> ==============================================================================
>>
>> ---
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/MiniXmlParser.java
>> (original)
>> +++
>> trunk/v3/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launcher/MiniXmlParser.java
>> 2008-02-29 20:31:05+0000
>> @@ -1,6 +1,24 @@
>> /*
>> - * To change this template, choose Tools | Templates
>> - * and open the template in the editor.
>> + * The contents of this file are subject to the terms
>> + * of the Common Development and Distribution License
>> + * (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/CDDLv1.0.html or
>> + * glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * See the License for the specific language governing
>> + * permissions and limitations under the License.
>> + *
>> + * When distributing Covered Code, include this CDDL
>> + * Header Notice in each file and include the License file
>> + * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>> + * If applicable, add the following below the CDDL Header,
>> + * with the fields enclosed by brackets [] replaced by
>> + * you own identifying information:
>> + * "Portions Copyrighted [year] [name of copyright owner]"
>> + *
>> + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
>> */
>> package com.sun.enterprise.glassfish.bootstrap.launcher;
>>
>> @@ -10,106 +28,97 @@
>> import javax.xml.stream.XMLStreamException;
>> import javax.xml.stream.XMLStreamReader;
>> import static javax.xml.stream.XMLStreamConstants.*;
>> +
>> /**
>> - *
>> + * A fairly simple but very specific stax XML Parser.
>> + * Give it the location of domain.xml and the name of the server
>> instance and it
>> + * will return JVM options.
>> + * Currently it is all package private.
>> * @author bnevins
>> */
>> -public class MiniXmlParser
>> -{
>> - public static void main(String[] args)
>> - {
>> - try
>> - {
>> +class MiniXmlParser {
>> +
>> + public static void main(String[] args) {
>> + try {
>> File dxml = new
>> File("C:/glassfish/domains/domain1/config/domain.xml");
>> MiniXmlParser parser = new MiniXmlParser(dxml, "server");
>> parser.read();
>> }
>> - catch (Exception e)
>> - {
>> + catch (Exception e) {
>> System.out.println("EXCEPTION: " + e);
>> }
>> }
>>
>> - public MiniXmlParser(File domainXml, String serverName)
>> - {
>> + MiniXmlParser(File domainXml, String serverName) {
>> this.serverName = serverName;
>> - try
>> - {
>> + try {
>> FileInputStream stream = new FileInputStream(domainXml);
>> XMLInputFactory xif = XMLInputFactory.newInstance();
>> parser =
>> xif.createXMLStreamReader(domainXml.toURI().toString(), stream);
>> }
>> - catch(Exception e)
>> - {
>> + catch (Exception e) {
>> throw new RuntimeException(e);
>> }
>> }
>> -
>> - public void read()
>> - {
>> - try
>> - {
>> +
>> + void read() {
>> + try {
>> getConfigRefName();
>> getConfig();
>> }
>> - catch(Exception e)
>> - {
>> + catch (Exception e) {
>> throw new RuntimeException(e);
>> }
>> }
>> +
>> /**
>> * @throws javax.xml.stream.XMLStreamException
>> */
>> - private void getConfigRefName() throws XMLStreamException
>> - {
>> - if(configRef != null)
>> - return; // second pass!
>> -
>> + private void getConfigRefName() throws XMLStreamException {
>> + if (configRef != null) {
>> + return;
>> + } // second pass!
>> +
>> skipRoot("domain");
>> skipTo("servers");
>> -
>> +
>> // the cursor is at the start-element of <servers>
>> - while(true)
>> - {
>> + while (true) {
>> // get to first <server> element
>> skipNonStartElements();
>>
>> - if(!parser.getLocalName().equals("server"))
>> + if (!parser.getLocalName().equals("server")) {
>> throw new XMLStreamException("no server found");
>> + }
>>
>> // get the attributes for this <server>
>> AttributeManager mgr = parseAttributes();
>> String thisName = mgr.getValue("name");
>> -
>> - if(serverName.equals(thisName))
>> - {
>> +
>> + if (serverName.equals(thisName)) {
>> configRef = mgr.getValue("config-ref");
>> return;
>> }
>> }
>> }
>>
>> - private void getConfig() throws XMLStreamException
>> - {
>> + private void getConfig() throws XMLStreamException {
>> skipTo("configs");
>> - while(true)
>> - {
>> + while (true) {
>> skipTo("config");
>>
>> // get the attributes for this <config>
>> AttributeManager mgr = parseAttributes();
>> String thisName = mgr.getValue("name");
>> -
>> - if(configRef.equals(thisName))
>> - {
>> +
>> + if (configRef.equals(thisName)) {
>> getJavaConfig();
>> return;
>> }
>> }
>> }
>>
>> - private void getJavaConfig() throws XMLStreamException
>> - {
>> + private void getJavaConfig() throws XMLStreamException {
>> // cursor --> <config>
>> skipTo("java-config");
>>
>> @@ -118,52 +127,44 @@
>> getJvmOptions();
>> }
>>
>> - private void getJvmOptions() throws XMLStreamException
>> - {
>> - while(skipToButNotPast("jvm-options", "java-config"))
>> - {
>> + private void getJvmOptions() throws XMLStreamException {
>> + while (skipToButNotPast("jvm-options", "java-config")) {
>> jvmOptions.add(parser.getElementText());
>> }
>> -
>> - for(String s : jvmOptions)
>> +
>> + for (String s : jvmOptions) {
>> System.out.println("JVM OPTION: " + s);
>> -
>> - }
>> + }
>>
>> + }
>>
>> - private void skipNonStartElements() throws XMLStreamException
>> - {
>> - while(true)
>> - {
>> + private void skipNonStartElements() throws XMLStreamException {
>> + while (true) {
>> int event = parser.next();
>> -
>> - if(event == START_ELEMENT)
>> - {
>> +
>> + if (event == START_ELEMENT) {
>> return;
>> }
>> }
>> }
>>
>> -
>> - private void skipRoot(String name) throws XMLStreamException
>> - {
>> + private void skipRoot(String name) throws XMLStreamException {
>> // The cursor is pointing at the start of the document
>> // Move to the first 'top-level' element under name
>> // Return with cursor pointing to first sub-element
>> - while (true)
>> - {
>> + while (true) {
>> int event = parser.next();
>> -
>> - if(event == START_ELEMENT)
>> - {
>> - if(!name.equals(parser.getLocalName()))
>> +
>> + if (event == START_ELEMENT) {
>> + if (!name.equals(parser.getLocalName())) {
>> throw new XMLStreamException("Unknown Domain XML
>> Layout");
>> -
>> + }
>> +
>> return;
>> }
>> }
>> }
>> -
>> +
>> /**
>> * The cursor will be pointing at the START_ELEMENT of name when
>> it returns
>> * note that skipTree must be called. Otherwise we could be
>> fooled by a
>> @@ -171,18 +172,18 @@
>> * @param name the Element to skip to
>> * @throws javax.xml.stream.XMLStreamException
>> */
>> - private void skipTo(String name) throws XMLStreamException
>> - {
>> - while (true)
>> - {
>> + private void skipTo(String name) throws XMLStreamException {
>> + while (true) {
>> skipNonStartElements();
>> // cursor is at a START_ELEMENT
>> String localName = parser.getLocalName();
>>
>> - if(name.equals(localName))
>> + if (name.equals(localName)) {
>> return;
>> - else
>> + }
>> + else {
>> skipTree(localName);
>> + }
>> }
>> }
>>
>> @@ -193,79 +194,82 @@
>> * @param name the Element to skip to
>> * @throws javax.xml.stream.XMLStreamException
>> */
>> - private boolean skipToButNotPast(String startName, String
>> endName) throws XMLStreamException
>> - {
>> - while (true)
>> - {
>> + private boolean skipToButNotPast(String startName, String
>> endName) throws XMLStreamException {
>> + while (true) {
>> int event = parser.next();
>> -
>> - if(event == START_ELEMENT)
>> - {
>> - if(parser.getLocalName().equals(startName))
>> +
>> + if (event == START_ELEMENT) {
>> + if (parser.getLocalName().equals(startName)) {
>> return true;
>> + }
>> }
>>
>> - if(event == END_ELEMENT)
>> - {
>> - if(parser.getLocalName().equals(endName))
>> + if (event == END_ELEMENT) {
>> + if (parser.getLocalName().equals(endName)) {
>> return false;
>> + }
>> }
>> }
>> }
>>
>> - private void skipTree(String name) throws XMLStreamException
>> - {
>> + private void skipTree(String name) throws XMLStreamException {
>> // The cursor is pointing at the start-element of name.
>> // throw everything in this element away and return with the
>> cursor
>> // pointing at its end-element.
>> - while (true)
>> - {
>> + while (true) {
>> int event = parser.next();
>> -
>> - if (event == END_ELEMENT &&
>> name.equals(parser.getLocalName()))
>> - {
>> +
>> + if (event == END_ELEMENT &&
>> name.equals(parser.getLocalName())) {
>> //System.out.println("END: " + parser.getLocalName());
>> return;
>> }
>> }
>> }
>> -
>> - private void dump() throws XMLStreamException
>> - {
>> +
>> + private void dump() throws XMLStreamException {
>> StringBuilder sb = new StringBuilder();
>> -
>> +
>> sb.append("\ngetName(): ").append(parser.getName());
>> sb.append("\ngetLocalName(): ").append(parser.getLocalName());
>> sb.append("\ngetNamespaceURI():
>> ").append(parser.getNamespaceURI());
>> - try { sb.append("\ngetText(): ").append(parser.getText()); }
>> catch(Exception e){}
>> - try { sb.append("\ngetElementText():
>> ").append(parser.getElementText());} catch(Exception e){}
>> + try {
>> + sb.append("\ngetText(): ").append(parser.getText());
>> + }
>> + catch (Exception e) {
>> + }
>> + try {
>> + sb.append("\ngetElementText():
>> ").append(parser.getElementText());
>> + }
>> + catch (Exception e) {
>> + }
>> sb.append("\ngetEventType(): ").append(parser.getEventType());
>> sb.append("\ngetLocation(): ").append(parser.getLocation());
>> - try { sb.append("\ngetAttributeCount():
>> ").append(parser.getAttributeCount());}catch(Exception e){}
>> -
>> + try {
>> + sb.append("\ngetAttributeCount():
>> ").append(parser.getAttributeCount());
>> + }
>> + catch (Exception e) {
>> + }
>> +
>> System.out.println(sb.toString());
>> }
>> -
>> - private AttributeManager parseAttributes()
>> - {
>> +
>> + private AttributeManager parseAttributes() {
>> // HINT: there is probably a MUCH better way to do this
>> -
>> +
>> AttributeManager mgr = new AttributeManager();
>> -
>> +
>> int num = parser.getAttributeCount();
>> -
>> - for(int i = 0; i < num; i++)
>> - {
>> +
>> + for (int i = 0; i < num; i++) {
>> mgr.add(parser.getAttributeName(i).getLocalPart(),
>> parser.getAttributeValue(i));
>> }
>> -
>> +
>> return mgr;
>> }
>> -
>> - private XMLStreamReader parser;
>> - private String serverName;
>> - private String configRef;
>> - private AttributeManager javaConfigAttributeManager;
>> - private List<String> jvmOptions = new ArrayList<String>();
>> + private XMLStreamReader parser;
>> + private String serverName;
>> + private String configRef;
>> + private AttributeManager javaConfigAttributeManager;
>> + private List<String> jvmOptions = new ArrayList<String>();
>> }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commits-unsubscribe_at_glassfish-svn.dev.java.net
>> For additional commands, e-mail: commits-help_at_glassfish-svn.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>

-- 
Byron Nevins Work 408-276-4089, Home 650-359-1290, Cell 650-784-4123 - Sun Microsystems, Inc.