Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-31-2008, 06:50 PM
Member
 
Join Date: Mar 2008
Posts: 1
Rep Power: 0
pushpik is on a distinguished road
Default distributed computing in java
Hi,
I am writing a distributed computing application for my project. I am receiving a java class file in byte stream from Client PC which i want to load in Current loader of server so that i can run any method present in received class. i want to load it in current loader because this received class is made by extending another Class which is present at server.

in the code bellow class received as byte is named PrimeNumberChecker and package name jdcclient. PrimeNumberChecker is made by extending Gthread which is present at server. I have made ByteCodeLoader which extends ClassLoader to load byte in loader. whats is wrong in the code

public static void main(String[] args) {
try {
ServerSocket serverSocket = new ServerSocket(9000);
System.out.println("Server listening on port 9000 for thread classes");

System.out.println("Waiting for connections.");
Socket client = serverSocket.accept();
System.out.println("Accepted a connection from: "+client.getInetAddress());

//Getting client classes in byteArray
DataInputStream dis = new DataInputStream(client.getInputStream());
int avail = dis.available();
System.out.println("Available = " + avail);
byte byteCode[] = new byte[avail];
dis.readFully(byteCode);

ByteCodeLoader loader = new ByteCodeLoader();
loader.setByteCode(byteCode);
Class getClass = loader.loadClass("jdcclient.PrimeNumberChecker", true);

dis.close();


//Getting Thread from client
ObjectInputStream ois = new ObjectInputStream(client.getInputStream());
GThread thr = (GThread) ois.readObject();

thr.start();

//System.out.println("OutPut is "+ output.intValue());
/*
ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream());
oos.writeObject(thr);

oos.flush();
oos.close();
*/
ois.close();
client.close();

} catch (Exception ex) {
ex.printStackTrace();
}
}
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Computing prime numbers in Java Java Tip java.lang 0 04-12-2008 08:39 PM
Computing the area of a triangle using Heron's Formula Java Tip java.lang 0 04-12-2008 08:39 PM
which is the best technology for distributed application. sujithc34 Advanced Java 1 02-05-2008 06:52 PM
Computing Fibonacci numbers recursively Java Tip Java Tips 0 01-22-2008 08:20 PM


All times are GMT +2. The time now is 12:32 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org