001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Aleksey V. Yantsen
021: * @version $Revision: 1.5 $
022: */
023:
024: /**
025: * Created on 10.25.2004
026: */package org.apache.harmony.jpda.tests.framework.jdwp;
027:
028: import org.apache.harmony.jpda.tests.framework.DebuggeeWrapper;
029: import org.apache.harmony.jpda.tests.framework.LogWriter;
030: import org.apache.harmony.jpda.tests.framework.TestErrorException;
031: import org.apache.harmony.jpda.tests.framework.TestOptions;
032: import org.apache.harmony.jpda.tests.framework.jdwp.TransportWrapper;
033: import org.apache.harmony.jpda.tests.framework.jdwp.VmMirror;
034:
035: /**
036: * This class represents specific kind of <code>DebuggeeWrapper</code> for JDWP tests.
037: * It encapsulates JDWP connection and communicates with debuggee using
038: * command, reply, and event packets.
039: */
040: public abstract class JDWPDebuggeeWrapper extends DebuggeeWrapper {
041:
042: public VmMirror vmMirror;
043:
044: /**
045: * Creates an instance of JDWPDebuggeeWrapper.
046: *
047: * @param settings test run options
048: * @param logWriter logWriter for messages
049: */
050: public JDWPDebuggeeWrapper(TestOptions settings, LogWriter logWriter) {
051: super (settings, logWriter);
052: vmMirror = createVmMirror(settings, logWriter);
053: }
054:
055: /**
056: * Creates new instance of appropriate TransportWrapper.
057: *
058: * @return new instance of TransportWrapper
059: */
060: public TransportWrapper createTransportWrapper() {
061: String name = settings.getTransportWrapperClassName();
062: try {
063: Class cls = Class.forName(name);
064: return (TransportWrapper) cls.newInstance();
065: } catch (Exception e) {
066: throw new TestErrorException(e);
067: }
068: }
069:
070: /**
071: * Creates new instance of VmMirror.
072: *
073: * @return new instance of VmMirror
074: */
075: protected VmMirror createVmMirror(TestOptions settings,
076: LogWriter logWriter) {
077: return new VmMirror(settings, logWriter);
078: }
079:
080: /**
081: * Returns opened JDWP connection or null.
082: *
083: * @return JDWP connection or null
084: */
085: public TransportWrapper getConnection() {
086: return vmMirror.getConnection();
087: }
088:
089: /**
090: * Sets opened JDWP connection.
091: *
092: * @param connection to set
093: */
094: public void setConnection(TransportWrapper connection) {
095: vmMirror.setConnection(connection);
096: }
097:
098: /**
099: * Resumes debuggee VM.
100: */
101: public void resume() {
102: vmMirror.resume();
103: }
104:
105: /**
106: * Disposes debuggee VM.
107: */
108: public void dispose() {
109: vmMirror.dispose();
110: }
111:
112: /**
113: * Exit target Virtual Machine
114: */
115: public void exit(int exitStatus) {
116: vmMirror.exit(exitStatus);
117: }
118:
119: }
|