1 /* 2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * 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 { SimpleProvider()45 public SimpleProvider() { 46 } 47 name()48 public String name() { 49 return "simple"; 50 } 51 type()52 public String type() { 53 return "none"; 54 } 55 attachVirtualMachine(String id)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 listVirtualMachines()65 public List<VirtualMachineDescriptor> listVirtualMachines() { 66 return new ArrayList<VirtualMachineDescriptor>(); 67 } 68 } 69 70 class SimpleVirtualMachine extends VirtualMachine { SimpleVirtualMachine(AttachProvider provider, String id)71 public SimpleVirtualMachine(AttachProvider provider, String id) { 72 super(provider, id); 73 } 74 detach()75 public void detach() throws IOException { 76 } 77 loadAgentLibrary(String agentLibrary, String options)78 public void loadAgentLibrary(String agentLibrary, String options) 79 throws IOException, AgentLoadException, AgentInitializationException 80 { 81 } 82 loadAgentPath(String agentLibrary, String options)83 public void loadAgentPath(String agentLibrary, String options) 84 throws IOException, AgentLoadException, AgentInitializationException 85 { 86 } 87 loadAgent(String agentLibrary, String options)88 public void loadAgent(String agentLibrary, String options) 89 throws IOException, AgentLoadException, AgentInitializationException 90 { 91 } 92 getSystemProperties()93 public Properties getSystemProperties() throws IOException { 94 return new Properties(); 95 } 96 getAgentProperties()97 public Properties getAgentProperties() throws IOException { 98 return new Properties(); 99 } 100 dataDumpRequest()101 public void dataDumpRequest() throws IOException { 102 } 103 startLocalManagementAgent()104 public String startLocalManagementAgent() { 105 return null; 106 } 107 startManagementAgent(Properties agentProperties)108 public void startManagementAgent(Properties agentProperties) { 109 } 110 111 } 112