baseagentxlet.java.svn-base
来自「cqME :java framework for TCK test.」· SVN-BASE 代码 · 共 118 行
SVN-BASE
118 行
/* * $Id$ * * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */package com.sun.tck.xlet.agent;import com.sun.tck.j2me.agent.AgentMain;import java.io.PrintStream;import javax.microedition.xlet.Xlet;import javax.microedition.xlet.XletContext;import javax.microedition.xlet.XletStateChangeException;public class BaseAgentXlet extends AgentMain implements Xlet, Runnable { protected String agentArgs[] = null; protected Thread agentThread = null; /** * Does nothing for AgentXlet. */ public synchronized void destroyXlet(boolean unconditional) throws XletStateChangeException {} /** * Reads arguments from XletContext.getXletProperty(XletContext.ARGS); * @throws XletStateChangeException if the Xlet cannot be initialized. */ public synchronized void initXlet(XletContext xc) throws XletStateChangeException { agentArgs = (String[]) xc.getXletProperty(XletContext.ARGS); } /** * Does nothing for AgentXlet. */ public synchronized void pauseXlet() {} /** * Starts Agent's execution thread. */ public synchronized void startXlet() throws XletStateChangeException { if (agentThread == null) { agentThread = new Thread(this); agentThread.start(); } } /** * Passes agentArgs to AgentMain(run). */ public void run() { try { int status = run(agentArgs); if (status != 0) { System.err.println("Error."); } } catch (IllegalArgumentException e) { System.err.println("Error: Bad arguments"); System.err.println(e.getMessage()); System.err.println(); usage(System.err); } catch (Exception e) { e.printStackTrace(); System.out.println("Unexpected exception " + e); } } /** * Displays the set of options for configuring AgentXlet. * @param out a stream to which to write the information */ public void usage(PrintStream out) { String className = getClass().getName(); out.println("Options for configuring AgentXlet :"); out.println(optionsHelp()); out.println("Options are passed as string array value of attribute XletContext.ARGS."); out.println("Each item (option name or value) must be single element of this array. "); } /** * Deprecated entry point for Xlet application model. */ public static void main(String[] args) { BaseAgentXlet dumpAgent = new BaseAgentXlet(); System.err.println("AgentXlet is not designed to run through the command line."); System.err.println("It should be started by an implementation-specific Application Manager."); System.err.println(); dumpAgent.usage(System.err); System.exit(1); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?