Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2038 - in development/laboratory/planet/facilities/xmpp: api/src/main/net/dpml/planet/xmpp impl/src/main/net/dpml/planet/xmpp/impl

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT hedhman.org
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2038 - in development/laboratory/planet/facilities/xmpp: api/src/main/net/dpml/planet/xmpp impl/src/main/net/dpml/planet/xmpp/impl
  • Date: Fri, 11 Mar 2005 15:13:52 -0500

Author: niclas AT hedhman.org
Date: Fri Mar 11 15:13:51 2005
New Revision: 2038

Modified:

development/laboratory/planet/facilities/xmpp/api/src/main/net/dpml/planet/xmpp/XMPPService.java

development/laboratory/planet/facilities/xmpp/impl/src/main/net/dpml/planet/xmpp/impl/DefaultXMPPService.java
Log:
Formatting and cleanup in the xmpp stuff

Modified:
development/laboratory/planet/facilities/xmpp/api/src/main/net/dpml/planet/xmpp/XMPPService.java
==============================================================================
---
development/laboratory/planet/facilities/xmpp/api/src/main/net/dpml/planet/xmpp/XMPPService.java
(original)
+++
development/laboratory/planet/facilities/xmpp/api/src/main/net/dpml/planet/xmpp/XMPPService.java
Fri Mar 11 15:13:51 2005
@@ -40,6 +40,7 @@
* name="net.dpml.planet.xmpp.XMPPService"
* version="1.0"
*/
-public interface XMPPService {
+public interface XMPPService
+{
XMPPConnection getConnection();
}

Modified:
development/laboratory/planet/facilities/xmpp/impl/src/main/net/dpml/planet/xmpp/impl/DefaultXMPPService.java
==============================================================================
---
development/laboratory/planet/facilities/xmpp/impl/src/main/net/dpml/planet/xmpp/impl/DefaultXMPPService.java
(original)
+++
development/laboratory/planet/facilities/xmpp/impl/src/main/net/dpml/planet/xmpp/impl/DefaultXMPPService.java
Fri Mar 11 15:13:51 2005
@@ -39,7 +39,7 @@
* a clean, simple library available from jivesoftware.org under the
* ASL for jabber communications.
*
- * @author Dan Gould
+ * @author Dan Gould
*
* @metro.component
* name="xmppService"
@@ -50,13 +50,15 @@
*
*/
public class DefaultXMPPService extends AbstractLogEnabled
- implements XMPPService,
+ implements XMPPService,
Configurable, Startable
{
- private String m_host;
- private int m_port = -1;
+ private String m_host;
+ private int m_port = -1;
private boolean m_secure = false;
- private String m_username, m_password, m_resource;
+ private String m_username;
+ private String m_password;
+ private String m_resource;

private XMPPConnection m_connection;

@@ -67,51 +69,48 @@

/**
* Sets the host, username, etc for the connection.
+ * <p>
* Takes the following parameters:
+ * <code><pre>
* Hostname (String, required)
* Port (int, optional)
* Username (String, required)
* Password (String, required)
* Resource (String, optional)
* Secure (boolean, optional)
- *
+ * </pre></code>
+ * </p>
* @param cfg Metro configuration information
* @throws ConfigurationException
*/
- public void configure(Configuration cfg)
- throws ConfigurationException
+ public void configure( Configuration cfg )
+ throws ConfigurationException
{
- //??? can this be called multiple times? If so, reset values
- // that aren't set
- try
+ try
{
Configuration hostcfg = cfg.getChild( "hostname" );
- if( null!=hostcfg )
- m_host = hostcfg.getValue( "localhost" );
+ // Niclas: If required, then don't supply a default.
+ // m_host = hostcfg.getValue( "localhost" );
+ m_host = hostcfg.getValue( "localhost" );

Configuration portcfg = cfg.getChild( "port" );
- if( null != portcfg )
- m_port = portcfg.getValueAsInteger( -1 );
+ m_port = portcfg.getValueAsInteger( -1 );

Configuration usercfg = cfg.getChild( "username" );
- if( null != usercfg)
- m_username = usercfg.getValue( "" );
+ m_username = usercfg.getValue();

Configuration passcfg = cfg.getChild( "password" );
- if( null != passcfg)
- m_password = passcfg.getValue( "" );
+ m_password = passcfg.getValue();

Configuration resourcecfg = cfg.getChild( "resource" );
- if( null != resourcecfg)
- m_resource= resourcecfg.getValue( "" );
+ m_resource= resourcecfg.getValue( "" );

Configuration securecfg = cfg.getChild( "secure" );
- if( null != securecfg)
- m_secure = securecfg.getValueAsBoolean( false );
+ m_secure = securecfg.getValueAsBoolean( false );

createXMPPConnection();
}
- catch (Exception ex)
+ catch (Exception ex)
{
throw new ConfigurationException("Error configuring
XMPPService.", cfg, ex);
}
@@ -125,19 +124,29 @@
public void createXMPPConnection()
throws XMPPException
{
- if( m_secure ) { //Use SSLXMPPConnection
+ if( m_secure ) //Use SSLXMPPConnection
+ {
if( -1 == m_port )
- m_connection = new SSLXMPPConnection(m_host);
+ {
+ m_connection = new SSLXMPPConnection( m_host );
+ }
else
- m_connection = new SSLXMPPConnection(m_host, m_port);
+ {
+ m_connection = new SSLXMPPConnection( m_host, m_port );
+ }
}
- else {
+ else
+ {
if( -1 == m_port)
+ {
m_connection = new XMPPConnection( m_host );
+ }
else
+ {
m_connection = new XMPPConnection( m_host, m_port );
+ }
}
-
+
}

//Startable implementation
@@ -149,13 +158,18 @@
public void start()
throws Exception
{
- if( ( null!=m_resource ) && ( !m_resource.equals("") ) )
+ if( m_resource.equals( "" ) == false )
+ {
m_connection.login( m_username, m_password, m_resource );
+ }
else
+ {
m_connection.login( m_username, m_password );
+ }

//??? should we have some sort of event that attempts to re-login
// on failure or on lost connections?
+ // Niclas: Stop followed by start() would provide that, right?
}

/**
@@ -177,9 +191,9 @@
* and can be used to send packets, register listeners for packets,
* and begin higher-level operations like begin a chat.
*
- * @return the Smack connection that allows jabber communication
+ * @return the Smack connection that allows jabber communication.
*/
- public XMPPConnection getConnection()
+ public XMPPConnection getConnection()
{
return m_connection;
}



  • svn commit: r2038 - in development/laboratory/planet/facilities/xmpp: api/src/main/net/dpml/planet/xmpp impl/src/main/net/dpml/planet/xmpp/impl, niclas, 03/11/2005

Archive powered by MHonArc 2.6.24.

Top of Page