Jini+JavaSpace05 to j2ee
Luis Arce <[email protected]> Thu, 20 Dec 2007 21:26:19 +0000
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
Anyone know what is the best practice for connect Jini+JavaSpace05 to j2ee
(ejb,servlet or J2EE-JCA).
My code is the next:
public class Jini
extends HttpServlet
implements DiscoveryListener,LeaseListener
{
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
try
{
Long tiempo=System.currentTimeMillis();
System.setSecurityManager(new RMISecurityManager());
LookupDiscovery descubrir=
new LookupDiscovery(LookupDiscovery.ALL_GROUPS);
descubrir.addDiscoveryListener(this);
Thread.currentThread().sleep(Lease.FOREVER);
}
catch(RemoteException e)
{
System.out.println(e.toString());
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,IOException
{
PrintWriter out=response.getWriter();
out.write("Hola");
out.close();
}
public void discovered(DiscoveryEvent evt)
{
try
{
ServiceRegistrar[] registrars=evt.getRegistrars();
for(int n=0;n<registrars.length;n++)
{
System.out.println("Descubriendo");
ServiceRegistrar registrar=registrars[n];
ServiceTemplate tmpl=new ServiceTemplate(null,new Class[]
{ JavaSpace05.class },null);
JavaSpace05 jsprueba=(JavaSpace05)registrar.lookup(tmpl);
if(jsprueba!=null)
{
System.out.println("Escribiendo grid");
Factura factura=new Factura();
factura.nombre="prueba1";
factura.nombre="valor1";
Entry prueba=factura;
jsprueba.write(prueba,null,Long.MAX_VALUE);
}
}
}
catch(RemoteException e)
{
System.out.println(e.toString());
}
catch(TransactionException e)
{
System.out.println(e.toString());
}
}
public void discarded(DiscoveryEvent evt)
{
System.out.println("Descartando "+evt.toString());
}
public void notify(LeaseRenewalEvent evt)
{
System.out.println("Expirado"+evt.toString());
}
}
Best regards,
Luis Arce
_________________________________________________________________
Consigue aquà las mejores y mas recientes ofertas de trabajo en América
Latina y USA: http://latam.msn.com/empleos/
--------------------------------------------------------------------------
Getting Started: http://www.jini.org/wiki/Category:Getting_Started
Community Web Site: http://jini.org
jini-users Archive: http://archives.java.sun.com/archives/jini-users.html
Unsubscribing: email "signoff JINI-USERS" to [email protected]