com.sun.messaging

## Class AdminConnectionFactory

- java.lang.Object
- - com.sun.messaging.AdministeredObject
  - - com.sun.messaging.AdminConnectionFactory

All Implemented Interfaces:
  java.io.Serializable

    public class AdminConnectionFactory
    extends AdministeredObject

An `AdminConnectionFactory` is used by management clients to create JMX connections to the Message Queue broker. After establishing a connection successfully, a handle to a JMX Connector can be obtained which can then be used for management or monitoring operations.

The sample code below obtains a JMX Connector that communicates with the default RMI based connector on the broker that is running on the default host and port (localhost and port 7676). The administrator username and password used here is the default `admin` and `admin`.

         import javax.management.*;
         import javax.management.remote.*;
         import com.sun.messaging.AdminConnectionFactory;
         ...
         AdminConnectionFactory acf;

         acf = new AdminConnectionFactory();
         System.out.println("JMXServiceURL used: " + acf.getJMXServiceURL().toString());

         JMXConnector jmxc = acf.createConnection();

         // Proceed to manage/monitor the broker using the JMX Connector
         // obtained above.
         ...

The sample code below obtains a JMX Connector that communicates with the default RMI connector on the broker that is running on the host `myhost` on port 7979. The administrator username and password used here is `admin1` and `adminpasswd`.

         import javax.management.*;
         import javax.management.remote.*;
         import com.sun.messaging.AdminConnectionFactory;
         import com.sun.messaging.AdminConnectionConfiguration;
         ...
         AdminConnectionFactory acf;

         acf = new AdminConnectionFactory();
         acf.setProperty(AdminConnectionConfiguration.imqAddress,
                            "myhost:7979");
         System.out.println("JMXServiceURL used: " + acf.getJMXServiceURL().toString());

         JMXConnector jmxc = acf.createConnection("admin1", "adminpasswd");

         // Proceed to manage/monitor the broker using the JMX Connector
         // obtained above.
         ...

The sample code below obtains a JMX Connector that communicates with the RMI connector named ssljmxrmi on the broker that is running on the localhost and on port 7676. This is the JMX connector that is configured to use SSL. The administrator username and password used here is the default `admin` and `admin`.

         import javax.management.*;
         import javax.management.remote.*;
         import com.sun.messaging.AdminConnectionFactory;
         import com.sun.messaging.AdminConnectionConfiguration;
         ...
         AdminConnectionFactory acf;

         acf = new AdminConnectionFactory();
         acf.setProperty(AdminConnectionConfiguration.imqAddress,
                            "localhost:7676/ssljmxrmi");
         System.out.println("JMXServiceURL used: " + acf.getJMXServiceURL().toString());

         JMXConnector jmxc = acf.createConnection();

         // Proceed to manage/monitor the broker using the JMX Connector
         // obtained above.
         ...

See Also:
  `com.sun.messaging.AdminConnectionConfiguration`, Serialized Form

### Field Summary

### Fields inherited from class com.sun.messaging.AdministeredObject

`AO_PROPERTY_TYPE_BOOLEAN, AO_PROPERTY_TYPE_INTEGER, AO_PROPERTY_TYPE_LIST, AO_PROPERTY_TYPE_LONG, AO_PROPERTY_TYPE_PROPERTYOWNER, AO_PROPERTY_TYPE_STRING, cachedConfigurationMap, configuration, configurationLabels, configurationTypes, cr, storedVersion, VERSION`

### Constructor Summary

Constructors
`` `AdminConnectionFactory()` Constructs a AdminConnectionFactory with the default configuration.
`protected` `AdminConnectionFactory(java.lang.String defaultsBase)` Constructs a AdminConnectionFactory with the specified configuration.

### Method Summary

Methods
`javax.management.remote.JMXConnector` `createConnection()` Creates a Connection with the default user identity.
`javax.management.remote.JMXConnector` `createConnection(java.lang.String username, java.lang.String password)` Creates a Connection with a specified user identity.
`javax.management.remote.JMXServiceURL` `getJMXServiceURL()` Returns the relevant JMXServiceURL that is advertised by the portmapper.
`void` `setDefaultConfiguration()` Sets the minimum `AdminConnectionFactory` configuration defaults required to connect to the MQ Administration Service.
`java.lang.String` `toString()` Returns a pretty printed version of the provider specific information for this ConnectionFactory object.

### Methods inherited from class com.sun.messaging.AdministeredObject

`dump, enumeratePropertyNames, getConfiguration, getCurrentConfiguration, getLabelForGroup, getPropertiesForGroup, getProperty, getPropertyForListValue, getPropertyGroups, getPropertyLabel, getPropertyListOtherName, getPropertyListValues, getPropertyType, getPropertyValueForListValue, getStoredVersion, getVERSION, isPropertyDeprecated, isPropertyHidden, isReadOnly, isStoredVersionCompatible, setProperty, setReadOnly`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### AdminConnectionFactory

    public AdminConnectionFactory()

Constructs a AdminConnectionFactory with the default configuration.

#### AdminConnectionFactory

    protected AdminConnectionFactory(java.lang.String defaultsBase)

Constructs a AdminConnectionFactory with the specified configuration.

### Method Detail

#### createConnection

    public javax.management.remote.JMXConnector createConnection()
                                                          throws javax.management.JMException

Creates a Connection with the default user identity. The default user identity is defined by the `AdminConnectionFactory` properties `imqDefaultAdminUsername` and `imqDefaultAdminPassword`

Returns:
  a newly created Connection.
Throws:
  `javax.management.JMException` - if a JMS error occurs.
See Also:
  `AdminConnectionConfiguration.imqDefaultAdminUsername`, `AdminConnectionConfiguration.imqDefaultAdminPassword`

#### createConnection

    public javax.management.remote.JMXConnector createConnection(java.lang.String username,
                                                        java.lang.String password)
                                                          throws javax.management.JMException

Creates a Connection with a specified user identity.

Parameters:
  `username` - the caller's user name
  `password` - the caller's password
Returns:
  a newly created connection.
Throws:
  `javax.management.JMException` - if a JMX error occurs.

#### toString

    public java.lang.String toString()

Returns a pretty printed version of the provider specific information for this ConnectionFactory object.

Overrides:
  `toString` in class `AdministeredObject`
Returns:
  the pretty printed string.

#### getJMXServiceURL

    public javax.management.remote.JMXServiceURL getJMXServiceURL()
                                                           throws javax.management.JMException

Returns the relevant JMXServiceURL that is advertised by the portmapper. This url will be used in connection attempts.

Returns:
  The relevant JMXServiceURL that is advertised by the portmapper.
Throws:
  `javax.management.JMException`

#### setDefaultConfiguration

    public void setDefaultConfiguration()

Sets the minimum `AdminConnectionFactory` configuration defaults required to connect to the MQ Administration Service.

Specified by:
  `setDefaultConfiguration` in class `AdministeredObject`