/** * Sets the java.rmi.server.hostname and java.rmi.server.codebase system properties which control * the automatic remote dynamic class loading. This must be called before starting the class * server. * * @param classServerPort The port the class server will use. */ private void configRMIProperties(int classServerPort) { // Logs all RMI activity to System.err System.setProperty("java.rmi.server.logCalls", "true"); try { // Try to get figure out this server's IP address and save it as the // RMI server hostname. System.setProperty("java.rmi.server.hostname", getLocalAddress()); System.setProperty( "java.rmi.server.codebase", "http://" + System.getProperty("java.rmi.server.hostname") + ":" + classServerPort + "/"); System.setProperty( "java.rmi.server.useCodebaseOnly", "false"); // Must be false to allow remote class dynamic loading (defaults to true for JDK // 1.7+) outputCmd.apply( "java.rmi.server.hostname: " + System.getProperty("java.rmi.server.hostname") + "\n", "java.rmi.server.codebase: " + System.getProperty("java.rmi.server.codebase") + "\n", "java.rmi.server.useCodebaseOnly: " + System.getProperty("java.rmi.server.useCodebaseOnly") + "\n"); } catch (Exception e) { outputCmd.apply("Error getting local host address: " + e + "\n"); } }
/** * Obtain an ObjectInputStream that allows de-serialization of a graph of objects. * * @throws IOException when the de-serialziation fails * @return an ObjectInputStream that can be used to deserialize objects */ public ObjectInputStream createObjectInputStream( final InputStream is, final boolean resolveObject, final ClassLoader loader) throws Exception { ObjectInputStream ois = null; if (loader != null) { // Need privileged block here because EJBObjectInputStream // does enableResolveObject if (System.getSecurityManager() == null) { ois = new EJBObjectInputStream(is, loader, resolveObject); } else { try { ois = (ObjectInputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public java.lang.Object run() throws Exception { return new EJBObjectInputStream(is, loader, resolveObject); } }); } catch (PrivilegedActionException ex) { throw (IOException) ex.getException(); } } } else { ois = new ObjectInputStream(is); } return ois; }
/** * Obtain an ObjectOutputStream that allows serialization of a graph of objects. The objects can * be plain Serializable objects or can be converted into Serializable objects using the handler * * @throws IOException when the serialziation fails * @return an ObjectOutputStream that can be used to serialize objects */ public ObjectOutputStream createObjectOutputStream( final OutputStream os, final boolean replaceObject, final NonSerializableObjectHandler handler) throws IOException { // Need privileged block here because EJBObjectOutputStream // does enableReplaceObject ObjectOutputStream oos = null; if (System.getSecurityManager() == null) { oos = new EJBObjectOutputStream(os, replaceObject, handler); } else { try { oos = (ObjectOutputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public java.lang.Object run() throws Exception { return new EJBObjectOutputStream(os, replaceObject, handler); } }); } catch (PrivilegedActionException ex) { throw (IOException) ex.getException(); } } return oos; }
public VINDecoderServer() { try { // Start the RMI Server // Registry registry = LocateRegistry.createRegistry(1099); // Assign a security manager, in the event that dynamic // classes are loaded if (System.getSecurityManager() == null) System.setSecurityManager( new RMISecurityManager() { public void checkConnect(String host, int port) {} public void checkConnect(String host, int port, Object context) {} public void checkAccept(String host, int port) {} }); System.out.println("Set the security manager"); // Create an instance of our power service server ... VINDecoderImpl vd = new VINDecoderImpl(); vd.setDB("/usr/local/vendor/bea/user_projects/matson/lib/jato_matson.jar"); System.out.println("Decoding vin..."); System.out.println(vd.decode("1GTDL19W5YB530809", null)); System.out.println("End Decoding vin..."); // ... and bind it with the RMI Registry // Naming.bind ("VINDecoderService", vd); System.out.println("VINDecoderService bound...."); } catch (Exception e) { e.printStackTrace(); } }
public SetupDataClient() throws RemoteException { try { // get the registry registry = LocateRegistry.getRegistry(serverAddress, (new Integer(serverPort)).intValue()); // look up the remote object rmiServer = (databaseinter) registry.lookup("Database"); rmiServer.receiveMessage("abc"); // starting time long time1 = System.currentTimeMillis(); // call the remote method System.out.println("sending " + text + " to " + serverAddress + ":" + serverPort); // receiving time long time2 = System.currentTimeMillis(); long timedelay = time2 - time1; System.out.println("RMI delay time: " + timedelay); // converting process // finish converting long time3 = System.currentTimeMillis(); long timefinish = time3 - time1; System.out.println("Total time: " + timefinish); } catch (NotBoundException e) { e.printStackTrace(); } catch (IOException e) { System.out.println("File not found"); System.out.println(e.getMessage()); e.printStackTrace(); } }
public static void main(String[] args) { String host = args[0]; int port = Integer.parseInt(args[1]); long id = Long.parseLong(args[2]); String character = args[3]; long actorId = Long.parseLong(args[4]); // Install an RMISecurityManager, if there is not a // SecurityManager already installed if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } String name = "rmi://" + host + ":" + port + "/MovieDatabase"; try { MovieDatabase db = (MovieDatabase) Naming.lookup(name); db.noteCharacter(id, character, actorId); Movie movie = db.getMovie(id); out.println(movie.getTitle()); for (Map.Entry entry : movie.getCharacters().entrySet()) { out.println(" " + entry.getKey() + "\t" + entry.getValue()); } } catch (RemoteException | NotBoundException | MalformedURLException ex) { ex.printStackTrace(System.err); } }
/** * @see <related> * @author $Author$ * @version $Revision$ */ public class BankBean21 extends BankBean21Base { public DataSource customerDb; static final String ID = "java:comp/env/id"; String id; String customerId = "defaultId"; static long nextAccountId = System.currentTimeMillis(); static long nextCustomerId = System.currentTimeMillis(); public String getId() { return id; } public String createAccountId(Customer customer) throws RemoteException { return getId() + "." + customer.getName() + "." + (nextAccountId++); } public String createCustomerId() { return getId() + "." + (nextCustomerId++); } public void storeCustomerId(String customerId) { this.customerId = customerId; } public String retrieveCustomerId() { return customerId; } public String interceptCustomerId(String customerId) { return customerId; } public void testResource() throws Exception { if (customerDb == null) throw new Exception("customerDb resource not set"); Connection connection = customerDb.getConnection(); connection.close(); } public void remove() {} @Init public void annotatedInit() { initialized += "YES"; } public void init() { initialized += "YES"; } }
/** * Start the class file server to support remote dynamic class loading. This method must be called * after configSecurityManager() and configRMIProperties(). If the reference to the class file * server, "classFileServer" is null, it is assumed that the class file server is not runnng. * * @param classServerPort the port the class file server will use. */ private void startClassFileServer(int classServerPort) { if (null != classFileServer) stopClassFileServer(); String userDir = System.getProperty("user.dir"); outputCmd.apply("user.dir: " + userDir); try { classFileServer = new ClassFileServer(classServerPort, System.getProperty("user.dir")); } catch (java.io.IOException e) { outputCmd.apply("Unable to start ClassServer: " + e.getMessage()); e.printStackTrace(); } }
/** * Robustly make a curve to a front * * @param curve the curve * @param flip true to flip the pips * @return the resulting front as a FieldImpl * @throws RemoteException On badness */ public FieldImpl robustCurveToFront(float[][] curve, boolean flip) throws RemoteException { // resample curve uniformly along length float increment = rsegment_length / (rprofile_length * zoom); float[][] oldCurve = null; try { oldCurve = resample_curve(curve, increment); } catch (VisADError ve) { // bad curve return null; } int fw = filter_window; fw = 1; FieldImpl front = null; float[][] originalCurve = curve; debug = true; for (int tries = 0; tries < 12; tries++) { // lowpass filter curve curve = smooth_curve(oldCurve, fw); // resample smoothed curve curve = resample_curve(curve, increment); try { front = curveToFront(curve, flip); break; } catch (VisADException e) { oldCurve = curve; if (tries > 4) { int n = oldCurve[0].length; if (n > 2) { float[][] no = new float[2][n - 2]; System.arraycopy(oldCurve[0], 1, no[0], 0, n - 2); System.arraycopy(oldCurve[1], 1, no[1], 0, n - 2); oldCurve = no; } } if (tries > 8) { fw = 2 * fw; } // if (debug) System.out.println("retry filter window = " + fw + " " + e); if (tries == 9) { // System.out.println("cannot smooth curve"); front = null; } } } return front; }
public RMIConnection createConnection() { RMIServerManager serverManager = null; Context initialNamingContext = null; try { initialNamingContext = new InitialContext(); } catch (NamingException exception) { System.out.println("Naming Exception " + exception.toString()); } ; // Set the client security manager try { System.setSecurityManager(new RMISecurityManager()); } catch (Exception exception) { System.out.println("Security violation " + exception.toString()); } // Get the remote factory object from the Registry try { serverManager = (RMIServerManager) initialNamingContext.lookup("SERVER-MANAGER"); } catch (Exception exception) { throw new TestProblemException(exception.toString()); } RMIConnection rmiConnection = null; try { rmiConnection = new RMIConnection(serverManager.createRemoteSessionController()); } catch (RemoteException exception) { System.out.println("Error in invocation " + exception.toString()); } return rmiConnection; }
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("del")) { try { UnionSet set = (UnionSet) ref.getData(); SampledSet[] sets = set.getSets(); SampledSet[] new_sets = new SampledSet[sets.length - 1]; System.arraycopy(sets, 0, new_sets, 0, sets.length - 1); ref.setData(new UnionSet(set.getType(), new_sets)); } catch (VisADException ex) { } catch (RemoteException ex) { } } else if (cmd.equals("fill")) { UnionSet set = null; try { set = (UnionSet) ref.getData(); System.out.println("area = " + DelaunayCustom.computeArea(set)); } catch (VisADException ex) { System.out.println(ex.getMessage()); } try { // Irregular2DSet new_set = DelaunayCustom.fill(set); Irregular2DSet new_set = DelaunayCustom.fillCheck(set, false); if (new_ref == null) { new_ref = new DataReferenceImpl("fill"); ConstantMap[] cmaps = new ConstantMap[] { new ConstantMap(1.0, Display.Blue), new ConstantMap(1.0, Display.Red), new ConstantMap(0.0, Display.Green) }; DataRenderer renderer = (display instanceof DisplayImplJ3D) ? (DataRenderer) new DefaultRendererJ3D() : (DataRenderer) new DefaultRendererJ2D(); renderer.suppressExceptions(true); display.addReferences(renderer, new_ref, cmaps); } new_ref.setData(new_set); } catch (VisADException ex) { System.out.println(ex.getMessage()); } catch (RemoteException ex) { System.out.println(ex.getMessage()); } } else if (cmd.equals("lines")) { try { lines = !lines; GraphicsModeControl mode = display.getGraphicsModeControl(); if (lines) { mode.setPolygonMode(DisplayImplJ3D.POLYGON_LINE); } else { mode.setPolygonMode(DisplayImplJ3D.POLYGON_FILL); } } catch (VisADException ex) { System.out.println(ex.getMessage()); } catch (RemoteException ex) { System.out.println(ex.getMessage()); } } }
public void mouseClicked(MouseEvent e) { int x = e.getX(); int y = e.getY(); int currentTabIndex = -1; int tabCount = tabPane.getTabCount(); for (int i = 0; i < tabCount; i++) { if (rects[i].contains(x, y)) { currentTabIndex = i; break; } // if contains } // for i if (currentTabIndex >= 0) { Rectangle tabRect = rects[currentTabIndex]; x = x - tabRect.x; y = y - tabRect.y; if ((x >= 5) && (x <= 15) && (y >= 5) && (y <= 15)) { try { tabbedPane.remove(currentTabIndex); } catch (Exception ex) { ex.printStackTrace(); } } // if } // if currentTabIndex >= 0 System.gc(); } // mouseClicked
// ---------------------------------------------------------------------------------------- public void createAndBroadcastMatrix( String[] rowNames, String[] columnNames, double[] data, String matrixName) { // System.out.println (" ------- RShellGoose.cabm"); // System.out.println (" row name count: " + rowNames.length); // System.out.println (" col name count: " + columnNames.length); // System.out.println (" data length: " + data.length); // System.out.println (" name: " + matrixName); DataMatrix matrix = new DataMatrix(); int rowCount = rowNames.length; int columnCount = columnNames.length; matrix.setSize(rowCount, columnCount); if (matrixName != null) { matrix.setShortName(matrixName); // matrix.setName(matrixName); } matrix.setRowTitles(rowNames); matrix.setColumnTitles(columnNames); for (int r = 0; r < rowCount; r++) { double[] rowValues = new double[columnCount]; int fromPosition = r * columnCount; System.arraycopy(data, fromPosition, rowValues, 0, columnCount); matrix.set(r, rowValues); } // for r broadcastMatrix(matrix); } // createAndBroadcastMatrix
// private static final String HOST = "localhost"; public static void main(String[] args) throws Exception { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } ClientImpt client = new ClientImpt(args); LocateRegistry.createRegistry(6600); String rmiObjectName = "rmi://localhost:6600/Client"; Naming.rebind(rmiObjectName, client); System.out.println(args[0] + " Broker server run...\n"); }
public void run() { try { Thread.sleep(1000); System.exit(0); } catch (Exception e) { e.printStackTrace(); } }
private static Echo[] spawnAndTest() { System.err.println("\nCreate Test-->"); Echo[] echo = new Echo[protocol.length]; for (int i = 0; i < protocol.length; i++) { JavaVM serverVM = new JavaVM("EchoImpl", "-Djava.security.policy=" + TestParams.defaultPolicy, protocol[i]); System.err.println("\nusing protocol: " + (protocol[i] == "" ? "none" : protocol[i])); try { /* spawn VM for EchoServer */ serverVM.start(); /* lookup server */ int tries = 12; // need enough tries for slow machine. echo[i] = null; do { try { echo[i] = (Echo) Naming.lookup("//:" + REGISTRY_PORT + "/EchoServer"); break; } catch (NotBoundException e) { try { Thread.sleep(2000); } catch (Exception ignore) { } continue; } } while (--tries > 0); if (echo[i] == null) TestLibrary.bomb("server not bound in 12 tries", null); /* invoke remote method and print result*/ System.err.println("Bound to " + echo[i]); byte[] data = ("Greetings, citizen " + System.getProperty("user.name") + "!").getBytes(); byte[] result = echo[i].echoNot(data); for (int j = 0; j < result.length; j++) result[j] = (byte) ~result[j]; System.err.println("Result: " + new String(result)); echo[i].shutdown(); } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { serverVM.destroy(); try { Naming.unbind("//:" + REGISTRY_PORT + "/EchoServer"); } catch (Exception e) { TestLibrary.bomb("unbinding EchoServer", e); } } } return echo; }
// ------------------------------------------------------------------------------------- public static void main(String[] args) { ClusterViewer view; if (args.length != 1) { System.err.println("usage: clusterViewer <baseUrl>"); System.exit(1); } view = new ClusterViewer(args[0].trim()); } // main
public static void main(String args[]) { try { // ReceiveMessageInterface rmiclient; RmiServer server = new RmiServer(); // rmiclient=(ReceiveMessageInterface)(registry.lookup("rmiclient")); // rmiclient.generateKeys(publicKey); KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(1024); KeyPair keypair = keyGen.genKeyPair(); publicKey = keypair.getPublic(); privateKey = keypair.getPrivate(); BufferedImage image = ImageIO.read(new File("/home/subba/Desktop/test/iris1.bmp")); // write it to byte array in-memory (jpg format) ByteArrayOutputStream b = new ByteArrayOutputStream(); ImageIO.write(image, "bmp", b); // do whatever with the array... byte[] jpgByteArray = b.toByteArray(); // convert it to a String with 0s and 1s StringBuilder sb = new StringBuilder(); int i = 0; for (byte by : jpgByteArray) { i++; if (i > 366) break; sb.append(Integer.toBinaryString(by & 0xFF)); } sb.append("0000000000000000000000000000000000000000000"); System.out.println(sb.toString().length()); System.out.println(sb.toString()); int token = 170; StringBuilder sb1 = new StringBuilder(); sb1.append(Integer.toBinaryString(token)); for (int j = 0; j < 102; j++) { sb1.append("00000000000000000000"); } System.out.println("Binary is " + sb1.length()); for (i = 0; i < sb.length(); i++) { bioTemplate.append(sb.charAt(i) ^ sb1.charAt(i)); } /*MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hashvalue=serviceProviderKey.getBytes(); digest.update(hashvalue); Phashdigest=digest.digest(); */ securePassword = getSecurePassword(serviceProviderKey, "200"); System.out.println(securePassword); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
public static void main(String[] args) throws NamingException, RemoteException { System.setProperty("java.security.policy", "client.policy"); System.setSecurityManager(new SecurityManager()); Context namingContext = new InitialContext(); System.out.print("RMI registry bindings: "); NamingEnumeration<NameClassPair> e = namingContext.list("rmi://localhost/"); while (e.hasMore()) System.out.println(e.next().getName()); String url = "rmi://localhost/central_warehouse"; Warehouse centralWarehouse = (Warehouse) namingContext.lookup(url); Scanner in = new Scanner(System.in); System.out.print("Enter keywords: "); List<String> keywords = Arrays.asList(in.nextLine().split("\\s+")); Product prod = centralWarehouse.getProduct(keywords); System.out.println(prod.getDescription() + ": " + prod.getPrice()); }
public boolean shutdown(String server) throws RemoteException { if (server.equalsIgnoreCase(FORCE_SHUTDOWN)) { System.exit(0); return true; } else if (server.equalsIgnoreCase("middleware")) { // Shutdown the cars group. shutdownGroup(this.carGroup); // Shutdown the rooms group. shutdownGroup(this.roomGroup); // Shutdown the flights group. shutdownGroup(this.flightGroup); // Shutdown all the middleware servers except yourself. for (MemberInfo m : this.currentMembers) { if (!m.equals(this.myInfo)) { shutdownMember(m); } } // Shut yourself down. System.exit(0); return true; } else if (server.equalsIgnoreCase("cars")) { shutdownGroup(this.carGroup); return true; } else if (server.equalsIgnoreCase("rooms")) { shutdownGroup(this.roomGroup); return true; } else if (server.equalsIgnoreCase("flights")) { shutdownGroup(this.flightGroup); return true; } else { return false; } }
public static void main(String args[]) { /* * Create and install a security manager */ if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { Registry registry = LocateRegistry.getRegistry(2002); Hello obj = (Hello) registry.lookup("Hello"); String message = obj.sayHello(); System.out.println(message); } catch (Exception e) { System.out.println("HelloClient exception: " + e.getMessage()); e.printStackTrace(); } }
public static void main(String[] argv) { try { System.setSecurityManager(new RMISecurityManager()); Addition Hello = new Addition(); Naming.rebind("rmi://localhost/ABCD", Hello); System.out.println("Addition Server is ready."); } catch (Exception e) { System.out.println("Addition Server failed: " + e); } }
protected void initProperties(String propFileName) { // Create instance of Class Properties props = new Properties(System.getProperties()); // Try to load property list try { props.load(new BufferedInputStream(new FileInputStream(propFileName))); } catch (IOException ex) { ex.printStackTrace(); System.out.println("Exception in SpaceAccessor"); System.exit(-3); } // Output property list (can be ommitted - testing only) System.out.println("jiniURL = " + props.getProperty("jiniURL")); // Assign values to fields jiniURL = props.getProperty("jiniURL"); }
public String sendDetails(String password, byte[] phash, String transactionID, byte[] spdata) throws RemoteException, NotBoundException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.DECRYPT_MODE, privateKey); byte[] cipherData = cipher.doFinal(spdata); String x = new String(cipherData); String sp[] = new String[10]; StringTokenizer st = new StringTokenizer(x.toString(), "|"); int count = 0; StringBuilder message = new StringBuilder(); while (st.hasMoreTokens()) { sp[count] = st.nextToken(); count++; } String decodemessgae = new String(); if (securePassword.equals(sp[1]) && serviceProviderId.equals(sp[0].toString().trim())) { System.out.println("hellosubba"); if (transactionID.equals(transactionDetails[0].toString())) { int qrData[] = new int[16]; for (int i = 0; i < password.length(); i++) { message.append(password.charAt(i) ^ bioTemplate.charAt(i)); } for (int i = 0; i < message.length(); i++) { if (message.charAt(i) == '1') { decodemessgae += '0'; } else decodemessgae += '1'; } int start = 56, end = 63; for (int i = 0; i < 16; i++) { qrData[i] = Integer.parseInt(decodemessgae.substring(start, end), 2); start += 64; end += 64; } RsDecode dec = new RsDecode(16); int r = dec.decode(qrData); System.out.println("r=" + r); System.out.println("qrData=" + java.util.Arrays.toString(qrData)); int[] MM = new int[qrData.length + 16]; System.arraycopy(qrData, 0, MM, 0, qrData.length); RsEncode enc = new RsEncode(16); enc.encode(MM); System.out.println("qrData=" + java.util.Arrays.toString(MM)); } } else { message.append("unkonw third party user"); } return message.toString(); }
public static void main(String[] args) { String host = args[0]; int port = Integer.parseInt(args[1]); if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } String name = "//" + host + ":" + port + "/EquationSolver"; double[][] A = { {4.0, 3.0, 1.0}, {2.0, -6.0, 4.0}, {7.0, 5.0, 3.0} }; double[] b = {17.0, 8.0, 32.0}; try { EquationSolver solver = (EquationSolver) Naming.lookup(name); double[] x = solver.solve(A, b); StringBuffer sb = new StringBuffer(); for (int i = 0; i < x.length; i++) { sb.append(x[i]); sb.append(' '); } System.out.println(sb); } catch (RemoteException ex) { ex.printStackTrace(System.err); } catch (NotBoundException ex) { ex.printStackTrace(System.err); } catch (MalformedURLException ex) { ex.printStackTrace(System.err); } }
// we define the method for getting a video link when pressing enter public String getvidlink() { try { System.setSecurityManager(new SecurityManager()); ipadd = tfIP.getText(); Interface client = (Interface) Naming.lookup("rmi://" + ipadd + "/getvid"); // Get the String entered into the TextField tfInput, convert to int link = tfInput.getText(); vlink = client.getvid(link); } catch (Exception e) { System.out.println("[System] Server failed: " + e); } return vlink; }
private static void reactivateAndTest(Echo[] echo) { System.err.println("\nReactivate Test-->"); for (int i = 0; i < echo.length; i++) { try { System.err.println("\nusing protocol: " + (protocol[i] == "" ? "none" : protocol[i])); byte[] data = ("Greetings, citizen " + System.getProperty("user.name") + "!").getBytes(); byte[] result = echo[i].echoNot(data); for (int j = 0; j < result.length; j++) result[j] = (byte) ~result[j]; System.err.println("Result: " + new String(result)); echo[i].shutdown(); } catch (Exception e) { TestLibrary.bomb("activating EchoServer for protocol " + protocol[i], e); } } }
public static void main(String args[]) { try { String serverName = args[0]; Solver solver = new Solver(); String rmiObServer = "rmi://" + HOST + "/" + serverName; Naming.rebind(rmiObServer, solver); System.out.println("Server ready"); } catch (ArrayIndexOutOfBoundsException ex) { System.out.println("Error! E' necessario specificare il nome del server"); } catch (RemoteException r) { System.out.println("Error while rebind object"); r.printStackTrace(); System.exit(1); } catch (MalformedURLException m) { System.out.println("Error! Malformed url require"); } }
public TransactionManagerAccessor(String propFileName) { LookupLocator locator = null; ServiceRegistrar registrar = null; // Security manager try { System.setSecurityManager(new RMISecurityManager()); } catch (Exception e) { e.printStackTrace(); } // Get properties from property file initProperties(propFileName); try { // Get lookup service locator at "jini://hostname" // use default port and register of the locator locator = new LookupLocator(jiniURL); registrar = locator.getRegistrar(); // Space name provided in property file ServiceTemplate template; // Specify the service requirement, array (length 1) of // instances of Class Class[] types = new Class[] {TransactionManager.class}; template = new ServiceTemplate(null, types, null); // Get manager, 10 attempts! for (int i = 0; i < 10; i++) { Object obj = registrar.lookup(template); if (obj instanceof TransactionManager) { manager = (TransactionManager) obj; break; } System.out.println("BasicService. TransactionManager not " + "available. Trying again..."); Thread.sleep(MAX_LOOKUP_WAIT); } } catch (Exception e) { e.printStackTrace(); } }
// ---------------------------------------------------------------------------------------- public double[] getAllMatrixData() { if (matrix == null) { System.out.println("The R goose has not received a matrix broadcast."); return new double[0]; } int rowCount = matrix.getRowCount(); int columnCount = matrix.getColumnCount(); int total = rowCount * columnCount; double result[] = new double[total]; for (int r = 0; r < rowCount; r++) { double[] rowValues = matrix.get(r); int toPosition = r * columnCount; System.arraycopy(rowValues, 0, result, toPosition, columnCount); } // for r return result; } // getAllMatrixData