1 /* 2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 3 * Copyright 2013 SAP AG. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. Oracle designates this 9 * particular file as subject to the "Classpath" exception as provided 10 * by Oracle in the LICENSE file that accompanied this code. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 */ 26 package sun.tools.attach; 27 28 import com.sun.tools.attach.VirtualMachine; 29 import com.sun.tools.attach.VirtualMachineDescriptor; 30 import com.sun.tools.attach.AttachNotSupportedException; 31 import java.io.IOException; 32 33 // Based on linux/classes/sun/tools/attach/AttachProviderImpl.java. 34 35 /* 36 * An AttachProvider implementation for Aix that uses a UNIX domain 37 * socket. 38 */ 39 public class AttachProviderImpl extends HotSpotAttachProvider { 40 41 public AttachProviderImpl() { 42 } 43 44 public String name() { 45 return "sun"; 46 } 47 48 public String type() { 49 return "socket"; 50 } 51 52 public VirtualMachine attachVirtualMachine(String vmid) 53 throws AttachNotSupportedException, IOException 54 { 55 checkAttachPermission(); 56 57 // AttachNotSupportedException will be thrown if the target VM can be determined 58 // to be not attachable. 59 testAttachable(vmid); 60 61 return new VirtualMachineImpl(this, vmid); 62 } 63 64 public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) 65 throws AttachNotSupportedException, IOException 66 { 67 if (vmd.provider() != this) { 68 throw new AttachNotSupportedException("provider mismatch"); 69 } 70 // To avoid re-checking if the VM if attachable, we check if the descriptor 71 // is for a hotspot VM - these descriptors are created by the listVirtualMachines 72 // implementation which only returns a list of attachable VMs. 73 if (vmd instanceof HotSpotVirtualMachineDescriptor) { 74 assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); 75 checkAttachPermission(); 76 return new VirtualMachineImpl(this, vmd.id()); 77 } else { 78 return attachVirtualMachine(vmd.id()); 79 } 80 } 81 82 }