Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaspace;
- import net.jini.space.JavaSpace;
- /**
- *
- * @author duszek
- */
- public class JavaSpaceLab {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- try {
- System.out.println("Szukam Java Space");
- Lookup finder = new Lookup(JavaSpace.class);
- JavaSpace space = (JavaSpace) finder.getService();
- System.out.println("Znaleziono Java Space");
- System.out.println("Zapis do JS");
- for(int i=0; i<99; ++i)
- {
- MessageEntry product = new MessageEntry(i, i+1, i+2);
- space.write(product, null, 60*60*60*100);
- System.out.println("Pisz: "+product.ToString());
- }
- System.out.println("Odczyt z JS!");
- MessageEntry template = new MessageEntry();
- while(true)
- {
- MessageEntry first= (MessageEntry) space.takeIfExists(template, null, 60*60*100);
- MessageEntry second= (MessageEntry) space.takeIfExists(template, null, 60*60*100);
- MessageEntry third= (MessageEntry) space.takeIfExists(template, null, 60*60*100);
- MessageEntry newProduct = new MessageEntry();
- if(first != null && second != null && third!= null)
- {
- newProduct.Change(first,second,third);
- space.write(newProduct, null, 60*60*100);
- System.out.println("Pisz nowy: "+ newProduct.ToString());
- }
- else
- {
- System.out.println("Ostateczny obiekt: " + first.ToString());
- break;
- }
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement