2617N/A/*
2617N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2617N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2617N/A *
2617N/A * This code is free software; you can redistribute it and/or modify it
2617N/A * under the terms of the GNU General Public License version 2 only, as
2617N/A * published by the Free Software Foundation.
2617N/A *
2617N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2617N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2617N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2617N/A * version 2 for more details (a copy is included in the LICENSE file that
2617N/A * accompanied this code).
2617N/A *
2617N/A * You should have received a copy of the GNU General Public License version
2617N/A * 2 along with this work; if not, write to the Free Software Foundation,
2617N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2617N/A *
2617N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2617N/A * or visit www.oracle.com if you need additional information or have any
2617N/A * questions.
2617N/A */
2617N/A
2617N/A/*
2617N/A * An example subclass of SimpleApplication that illustrates how to
2617N/A * override the doMyAppWork() method.
2617N/A */
2617N/A
2617N/Apublic class SleeperApplication extends SimpleApplication {
2617N/A public static int DEFAULT_SLEEP_TIME = 60; // time is in seconds
2617N/A
2617N/A // execute the sleeper app work
2617N/A public void doMyAppWork(String[] args) throws Exception {
2617N/A int sleep_time = DEFAULT_SLEEP_TIME;
2617N/A
2617N/A // args[0] is the port-file
2617N/A if (args.length < 2) {
2617N/A System.out.println("INFO: using default sleep time of "
2617N/A + sleep_time + " seconds.");
2617N/A } else {
2617N/A try {
2617N/A sleep_time = Integer.parseInt(args[1]);
2617N/A } catch (NumberFormatException nfe) {
2617N/A throw new RuntimeException("Error: '" + args[1] +
2617N/A "': is not a valid seconds value.");
2617N/A }
2617N/A }
2617N/A
2617N/A Thread.sleep(sleep_time * 1000); // our "work" is to sleep
2617N/A }
2617N/A
2617N/A public static void main(String[] args) throws Exception {
2617N/A SleeperApplication myApp = new SleeperApplication();
2617N/A
2617N/A SimpleApplication.setMyApp(myApp);
2617N/A
2617N/A SimpleApplication.main(args);
2617N/A }
2617N/A}