16_EZEL_final

Download Report

Transcript 16_EZEL_final

Developer Libraries and Services
16-1
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
16-1
Overview
●
●
Optional Libraries
–
EZEL
–
JAL
JXTA Services
–
JAAS
–
JNLP
–
RMI, SOAP, etc.
16-1
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
16-1
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
16-1
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
16-1
JAL Architecture
Application
Peer interface
EZEL
JXTA Abstraction
Layer
JXTA
16-1
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
16-1
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
16-1
JAL API
Message Functions
●
boolean sendMessage(String name, Message msg)
Message receiveMessage()
–
●
boolean broadcast(Message msg)
–
●
Broadcast a message to everyone in the group
Message newMessage()
–
●
Send or receive a message
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
16-1
JAL API
Group Functions
●
String[] getGroups()
–
●
void createGroup(String name)
–
●
Create and/or join group
void joinGroup(String name)
–
●
Create a new group
void createAndOrJoinGroup(String name)
–
●
Get peergroups associated with this peer
Join a group
void leaveGroup(String name)
16-1
JAL API
Search & Display Functions
●
boolean searchGroupWithName(String name)
–
●
boolean searchPeerWithName(String name)
–
●
Search for a peer
void displayPeers()
void displayGroups()
void displayServices()
–
●
Search for a peergroup
Display all peers, peergroups, or services in the current
peergroup
String getPeerStatistics()
–
Display some useful statistics
16-1
JAL Example
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);
}
}
16-1
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
16-1
JAAS Membership Service Project
●
JAAS MemberShip Service
–
JXTA MembershipService implementation
●
–
Leverage existing authentication services
●
–
(JNDI, LDAP, NIS, WinNT, and Unix)
Provides a framework for integrating new
authentication services
●
●
Uses JAAS for authentication
(Liberty, SAML, Passport)
Status
–
A functional implementation of
JaasMembershipService is in place
●
http://jaas-membership.jxta.org
16-1
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) {
}
16-1
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/
16-1
JXTA Community Services
●
http://services.jxta.org
–
SOAP
●
–
JXTA-RMI
●
–
RMI API on top of JXTA
Validation Service
●
–
JXTA SOAP bindings
A ValidationService for JXTA Advertisements
Many more ...
16-1
Developer Libraries and Services
16-1