basico de java...urgente!

triclap
27 de Abril del 2008
Hola a todos!! estoy haceindo un trabajo para la universidad...se trata de implementar un servicio en Jini. la interfaz del servidor ya la tengo hecha...ahora estoy haciendo la parte del cliente!! he intentado averiguar loq me me pasa con los errores que me dan...pero no se mucho de java y no se q mas hacer... me salen errores en el DataInputStream y sobretodo en el switch!! alguien me podria ayudar?? muchas gracias!!

package refrigerator;

import net.jini.core.entry.*;
import net.jini.core.lookup.*;
import net.jini.core.discovery.*;
import net.jini.lookup.entry.*;
import com.sun.jini.lookup.entry.*;
import java.io.*;
import java.rmi.*;

// declaration class
public class refrigeratorJiniServiceClient {
//principal function
public static void main(String [] arg){

Entry [] aeAttributes;
LookupLocator lookup;
ServiceID id;
ServiceRegistrar registrar;
ServiceTemplate template;
refrigeratorJiniService myrefrigeratorJiniService;
DataInputStream DataInputStream;
try

{

System.setSecurityManager(new RMISecurityManager());

lookup = new LookupLocator ("jini//localhost");

registrar = lookup.getRegistrar();
id = registrar.getServiceID();

System.out.println("client: ServiceRegistrar =" + registrar);
System.out.println("client: ServiceID =" + id);

aeAttributes = new Entry[1];
aeAttributes[0] = new Name ("MyServer");

template = new ServiceTemplate (null, null, aeAttributes);

myrefrigeratorJiniService = (refrigeratorJiniService)registrar.lookup(template);

System.out.println("Client : ServiceTemplate =" + template);
System.out.println("Client : Service object =" + myrefrigeratorJiniService);

String election;
String onoffdegree;

//String read;

DataInputStream input = new DataInputStream(System.in);

if(myrefrigeratorJiniService instanceof refrigeratorJiniService)
{
System.out.println("Service Refrigerator n" + "choose one option:n" + "1-Powern" + "2-Temperaturen" /*"3-RFIDn"*/);

//the user choose the service:
election = input.readLine();

System.out.println("Choose the state:n" + "1- Off - 0ºn" + "2- On - 36º predeterminaten");

//the user choose the state and the temperature of the refigerator
onoffdegree = input.readLine();

}

//call to the methods
switch(election)
{
case 1: myrefrigeratorJiniService.power(onoffdegree);
break;
case 2: myrefrigeratorJiniService.temperature(onoffdegree);
break;
//case 3: myrefrigeratorJiniService.rfid(read);
default: break;

}

}catch (Exception e){
System.out.println("refrigeratorJiniServiceClient: main() exception" +e);
}
}
}