org.netbeans.lib.collab

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » collab » org.netbeans.lib.collab 
org.netbeans.lib.collab
Netbeans Collab Service API - Overview

Netbeans Collab Service API

 

Overview

The collab service is the communication layer allowing netbeans users to communicate in real-time, by providing access to Conference, Presence, Data Streaming, News and Notification services. The Collab Service API may also be used directly in order to build application leveraging these services. Possible applications include:
  • portal channels displaying contact lists and allowing real-time communication.
  • presence status display and initiation of conferences from other Web-based collaboration applications, such as web-based email, calendar, or address books.
  • desktop-based instant messaging clients
  • handheld-based instant messaging clients (through a gateway)
  • leverage presence status in server applications in order to notify end-users optimally.

Available services

Architecture


 

How to use the API

 

Creating a Session

A session is a service-independent authentication handle.  It is created by passing credentials and having them validated by the services infrastructure.

In order to create sessions, an application must first instantiate CollaborationSessionFactory. Then the factory can be used to create one or more session objects. Example:

CollaborationSessionFactory fac = new CollaborationSessionFactory();

// create a session listener for asynchronous session events
CollaborationSessionListener listener = new MyCollaborationSessionListener();

// create a session
Session session = fac.getSession("myserver.example.com", "fred@example.com",
                                 "secret", listener);

 

Accessing services

Once a Session is created, individual services can  be accessed using the corresponding accessor and initialization methods. So for example with the Conference service:

// access the Conference Service
ConferenceService cService = session.getConferenceService();

// and do not forget to initialize it with your listener
ConferenceServiceListener csListener = new MyConferenceServiceListener();
cService.initialize(csListener);

 

The Conference Service

Once the ConferenceService object has been created, a conference can be initiated by inviting one or more other users.  For Example:
// create a ConferenceListener for asynchronous chat events
// (e.g. messages).
MyConferenceListener cListener = new MyConferenceListener();
// create the conference.
Conference c = cService.setupConference(cListener, Conference.MANAGE)
To invite users to this conference, one needs to setup an invite message and call invite using this message.
// create invite message 
Message newMsg = c.createInviteMessage(); 
newMsg.addRecipient("roscoe@example.com"); 
newMsg.addRecipient("yolanda@example.com"); 
MessagePart part = newMsg.newPart(); 
part.setContent("Let's talk"); 
newMsg.addPart(part); 
 
// send the invite 
e.invite(newMsg); 
 
One can also join an already existing public conference, by using its well-known address:
// join public conference conf123@example.com
Conference c = cService.join("conf123@example.com", cListener);

Once a Conference object is created, it can be used to build and send messages, as if it was a private conference.
 

The News Service

To use the news functionality, one needs to create a NewsChannel object for each news channel of interest, as follows
// create a news channel listener for asynchronous events
(e.g. messages added or removed).
// note: MyNewsChannelListener implements the NewsChannelListener
interface.
MyNewsChannelListener bbListener = new MyNewsChannelListener();
// subscribe to the news channel.  news channel messages
are received
// asynchronously, through the listener.  One may also pass
a null
NewsChannel  bb = nService.getNewsChannel("hugo@example.com",
bbListener)


Once created, the NewsChannel object can be used to generate, add or remove messages.

// generate a new message
Message message = bb.createMessage();
// add content to message
// publish it
bb.addMessage(message);


To find out which news channels are available, use the listNewsChannels method:

// get a Collection of news channels.
java.util.Collection bbList = session.listNewsChannels();
// loop through the list until you find the one you want
if (bbList != null) {
    java.util.Iterator bbIter = bbList.iterator();
    while (bbIter.hasNext()) {
        NewsChannel bb = (NewsChannel)bbIter.next();
        if (bb.getDestination.equals("theOneIWant")) {
            break;
        }
    }
}
// subscribe to it to get messages
bb.subscribe(bbListener);

 
 
Finally, it is also possible to create new news channels, as follows:
bb = session.newNewsChannel("hugo@example.com", bbListener,                               Conference.PUBLISH);

The Notification Service

To send a message, first create one
// start a message to noah@example.com Message message = nSession.createMessage("noah@example.com");
fill it with appropriate content and headers,
message.setHeader("Subject", "just a demo"); MessagePart part = message.newPart(); String content = "the body of the message"; part.setContentType("text/plain"); part.setContent(content.bytes());
create a message status listener if you expect status or replies,
MyMessageStatusListener mListener = new MyMessageStatusListener();
and send it:
session.sendMessage(message, mListener);


Messages can also be received.  This is done through the NotificationSessionListener.onMessage method.  Received messages may be acknowledged or replied-to through the MessageHandler argument to onMessage.
 

// mark a message read. handler.sendStatus(MessageStatus.READ); // reply to a message replyMessage = nSession.createMessage(); ... handler.sendReply(replayMessage);

 

The Presence Service

To use the presence service, first create a PresenceSession using CollaborationSession.accessService

