public class BasicConnectionFactory extends AdministeredObject implements ConnectionFactory
BasicConnectionFactory
encapsulates Sun MQ specific configuration information
for Sun MQ ConnectionFactory
objects and is used to create Connections with
a Sun MQ Java Message Service (JMS) provider.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
Modifier | Constructor and Description |
---|---|
|
BasicConnectionFactory()
Constructs a BasicConnectionFactory with the default configuration.
|
protected |
BasicConnectionFactory(String defaultsBase)
Constructs a BasicConnectionFactory with the specified configuration.
|
Modifier and Type | Method and Description |
---|---|
Connection |
createConnection()
Creates a Connection with the default user identity.
|
Connection |
createConnection(String username,
String password)
Creates a Connection with a specified user identity.
|
JMSContext |
createContext()
Creates a JMSContext with the default user identity
and an unspecified sessionMode.
|
JMSContext |
createContext(int sessionMode)
Creates a JMSContext with the default user identity
and the specified session mode.
|
JMSContext |
createContext(String userName,
String password)
Creates a JMSContext with the specified user identity
and an unspecified sessionMode.
|
JMSContext |
createContext(String userName,
String password,
int sessionMode)
Creates a JMSContext with the specified user identity
and the specified session mode.
|
String |
getConnectionType()
Returns the type of connections created by this
BasicConnectionFactory . |
protected static com.sun.messaging.jmq.jmsclient.ContainerType |
getContainerType() |
void |
setConnectionType(String type)
Sets the type of connections created by this
BasicConnectionFactory . |
void |
setDefaultConfiguration()
Sets the minimum
BasicConnectionFactory configuration defaults
required to connect to the Sun MQ Message Service. |
String |
toString()
Returns a pretty printed version of the provider specific
information for this ConnectionFactory object.
|
dump, enumeratePropertyNames, getConfiguration, getCurrentConfiguration, getLabelForGroup, getPropertiesForGroup, getProperty, getPropertyForListValue, getPropertyGroups, getPropertyLabel, getPropertyListOtherName, getPropertyListValues, getPropertyType, getPropertyValueForListValue, getStoredVersion, getVERSION, isPropertyDeprecated, isPropertyHidden, isReadOnly, isStoredVersionCompatible, setProperty, setReadOnly
public BasicConnectionFactory()
protected BasicConnectionFactory(String defaultsBase)
public Connection createConnection() throws JMSException
ConnectionFactory
properties
imqDefaultUsername
and imqDefaultPassword
createConnection
in interface ConnectionFactory
JMSException
- if a JMS error occurs.ConnectionConfiguration.imqDefaultUsername
,
ConnectionConfiguration.imqDefaultPassword
public Connection createConnection(String username, String password) throws JMSException
createConnection
in interface ConnectionFactory
username
- the caller's user namepassword
- the caller's passwordJMSException
- if a JMS error occurs.public JMSContext createContext()
ConnectionFactory
A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer is created.
The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress.
In a Java SE environment or in the Java EE application client container:
JMSContext.AUTO_ACKNOWLEDGE
For a definition of the meaning of this acknowledgement mode see the link below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
JMSContext
's commit
or rollback
methods.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
JMSContext.AUTO_ACKNOWLEDGE
For a definition of the meaning of this acknowledgement mode see the link below.
createContext
in interface ConnectionFactory
JMSContext.AUTO_ACKNOWLEDGE
,
ConnectionFactory.createContext(int)
,
ConnectionFactory.createContext(java.lang.String, java.lang.String)
,
ConnectionFactory.createContext(java.lang.String, java.lang.String, int)
,
JMSContext.createContext(int)
public JMSContext createContext(String userName, String password)
ConnectionFactory
A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer.
The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress.
In a Java SE environment or in the Java EE application client container:
JMSContext.AUTO_ACKNOWLEDGE
For a definition of the meaning of this acknowledgement mode see the link below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
JMSContext
's commit
or rollback
methods.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
JMSContext.AUTO_ACKNOWLEDGE
For a definition of the meaning of this acknowledgement mode see the link below.
createContext
in interface ConnectionFactory
userName
- the caller's user namepassword
- the caller's passwordJMSContext.AUTO_ACKNOWLEDGE
,
ConnectionFactory.createContext()
,
ConnectionFactory.createContext(int)
,
ConnectionFactory.createContext(java.lang.String, java.lang.String, int)
,
JMSContext.createContext(int)
public JMSContext createContext(String userName, String password, int sessionMode)
ConnectionFactory
A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the sessionMode
argument depends on whether this method is called in a Java SE environment,
in the Java EE application client container, or in the Java EE web or EJB container.
If this method is called in the Java EE web or EJB container then the
effect of setting the sessionMode
argument also depends on
whether or not there is an active JTA transaction in progress.
In a Java SE environment or in the Java EE application client container:
sessionMode
is set to JMSContext.SESSION_TRANSACTED
then the session
will use a local transaction which may subsequently be committed or rolled back
by calling the JMSContext
's commit
or rollback
methods.
sessionMode
is set to any of
JMSContext.CLIENT_ACKNOWLEDGE
,
JMSContext.AUTO_ACKNOWLEDGE
or
JMSContext.DUPS_OK_ACKNOWLEDGE
.
then the session will be non-transacted and
messages received by this session will be acknowledged
according to the value of sessionMode
.
For a definition of the meaning of these acknowledgement modes see the links below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
sessionMode
is ignored.
The session will participate in the JTA transaction and will be committed or rolled back
when that transaction is committed or rolled back,
not by calling the JMSContext
's commit
or rollback
methods.
Since the argument is ignored, developers are recommended to use
createSession()
, which has no arguments, instead of this method.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
acknowledgeMode
must be set to either of
JMSContext.AUTO_ACKNOWLEDGE
or
JMSContext.DUPS_OK_ACKNOWLEDGE
.
The session will be non-transacted and messages received by this session will be acknowledged
automatically according to the value of acknowledgeMode
.
For a definition of the meaning of these acknowledgement modes see the links below.
The values JMSContext.SESSION_TRANSACTED
and JMSContext.CLIENT_ACKNOWLEDGE
may not be used.
createContext
in interface ConnectionFactory
userName
- the caller's user namepassword
- the caller's passwordsessionMode
- indicates which of four possible session modes will be used.
JMSContext.SESSION_TRANSACTED
,
JMSContext.CLIENT_ACKNOWLEDGE
,
JMSContext.AUTO_ACKNOWLEDGE
and
JMSContext.DUPS_OK_ACKNOWLEDGE
.
JMSContext.AUTO_ACKNOWLEDGE
and
JMSContext.DUPS_OK_ACKNOWLEDGE
.
In this case the values JMSContext.TRANSACTED
and JMSContext.CLIENT_ACKNOWLEDGE
are not permitted.
JMSContext.SESSION_TRANSACTED
,
JMSContext.CLIENT_ACKNOWLEDGE
,
JMSContext.AUTO_ACKNOWLEDGE
,
JMSContext.DUPS_OK_ACKNOWLEDGE
,
ConnectionFactory.createContext()
,
ConnectionFactory.createContext(int)
,
ConnectionFactory.createContext(java.lang.String, java.lang.String)
,
JMSContext.createContext(int)
public JMSContext createContext(int sessionMode)
ConnectionFactory
A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the sessionMode
argument depends on whether this method is called in a Java SE environment,
in the Java EE application client container, or in the Java EE web or EJB container.
If this method is called in the Java EE web or EJB container then the
effect of setting the sessionMode
argument also depends on
whether or not there is an active JTA transaction in progress.
In a Java SE environment or in the Java EE application client container:
sessionMode
is set to JMSContext.SESSION_TRANSACTED
then the session
will use a local transaction which may subsequently be committed or rolled back
by calling the JMSContext
's commit
or rollback
methods.
sessionMode
is set to any of
JMSContext.CLIENT_ACKNOWLEDGE
,
JMSContext.AUTO_ACKNOWLEDGE
or
JMSContext.DUPS_OK_ACKNOWLEDGE
.
then the session will be non-transacted and
messages received by this session will be acknowledged
according to the value of sessionMode
.
For a definition of the meaning of these acknowledgement modes see the links below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
sessionMode
is ignored.
The session will participate in the JTA transaction and will be committed or rolled back
when that transaction is committed or rolled back,
not by calling the JMSContext
's commit
or rollback
methods.
Since the argument is ignored, developers are recommended to use
createSession()
, which has no arguments, instead of this method.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
acknowledgeMode
must be set to either of
JMSContext.AUTO_ACKNOWLEDGE
or
JMSContext.DUPS_OK_ACKNOWLEDGE
.
The session will be non-transacted and messages received by this session will be acknowledged
automatically according to the value of acknowledgeMode
.
For a definition of the meaning of these acknowledgement modes see the links below.
The values JMSContext.SESSION_TRANSACTED
and JMSContext.CLIENT_ACKNOWLEDGE
may not be used.
createContext
in interface ConnectionFactory
sessionMode
- indicates which of four possible session modes will be used.
JMSContext.SESSION_TRANSACTED
,
JMSContext.CLIENT_ACKNOWLEDGE
,
JMSContext.AUTO_ACKNOWLEDGE
and
JMSContext.DUPS_OK_ACKNOWLEDGE
.
JMSContext.AUTO_ACKNOWLEDGE
and
JMSContext.DUPS_OK_ACKNOWLEDGE
.
In this case the values JMSContext.TRANSACTED
and JMSContext.CLIENT_ACKNOWLEDGE
are not permitted.
JMSContext.SESSION_TRANSACTED
,
JMSContext.CLIENT_ACKNOWLEDGE
,
JMSContext.AUTO_ACKNOWLEDGE
,
JMSContext.DUPS_OK_ACKNOWLEDGE
,
ConnectionFactory.createContext()
,
ConnectionFactory.createContext(java.lang.String, java.lang.String)
,
ConnectionFactory.createContext(java.lang.String, java.lang.String, int)
,
JMSContext.createContext(int)
protected static com.sun.messaging.jmq.jmsclient.ContainerType getContainerType()
public final void setConnectionType(String type)
BasicConnectionFactory
.type
- The type of connections created by this
BasicConnectionFactory
.public final String getConnectionType()
BasicConnectionFactory
.BasicConnectionFactory
.public String toString()
toString
in class AdministeredObject
public void setDefaultConfiguration()
BasicConnectionFactory
configuration defaults
required to connect to the Sun MQ Message Service.setDefaultConfiguration
in class AdministeredObject
Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.