1 2 package SOFA.SOFAnode.Run.Deployment; 3 4 import org.omg.CosNaming.NameComponent ; 5 6 import SOFA.SOFAnode.Run.DeplDockRegistry.DeplDockRegistry; 7 import SOFA.SOFAnode.Run.DeplDockRegistry.DeplDockRegistryHelper; 8 import SOFA.SOFAnode.Run.DeplDockRegistry.NotFoundException; 9 10 14 public class DeplDockScanner { 15 public static void main(String [] argv) { 16 if (argv.length != 1) { 17 System.out.println("Bad number of the arguments."); 18 System.out.println("Specify name of the deployment dock"); 19 System.exit(1); 20 } 21 22 if (System.getSecurityManager() == null) { 23 System.setSecurityManager(new java.rmi.RMISecurityManager ()); 24 } 25 26 SOFA.Util.CORBAAccess ca = new SOFA.Util.CORBAAccess(); 27 28 NameComponent nc = new NameComponent ("DeplDockRegistry", ""); 29 NameComponent path[] = {nc}; 30 DeplDockRegistry ddr = null; 31 try { 32 System.out.print("Obtaining depldock registry..."); 33 ddr = DeplDockRegistryHelper.narrow(SOFA.Util.CORBAAccess.ncRef.resolve(path)); 34 System.out.println("OK"); 35 } catch (Exception e) { 36 System.out.println("Can't get DeplDock registry."); 37 e.printStackTrace(); 38 System.exit(1); 39 } 40 41 42 byte[] serRef = null; 43 try { 44 System.out.print("Obtaining reference to depldock..."); 45 serRef = ddr.lookup(argv[0]); 46 System.out.println("OK"); 47 } catch (NotFoundException e) { 48 System.out.println("No deployment dock with name \""+argv[1]+"\"."); 49 System.exit(1); 50 } 51 52 SOFA.Connector.Reference ddRef = SOFA.SOFAnode.Run.Deployment.DeplDockImpl.bytesToSofaReference(serRef); 53 54 DeplDock ddock = null; 55 try { 56 System.out.print("Creating connector to depldock..."); 57 ddock = (DeplDock) SOFA.Connector.Boot.DeplDockConnector.createClt(ddRef); 58 System.out.println("OK"); 59 } catch (SOFA.Connector.ConnectorException e) { 60 System.out.println("Can't create connector to deployment dock."); 61 System.exit(1); 62 } 63 64 String [] names = ddock.namesOfAllRunningComponents(); 65 System.out.print("Number of the components: "); 66 System.out.println(names.length); 67 for (int i=0; i<names.length; i++) { 68 System.out.println(names[i]); 69 } 70 } 71 } 72 | Popular Tags |