To access the presence information of a user of the service, use the fetch or subscribe methods

// subscribe to hugo's presentity
// Note: MyPresenceInfoListener implements PresenceInfoListener
MyPresenceInfoListener piListener = new MyPresenceInfoListener();
java.util.Date expiration =
PresenceSubscription subs = pSession.subscribe("hugo@example.com",
piListener, expiration);
...
// unsubscribe
subs.cancel();

Presence information is received asynchronously by the presence info listener in the form of an XML String. This String may be parsed using the PresenceHelper class. The following prints out presence info.

PresenceHelper ph = new PresenceHelper(pi /* XML string */);
for (Iterator i = ph.getTuples().iterator(); i.hasNext() ; ) {
    PresenceTuple t = (PresenceTuple)i.next();
    System.out.println(t.destination + " " + t.status + " " + t.note);
}

To publish presence information updates, use the publish method. The argument is an XML String which can be genberated with the help of the PresenceHelper class.

PresenceTuple pt = new PresenceTuple("hugo@example.com",
                                     PresenceSession.STATUS_AWAY);
PresenceHelper ph = new PresenceHelper();
ph.addTuple(pt);
pSession.publish(ph.toString());

 

The Personal Store Service

To use the Personal Store service, first create a PersonalStoreSession using CollaborationSession.accessService

To retrieve the contact list of the user who owns the current session, retrieve the contact folders

Collection folders = psSession.getFolders(PersonalStoreFolder.CONTACT_FOLDER);
For each folder fthe list of contacts can be obtained as follows:
Collection entries = f.getEntries();
System.out.println(" - " + f.getDisplayName());
for (Iterator j = entries.iterator() ; j.hasNext() ;) {
    PersonalContact c = (PersonalContact)j.next();
    System.out.println("Found " + c.getDisplayName() + " in " + f.getDisplayName());
}

Using an alternate session provider

The instructions listed above will let you create an IM session, similar to a session that would be created by an XMPP/Jabber client. However, it is possible to create other types of session, by using alternative session providers. Several provider implementation are bundle with the API. Others can be built and used by the application (e.g. netbeans) in order to leverage protocols not provided by default.

The Collab Service Factory can be told to use a specific session provider, by setting the org.netbeans.lib.collab.provider system property to the class name of the provider yopu want to use. For instance, com.example.SessionProvider being a Session Provider, one would call:

System.setProperty(CollaborationSessionFactory.systemProperty, "com.example.SessionProvider");
The Collab Service API includes two alternative session providers:
  • org.netbeans.lib.collab.xmpp.XMPPSecureSessionProvider: connects to the XMPP service using the legacy SSL mode (as opposed to usign startTLS).
  • org.netbeans.lib.collab.xmpp.ProxySessionProvider: proxies XMPP traffic through a HTTP or SOCKS V5 proxy as specified using the service URL argument.
  • org.netbeans.lib.collab.xmpp.XMPPComponentSessionProvider: authenticates to the jabber service as a jabber:component:accept component
  • org.netbeans.lib.collab.xmpp.XMPPSecureComponentSessionProvider: same as above but using the old Jabber SSL.
  • org.netbeans.lib.collab.xmpp.httpbind.HTTPBindSessionProvider: accesses a Jabber/XMPP service through a JEP-0124 gateway.
The following (outdated) block diagram shows relationships between the various providers, the Collab Service API implementation, IM components, and custom application.
 
 

Sample programs

These are a few simple but actual examples written with the Collab Service API. They are provided here for educational purposes only and should not be used for other purposes.
  • Talk, a simple command line talk utility using the conference service. It allows the user to initiate conferences, invite users in conferences, be invited to conferences, and toggle between conferences.
    source code: Talk.java
  • Watcher, a simple command line utility allowing the users to keep track of the presence of other users.
    source code: Watcher.java
  • Alerter, a simple command line utility which listens for incoming notifications
    source code: Alerter.java
  • News, a simple command line utility to manage news channel: create a news channel, post new messages or remive existing messages. listens for incoming notifications
    source code: News.java

Default API Provider's documentation (XMPPSessionProvider)

