agentinfo.java.svn-base

来自「cqME :java framework for TCK test.」· SVN-BASE 代码 · 共 135 行

SVN-BASE
135
字号
/* * $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.j2me.execution.server;import java.io.IOException;import java.io.StringReader;import java.util.ArrayList;import java.util.Collections;import java.util.LinkedHashMap;import java.util.Map;import com.sun.tck.j2me.execution.baseclient.Constants;import com.sun.tck.j2me.execution.client.RegistrationTicket;/** * This class contains all information about Agent, such as Agent ID, * properties provided during registration, task being executed, last * registration ticket, and last access time. */class AgentInfo {    private String id;    private LinkedHashMap<String, String> registrationProperties;    private RegistrationTicket lastRegistration;    private long lastAccess;    private com.sun.javatest.agent.Map map;    private ArrayList<ServerProactiveCommand> proactiveCommands;    /**     * Creates an instance with the given id, registration properties     * and RegistrationTicket.     */    public AgentInfo(String id, Map<String, String> props, RegistrationTicket ticket) {        if (props == null) {            props = Collections.emptyMap();        }        this.id = id;        registrationProperties = new LinkedHashMap<String,String>();        // sort registration options        ArrayList<String> keys = ((props == null) ? new ArrayList<String>()                                  : new ArrayList<String>(props.keySet()));        Collections.sort(keys);        for (String key : keys) {            registrationProperties.put(key, props.get(key));        }        lastRegistration = ticket;        String mapData = props.get(Constants.AGENT_MAP);        mapData = (mapData == null) ? "" : mapData;        try {            map = new com.sun.javatest.agent.Map(new StringReader(mapData));        } catch (IOException e) {            // TODO        }        proactiveCommands = new ArrayList<ServerProactiveCommand>();        changeAccess();    }    /**     * Returns the lastRegistration.     */    public synchronized RegistrationTicket getLastRegistration() {        return lastRegistration;    }    /**     * @param lastRegistration The lastRegistration to set.     */    public synchronized void setLastRegistration(RegistrationTicket lastRegistration) {        this.lastRegistration = lastRegistration;    }    /**     * Returns the id.     */    public String getId() {        return id;    }    /**     * Returns the registrationProperties.     */    public Map<String, String> getRegistrationProperties() {        return registrationProperties;    }    /**     * Sets the latest modification time to the current time.     */    public synchronized void changeAccess() {        lastAccess = System.currentTimeMillis();    }    /**     * Maps the given arguments using map file provided by     * registration properties.     */    public void mapArgs(String[] args) {        if (map != null) {            map.map(args);        }    }    /**     * Returns ArrayList with the proactive commands.     */    public ArrayList<ServerProactiveCommand> getProactiveCommands() {        return proactiveCommands;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?