jdk/test/com/sun/tools/attach/SimpleProvider.java
changeset 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 /*
       
     2  * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    21  * have any questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  *
       
    26  *
       
    27  * Simple ("no-op") AttachProvider used in unit tests for Attach API.
       
    28  */
       
    29 import com.sun.tools.attach.VirtualMachine;
       
    30 import com.sun.tools.attach.VirtualMachineDescriptor;
       
    31 import com.sun.tools.attach.AgentLoadException;
       
    32 import com.sun.tools.attach.AgentInitializationException;
       
    33 import com.sun.tools.attach.AttachNotSupportedException;
       
    34 import com.sun.tools.attach.spi.AttachProvider;
       
    35 
       
    36 import java.io.IOException;
       
    37 import java.util.Properties;
       
    38 import java.util.List;
       
    39 import java.util.ArrayList;
       
    40 
       
    41 /*
       
    42  * AttachProvider implementation
       
    43  */
       
    44 public class SimpleProvider extends AttachProvider {
       
    45     public SimpleProvider() {
       
    46     }
       
    47 
       
    48     public String name() {
       
    49         return "simple";
       
    50     }
       
    51 
       
    52     public String type() {
       
    53         return "none";
       
    54     }
       
    55 
       
    56     public VirtualMachine attachVirtualMachine(String id)
       
    57         throws AttachNotSupportedException, IOException
       
    58     {
       
    59         if (!id.startsWith("simple:")) {
       
    60             throw new AttachNotSupportedException("id not recognized");
       
    61         }
       
    62         return new SimpleVirtualMachine(this, id);
       
    63     }
       
    64 
       
    65     public List<VirtualMachineDescriptor> listVirtualMachines() {
       
    66         return new ArrayList<VirtualMachineDescriptor>();
       
    67     }
       
    68 }
       
    69 
       
    70 class SimpleVirtualMachine extends VirtualMachine {
       
    71     public SimpleVirtualMachine(AttachProvider provider, String id) {
       
    72         super(provider, id);
       
    73     }
       
    74 
       
    75     public void detach() throws IOException {
       
    76     }
       
    77 
       
    78     public void loadAgentLibrary(String agentLibrary, String options)
       
    79         throws IOException, AgentLoadException, AgentInitializationException
       
    80     {
       
    81     }
       
    82 
       
    83     public void loadAgentPath(String agentLibrary, String options)
       
    84         throws IOException, AgentLoadException, AgentInitializationException
       
    85     {
       
    86     }
       
    87 
       
    88     public void loadAgent(String agentLibrary, String options)
       
    89         throws IOException, AgentLoadException, AgentInitializationException
       
    90     {
       
    91     }
       
    92 
       
    93     public Properties getSystemProperties() throws IOException {
       
    94         return new Properties();
       
    95     }
       
    96 
       
    97     public Properties getAgentProperties() throws IOException {
       
    98         return new Properties();
       
    99     }
       
   100 
       
   101     public void dataDumpRequest() throws IOException {
       
   102     }
       
   103 }