Default API Provider's documentation
Java Source File NameTypeComment
ApplicationInfo.javaClass This class can be used to set the characteristics/properties of all CollaborationSession objects that will be created using a given SessionProvider.
AuthenticationException.javaClass
AuthenticationListener.javaInterface Listener which is used to query the choice of authentication mechanism to be used.
AuthorizationException.javaClass
CertificateRejectedException.javaClass
CollaborationException.javaClass
CollaborationGroup.javaInterface
CollaborationPrincipal.javaInterface
CollaborationSession.javaInterface Authenticated instant communication session.
CollaborationSessionFactory.javaClass This class is a Factory class, which can be used to create CollborationSessions.
CollaborationSessionListener.javaInterface abstract Basic listener Listeners are implemented by the application and invoked by the provider to communicate asynchronous event to the application.
CollaborationSessionProvider.javaInterface Interface defining a Collaboratio Session Provider.
Conference.javaInterface A Conference is an instant messaging session between 2 or more users.
ConferenceEvent.javaInterface An Event is a piece of information originated by the service, as opposed to a Message which is originated by another user of the service.
ConferenceEventHelper.javaClass Helper class for recipients of a poll message.
ConferenceEventListener.javaInterface interface to receive conference events as object.
ConferenceEventTuple.javaClass
ConferenceHistory.javaClass This class should be used to convey the parameters desired for getting the message history for the conference room.
ConferenceListener.javaInterface
ConferencePasswordListener.javaInterface
ConferenceService.javaInterface The Conference service. There are two types of conferences, private and public The difference between private and public is public conferences persist even when no members are present. private conferences can be setup using setupConference().
ConferenceServiceListener.javaInterface The ConferenceServiceListener.
ConflictException.javaClass
ContentStream.javaInterface
ContentStreamListener.javaInterface
ExtendedConferenceService.javaInterface
author:
   Rahul K Singh
author:
   The major difference between this and ConferenceService is , ExtendedConferenceService
author:
   requires for all of its operation.
InviteMessage.javaInterface
InviteMessageStatusListener.javaInterface
ItemNotFoundException.javaClass
MediaListener.javaInterface
MediaService.javaInterface
Message.javaInterface
MessagePart.javaInterface
MessageProcessingListener.javaInterface
MessageProcessingRule.javaInterface This class allows the application to define rules governing how messages should be processed by the service.
MessageStatus.javaClass This class defines message delivery status constants.
MessageStatusListener.javaInterface A MessageStatusListener is instantiated by the application, passed to the alert method in Session and later used to convey statusses and responses to the sender.
NewsChannel.javaInterface NewsChannels inherit all the attributes and behaviors of a conference, in particular, members can be instantly notified of new messages, access control rules are created and manages the same way.
NewsChannelListener.javaInterface
NewsService.javaInterface
NotificationService.javaInterface A Notification service is used to send and receive messages.
NotificationServiceListener.javaInterface The NotificationServiceListener Alert messages received are delivered through this listener.
P2PAudioService.javaInterface
P2PAudioSession.javaInterface
P2PAudioSessionListener.javaInterface
P2PIncomingAudioListener.javaInterface
P2PService.javaInterface
P2PServiceBase.javaInterface
P2PTransport.javaInterface
P2PUdpTransport.javaClass
PersonalConference.javaInterface This class represents a record of a public conference in a personal store.
PersonalContact.javaInterface
PersonalGateway.javaInterface
PersonalGroup.javaInterface
PersonalProfile.javaInterface
PersonalStoreEntry.javaInterface
PersonalStoreEvent.javaClass This object will be used to notify the changes in the PersonalStoreEntry objects.
PersonalStoreFolder.javaInterface
PersonalStoreService.javaInterface The PersonalStore Service The service should be intialized by calling intialize() before using any of the methods.
PersonalStoreServiceListener.javaInterface Callback object to notify any asynchromous changes in the PersonalStoreEntry objects.
Poll.javaClass
PollHelper.javaClass
PollResponse.javaClass
PolsterHelper.javaClass
Presence.javaClass
PresenceHelper.javaClass Presence Document parser.
PresenceService.javaInterface presence service session.
PresenceServiceListener.javaInterface Callback object allowing the implementation to invoke the application when a presence notification needs to be relayed to the user.
PresenceTuple.javaClass
PrivacyItem.javaInterface an access control item is one element in a list of items defining the access rule to a particular resource.
PrivacyList.javaInterface
ReadOnlyMessage.javaInterface
ReadOnlyMessagePart.javaInterface
ReceiverFileStreamingProfile.javaInterface
ReceiverStreamingProfile.javaInterface
RecipientUnvailableException.javaClass
RegistrationListener.javaInterface
RoutingException.javaClass
SASLClientProvider.javaInterface A SASL client provider allows for extending the IM server to support custom SASL protocols.
SASLClientProviderFactory.javaInterface A SASL client provider factory.
SASLData.javaInterface The data and status is sent to and recieved from the custom SASL providers using an object which adhere to this interface.
SASLProviderException.javaClass SASL Provider exception.
SecureRegistrationListener.javaInterface
SecureSessionListener.javaInterface abstract Session listener Listeners are implemented by the application and invoked by the provider to communicate asynchronous event to the application.
SecurityListener.javaInterface This specifies the callback which will be used to determine the runtime behaviour of the api w.r.t TLS.
SenderFileStreamingProfile.javaClass
SenderStreamingProfile.javaClass
ServiceUnavailableException.javaClass Exception thrown when the application attempts to access a service which is not available.
StreamingService.javaInterface
StreamingServiceListener.javaInterface
TimeoutException.javaClass Exception raised when a request to the service times out.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.