190 likes | 348 Views
Developer Libraries and Services. Learning Objectives:. This module will help you... Learn about optional JXTA libraries and services Understand the goals of the JXTA Easy Entry Library (EZEL) project Understand the benefits of the JXTA Abstraction Library (JAL) API
E N D
Learning Objectives: • This module will help you... • Learn about optional JXTA libraries and services • Understand the goals of the JXTA Easy Entry Library (EZEL) project • Understand the benefits of the JXTA Abstraction Library (JAL) API • Gain familiarity with the JAL API • Learn about other JXTA services
Overview • Optional Libraries • EZEL • JAL • JXTA Services • JAAS • JNLP • RMI, SOAP, etc.
EZEL Overview • EZEL = Easy Entry Library for JXTA • Goal: • Enable a client-server developer – with no JXTA or P2P experience – to create a JXTA service in a single afternoon • Provides client/server-like API • Hides implementation details • Provides reasonable defaults
Benefits • Simplifies JXTA application development • Reduces the learning curve • Provides “best practices” for handling common JXTA programming tasks • Complete isolation from API changes • Can “learn as you go” and supplement API with direct JXTA programming
JAL: JXTA Abstraction Library • Extension to EZEL • API for commonly used JXTA primitives • Discover peers (and allow to be discovered) • Search for peers and peergroups • Create and manage peergroups • Communicate with other peers • Get information about peers and peergroups
JAL Architecture Application EZEL Peer interface JXTA Abstraction Layer JXTA
EZEL Classes • class net.pkg.jal.EZAdvertisement • class net.pkg.jal.EZCommunication • class net.pkg.jal.EZDiscovery • class net.pkg.jal.EZDisplay • class net.pkg.jal.EZGroups • class net.pkg.jal.EZMinimalPeer • Implements net.pkg.jal.Peer, net.jxta.pipe.PipeMsgListener • class net.pkg.jal.EZUtilities
JAL API • void boot(String name)void boot(String name, String group) • Boot the peer; every peer must call it • void publish() • Publish peer so other can discover it • String getName() • Get the name of this peer • String[] getPeers() • Get peers associated with this peer in current peergroup
JAL API Message Functions • boolean sendMessage(String name, Message msg)Message receiveMessage() • Send or receive a message • boolean broadcast(Message msg) • Broadcast a message to everyone in the group • Message newMessage() • Create a new, blank message • void pushObject(Message msg, String tag, Object obj)Object popObject(Message msg, String tag) • Push/pop an object to the Message
JAL API Group Functions • String[] getGroups() • Get peergroups associated with this peer • void createGroup(String name) • Create a new group • void createAndOrJoinGroup(String name) • Create and/or join group • void joinGroup(String name) • Join a group • void leaveGroup(String name)
JAL API Search & Display Functions • boolean searchGroupWithName(String name) • Search for a peergroup • boolean searchPeerWithName(String name) • Search for a peer • void displayPeers()void displayGroups()void displayServices() • Display all peers, peergroups, or services in the current peergroup • String getPeerStatistics() • Display some useful statistics
import net.jxta.endpoint.Message;import net.pkg.jal.*;import java.io.*;public class TestApp { private static Peer me; public static void main (String args[]) {me = new EZMinimalPeer(); try {me.boot("MDE" + args[0]); me.displayPeers(); me.displayGroups(); me.createGroup("MDE"); me.displayGroups(); me.joinGroup("MDE"); me.displayPeers(); me.displayGroups(); //finally try out getJoinedGroups String a[] = me.getJoinedGroups(); System.out.println("getJoinedGroups:"); for(int i = 0; i < a.length; i++){ System.out.println(a[i]); } System.exit(0); }catch (Exception e) { e.printStackTrace(); System.exit(0); } System.exit(0); }} JAL Example
JAAS Overview • Java Authentication and Authorization Service (JAAS) • Enables services to authenticate and enforce access controls upon users • Supports user-based authorization • Releases • Integrated into the Java 2 SDK, Standard Edition, v 1.4 • Optional package to the Java 2 SDK, v 1.3.x
JAAS Membership Service Project • JAAS MemberShip Service • JXTA MembershipService implementation • Uses JAAS for authentication • Leverage existing authentication services • (JNDI, LDAP, NIS, WinNT, and Unix) • Provides a framework for integrating new authentication services • (Liberty, SAML, Passport) • Status • A functional implementation of JaasMembershipService is in place • http://jaas-membership.jxta.org
Code Example try { MembershipService membership = jaasGroup.getMembershipService(); AuthenticationCredential authCred = new AuthenticationCredential(jaasGroup, "JAAS", null); membership.join(membership.apply(authCred)); Enumeration enum = membership.getCurrentCredentials(); if(enum.hasMoreElements()) { JaasCredential subjCred = (JaasCredential)enum.nextElement(); Subject subject = subjCred.getSubject(); } else { System.out.println("No Credentials!"); } } catch (Exception e) { }
JXTA JnlpLoader Project • Goals: • An implementation of JxtaLoader • Utilizes Java Network Launching (JNLP) to load modules, and resources • JnlpLoader is based on OpenJNLP • http://openjnlp.nanode.org/ • Status • Basic functionality is complete • http://jnlploader.jxta.org/
JXTA Community Services • http://services.jxta.org • SOAP • JXTA SOAP bindings • JXTA-RMI • RMI API on top of JXTA • Validation Service • A ValidationService for JXTA Advertisements • Many more ...