|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.util.connection.ConnectionFactoryBean
public class ConnectionFactoryBean
The ConnectionFactoryBean class is a Java bean which wraps ConnectionFactory classes in the com.sas.services.connection package. It is a wrapper which provides for an easier way to create and use a ConnectionFactory, but it is tailored for use with a customizer, the webAF IDE and accompanying BeanStateInfo.
The bean allows for a more straightforward way to define the complex sets of properties used in the construction of a factory. Once the factory has been created, connections (workspaces) can be requested from it through the requestWorkspace() method. These workspaces are wrapped in a WorkspaceBean class which provides a way for a workspace to be manipulated in an IDE.
The original design for this bean included the element of having the webAF IDE authomatically generate the configuration code for you when you drop the bean in your project and customize it. However, you can use this class and code similar to that shown below in your own application if desired. Note that in such a case, it may be more desireable to use the ConnectionFactory API directly, rather than going through this bean in a manual fashion. The following code illustrates the procedure for configuring and using the bean:
// Create the ConnectionFactory bean connectionFactoryBean1 = new com.sas.util.connection.ConnectionFactoryBean( ); // Set the type of configuration to com.sas.util.connection.ConnectionFactoryBean.CONFIG_TYPE_MANUAL connectionFactoryBean1.setConfigType( 0 ); // Set the type of server to com.sas.services.connection.BridgeServer.CLSID_SAS connectionFactoryBean1.setServerType( "440196d4-90f0-11d0-9f41-00a024bb830c" ); connectionFactoryBean1.setWaitTimeOnBusyFactory( -1 ); connectionFactoryBean1.setInitialWorkspaceCount( 0 ); // Identify the user credentials to use when requesting workspaces via the // requestWorkspace() method. connectionFactoryBean1.setRequestUsername( "userUsername" ); connectionFactoryBean1.setRequestPassword( "userPassword" ); // Add a factory account and set associated properties connectionFactoryBean1.addPuddleLogin( "factoryUsername", "factoryPassword" ); connectionFactoryBean1.setEncryption( "none",null,null ); connectionFactoryBean1.setPoolMinSize( -1 ); connectionFactoryBean1.setPoolMinAvail( -1 ); connectionFactoryBean1.setClusterType( 1 ); connectionFactoryBean1.addServer( "localhost",5310,10,0,-1 ); // Add a user with the specified credentials. connectionFactoryBean1.addUser( "userUsername","userPassword" ); // Get a workspace bean from the ConnectionFactory com.sas.util.connection.WorkspaceBean workspaceBean1 = connectionFactoryBean1.requestWorkspace();
Nested Class Summary | |
---|---|
protected class |
ConnectionFactoryBean.BeanPuddle
The internal BeanPuddle class holds the set of properties for a puddle. |
Field Summary | |
---|---|
protected com.sas.services.information.metadata.LogicalServerInterface |
bipServer
A handle to a BIP server for use when configType is set to CONFIG_TYPE_PLATFORM |
static int |
CONFIG_TYPE_MANUAL
Defines a ConnectionFactory configuration that is defined manually by the user |
static int |
CONFIG_TYPE_PLATFORM
Defines a ConnectionFactory configuration that is defined in a BI Platform repository |
protected int |
configType
The currently assigned configuration type |
protected boolean |
designTime
A flag representing whether or not this object is in design-time mode in the webAF IDE |
protected com.sas.services.connection.ConnectionFactoryInterface |
factory
The actual factory itself |
protected com.sas.services.connection.ConnectionFactoryAdminInterface |
factoryAdmin
An admin interface on the factory |
protected com.sas.services.connection.ConnectionFactoryConfiguration |
factoryConfig
The factory configuration |
protected int |
initialWorkspaceCount
The number of workspaces to obtain when the bean is instantiated at run-time |
protected ConnectionFactoryBean.BeanPuddle |
puddle
An internal BeanPuddle object that represents the current puddle as a user is configuring the bean |
protected java.util.Vector |
puddles
The set of all puddles for the factory |
static java.lang.String |
RB_KEY
|
protected java.lang.String |
requestPassword
The password to use when requesting workspaces via the requestWorkspace method |
protected java.lang.String |
requestUsername
The username to use when requesting workspaces via the requestWorkspace method |
protected java.lang.String |
serverType
The type of server for which this factory will provide connections |
protected int |
waitTimeOnBusyFactory
The time to wait (in milliseconds) for a connection when the factory has been maxed-out |
protected java.util.Vector |
workspaceBeans
The set of all workspace beans generated by the factory |
Constructor Summary | |
---|---|
ConnectionFactoryBean()
Default constructor. |
Method Summary | |
---|---|
void |
addPuddleLogin(com.sas.services.connection.PasswordCredential login)
Adds a login to a puddle for use by the factory. |
void |
addPuddleLogin(java.lang.String username,
java.lang.String password)
Adds a login to a puddle for use by the factory. |
void |
addServer(java.lang.String hostname,
int port)
Associates a server with the current puddle login in the bean. |
void |
addServer(java.lang.String hostname,
int port,
int maxClients,
int reactivationLimit,
int shutdownAfterMinutes)
Associates a server with the current puddle login in the bean. |
void |
addServer(java.lang.String hostname,
int port,
int maxClients,
int reactivationLimit,
int shutdownAfterMinutes,
java.lang.String serverName)
Associates a server with the current puddle login in the bean. |
void |
addUser(java.lang.String username,
java.lang.String password)
Associates a user login with the current puddle in the bean. |
void |
addWorkspaceBean(WorkspaceBean workspaceBean)
Adds a workspace bean to this bean. |
void |
clearPuddleLogins()
Removes any puddle logins that may have been previously defined for the factory. |
protected java.lang.String |
DecodePassword(java.lang.String password)
Decodes the specified password. |
protected java.lang.String |
EncodePassword(java.lang.String password)
Encodes the specified password. |
int |
getClusterType(int puddle)
Returns the type of clustering behavior defined for the specified puddle. |
int |
getConfigType()
Returns the type of configuration defined for this factory. |
java.lang.String |
getEncryptionAlgorithms(int puddle)
Returns the encryption algorithms for the specified puddle. |
java.lang.String |
getEncryptionContent(int puddle)
Returns the encryption content for the specified puddle. |
java.lang.String |
getEncryptionPolicy(int puddle)
Returns the encryption policy for the specified puddle. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to
augment the automatically introspected information about this ConnectionFactoryBean. |
protected void |
getFactory()
Creates a set of puddles from the defined logins and servers and and then gets a ConnectionFactory. |
int |
getInitialWorkspaceCount()
Returns the number of initial workspace beans to add to the IDE project. |
java.util.logging.Logger |
getLogger()
Returns an instance of java.util.logging.Logger which can be used to view detailed information about the underlying ConnectionFactory. |
int |
getPoolMinAvail(int puddle)
Returns the minimum number of idle connections for the specified puddle that the factory must maintain at all times. |
int |
getPoolMinSize(int puddle)
Returns the minimum number of connections (idle or in-use) for the specified puddle that the factory must maintain at all times. |
com.sas.services.connection.PasswordCredential[] |
getPuddleLogins()
Returns the set of PasswordCredential objects defined in the bean via the addPuddleLogin method. |
com.sas.services.connection.Puddle[] |
getPuddles()
Returns the set of all puddles defined for the factory. |
java.lang.String |
getRequestPassword()
Returns the password used when requesting workspaces via the requestWorkspace method. |
java.lang.String |
getRequestUsername()
Returns the username used when requesting workspaces via the requestWorkspace method. |
java.util.Vector |
getServers(com.sas.services.connection.PasswordCredential login)
Returns the set of servers associated with a given puddle login. |
java.lang.String |
getServerType()
Returns the type of SAS server that this factory will provide. |
java.util.Vector |
getUsers(com.sas.services.connection.PasswordCredential login)
Returns the set of users associated with a given puddle login. |
int |
getWaitTimeOnBusyFactory()
Gets the amount of time to wait, in milliseconds, for a connection when a request is made to the factory but all available connections are currently in use. |
java.util.Vector |
getWorkspaceBeans()
Returns the set of workspace beans associated with this bean. |
com.sas.services.connection.ConnectionInterface |
requestConnection()
Obtains a connection from the ConnectionFactory, which can then be used to obtain an IOM workspace and return it back to the factory. |
WorkspaceBean |
requestWorkspace()
Obtains an IOM workspace from the ConnectionFactory, stored in a wrapper bean. |
WorkspaceBean |
requestWorkspace(com.sas.services.connection.ConnectionInterface connection)
Obtains an IOM workspace from the ConnectionFactory, stored in a wrapper bean. |
void |
resetFactory()
Resets a failed factory that may have suffered a fatal error. |
void |
setClusterType(int type)
Sets the type of clustering behavior to be used for the current puddle. |
void |
setClusterType(int puddleIx,
int type)
Sets the type of clustering behavior to be used for the current puddle. |
void |
setConfigDataBIP(com.sas.services.information.metadata.LogicalServerInterface bipServer)
Sets the BI Platform-specific data for a factory configured to use the platform. |
void |
setConfigType(int configType)
Sets the type of configuration to be used for this factory. |
void |
setDesignTime(boolean value)
Sets whether or not the bean is in design-time mode. |
void |
setEncryption(int puddle,
java.lang.String policy,
java.lang.String content,
java.lang.String algorithms)
Sets the type of data encryption to be used in communications for the current puddle. |
void |
setEncryption(java.lang.String policy,
java.lang.String content,
java.lang.String algorithms)
Sets the type of data encryption to be used in communications for the current puddle. |
void |
setInitialWorkspaceCount(int value)
Sets the number of initial workspace beans to add to the IDE project. |
void |
setPoolMinAvail(int value)
Sets the minimum number of idle connections for the current puddle that the factory must maintain at all times. |
void |
setPoolMinAvail(int puddle,
int value)
Sets the minimum number of idle connections for the current puddle that the factory must maintain at all times. |
void |
setPoolMinSize(int size)
Sets the minimum number of connections (idle or in-use) for the current puddle that the factory must maintain at all times. |
void |
setPoolMinSize(int puddle,
int size)
Sets the minimum number of connections (idle or in-use) for the current puddle that the factory must maintain at all times. |
void |
setRequestPassword(java.lang.String password)
The password to use when requesting workspaces via the requestWorkspace method. |
void |
setRequestUsername(java.lang.String username)
The username to use when requesting workspaces via the requestWorkspace method. |
void |
setServerType(java.lang.String serverType)
Sets the type of SAS server that this factory will provide. |
void |
setWaitTimeOnBusyFactory(int waitTimeOnFullFactory)
Sets the amount of time to wait, in milliseconds, for a connection when a request is made to the factory but all available connections are currently in use. |
Field Detail |
---|
public static java.lang.String RB_KEY
protected boolean designTime
public static int CONFIG_TYPE_MANUAL
public static int CONFIG_TYPE_PLATFORM
protected int configType
protected com.sas.services.information.metadata.LogicalServerInterface bipServer
protected java.lang.String serverType
protected int waitTimeOnBusyFactory
protected int initialWorkspaceCount
protected java.lang.String requestUsername
protected java.lang.String requestPassword
protected ConnectionFactoryBean.BeanPuddle puddle
protected java.util.Vector puddles
protected java.util.Vector workspaceBeans
protected com.sas.services.connection.ConnectionFactoryConfiguration factoryConfig
protected com.sas.services.connection.ConnectionFactoryInterface factory
protected com.sas.services.connection.ConnectionFactoryAdminInterface factoryAdmin
Constructor Detail |
---|
public ConnectionFactoryBean()
Method Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
com.sas.beans.Introspector
to
augment the automatically introspected information about this ConnectionFactoryBean.
public void setDesignTime(boolean value)
value
- The boolean value to set.public int getConfigType()
setConfigType(int)
public void setConfigType(int configType)
configType
- The type of configuration for the factory. Valid values are:
com.sas.util.connection.ConnectionFactoryBean.CONFIG_TYPE_MANUAL (default)
com.sas.util.connection.ConnectionFactoryBean.CONFIG_TYPE_PLATFORMgetConfigType()
public void setConfigDataBIP(com.sas.services.information.metadata.LogicalServerInterface bipServer)
bipServer
- An encapsulation of information about a server or group of servers in a BIP metadata repository.public java.lang.String getServerType()
setServerType(String)
public void setServerType(java.lang.String serverType)
serverType
- The type of server.getServerType()
public int getWaitTimeOnBusyFactory()
setWaitTimeOnBusyFactory(int)
public void setWaitTimeOnBusyFactory(int waitTimeOnFullFactory)
waitTimeOnFullFactory
- The amount of time to wait.getWaitTimeOnBusyFactory()
public int getInitialWorkspaceCount()
setInitialWorkspaceCount(int)
public void setInitialWorkspaceCount(int value)
value
- The number of initial workspace beans to add to the IDE project.getInitialWorkspaceCount()
public void setRequestUsername(java.lang.String username)
username
- The username value.public java.lang.String getRequestUsername()
setRequestUsername(String)
public void setRequestPassword(java.lang.String password)
password
- The password value. This string may be encoded if desired.public java.lang.String getRequestPassword()
setRequestUsername(String)
public com.sas.services.connection.PasswordCredential[] getPuddleLogins()
addPuddleLogin(PasswordCredential)
public void addPuddleLogin(com.sas.services.connection.PasswordCredential login)
username
- The username required to access a set of servers.password
- The password required to access a set of servers.addServer(String, int)
,
addServer(String, int, int, int, int)
public void addPuddleLogin(java.lang.String username, java.lang.String password)
username
- The username required to access a set of servers.password
- The password required to access a set of servers. This string may be
encoded if desired.addServer(String, int)
,
addServer(String, int, int, int, int)
public void clearPuddleLogins()
addPuddleLogin(PasswordCredential)
,
addPuddleLogin(String, String)
public com.sas.services.connection.Puddle[] getPuddles()
public java.lang.String getEncryptionPolicy(int puddle)
puddle
- The index of the puddle of interest.
setEncryption(String, String, String)
public java.lang.String getEncryptionContent(int puddle)
puddle
- The index of the puddle of interest.
setEncryption(String, String, String)
public java.lang.String getEncryptionAlgorithms(int puddle)
puddle
- The index of the puddle of interest.
setEncryption(String, String, String)
public void setEncryption(java.lang.String policy, java.lang.String content, java.lang.String algorithms)
policy
- Valid values are as follows:
none - no communication with the server will be encrypted. If the server requires encryption, the connection will fail. This is the default value. If this is the value of this attribute, then the values for encryptionContent and encryptionAlgorithms will be ignored.
optional - communication with the server will be encrypted if the server supports an encryption algorithm supported by the client. Otherwise no communication with the server will be encrypted.
required - communication with the server will be encrypted if the server supports an encryption algorithm supported by the client. Otherwise the connection will fail.content
- Valid values are as follows:
all - all communication is encrypted. This is the default.
authentication - only user name and password information is encrypted.algorithms
- Valid values are sasproprietary, rc2, rc4, des, and tripledes.public void setEncryption(int puddle, java.lang.String policy, java.lang.String content, java.lang.String algorithms)
puddle
- The index of the puddle of interest.policy
- Valid values are as follows:
none - no communication with the server will be encrypted. If the server requires encryption, the connection will fail. This is the default value. If this is the value of this attribute, then the values for encryptionContent and encryptionAlgorithms will be ignored.
optional - communication with the server will be encrypted if the server supports an encryption algorithm supported by the client. Otherwise no communication with the server will be encrypted.
required - communication with the server will be encrypted if the server supports an encryption algorithm supported by the client. Otherwise the connection will fail.content
- Valid values are as follows:
all - all communication is encrypted. This is the default.
authentication - only user name and password information is encrypted.algorithms
- Valid values are sasproprietary, rc2, rc4, des, and tripledes.public int getClusterType(int puddle)
puddle
- The index of the puddle of interest.
Cluster
public void setClusterType(int type)
type
- The type of cluster to use. Valid values are as follows:
com.sas.services.connection.Cluster.TYPE_FAILOVER
com.sas.services.connection.Cluster.TYPE_LOAD_BALANCINGCluster
public void setClusterType(int puddleIx, int type)
puddle
- The index of the puddle of interest.type
- The type of cluster to use. Valid values are as follows:
com.sas.services.connection.Cluster.TYPE_FAILOVER
com.sas.services.connection.Cluster.TYPE_LOAD_BALANCINGCluster
public java.util.Vector getServers(com.sas.services.connection.PasswordCredential login)
login
- The PasswordCredential added to the bean via the addLogin method.
public void addServer(java.lang.String hostname, int port)
hostname
- The hostname of the server.port
- The port number of the server.addServer(String, int, int, int, int)
public void addServer(java.lang.String hostname, int port, int maxClients, int reactivationLimit, int shutdownAfterMinutes)
hostname
- The hostname of the server.port
- The port number of the server.maxClients
- The maximum number of clients allowed to use this server.reactivationLimit
- The maximum number of clients that will be allowed to use the connection before it is destroyed (and reconnected if necessary). The value must be greater than or equal to 0. If it is equal to 0, then any number of clients will allowed to use the connection before it is destroyed.shutdownAfterMinutes
- The number of minutes the connection will be allowed to exist with no clients before it is destroyed. -1 means the connection will be allowed to exist with no clients until connection factory shutdown.public void addServer(java.lang.String hostname, int port, int maxClients, int reactivationLimit, int shutdownAfterMinutes, java.lang.String serverName)
hostname
- The hostname of the server.port
- The port number of the server.maxClients
- The maximum number of clients allowed to use this server.reactivationLimit
- The maximum number of clients that will be allowed to use the connection before it is destroyed (and reconnected if necessary). The value must be greater than or equal to 0. If it is equal to 0, then any number of clients will allowed to use the connection before it is destroyed.shutdownAfterMinutes
- The number of minutes the connection will be allowed to exist with no clients before it is destroyed. -1 means the connection will be allowed to exist with no clients until connection factory shutdown.serverName
- Specifies the serverName to use when multiple servers are availablepublic java.util.Vector getUsers(com.sas.services.connection.PasswordCredential login)
login
- The PasswordCredential added to the bean via the addLogin method.
public void addUser(java.lang.String username, java.lang.String password)
username
- The username of the user to add.password
- The password of the user to add. This string may be encoded if desired.public java.util.Vector getWorkspaceBeans()
public void addWorkspaceBean(WorkspaceBean workspaceBean)
workspaceBean
- The workspace bean to add.public com.sas.services.connection.ConnectionInterface requestConnection() throws com.sas.services.connection.ConnectionFactoryException
com.sas.services.connection.ConnectionFactoryException
public WorkspaceBean requestWorkspace(com.sas.services.connection.ConnectionInterface connection) throws com.sas.services.connection.ConnectionFactoryException
connection
- The connection obtained from the requestConnection() method call.
com.sas.services.connection.ConnectionFactoryException
public WorkspaceBean requestWorkspace() throws com.sas.services.connection.ConnectionFactoryException
This is a convenience method which is equivalent to the following:
ConnectionInterface connection = requestConnection(); return requestWorkspace(connection);
com.sas.services.connection.ConnectionFactoryException
public int getPoolMinSize(int puddle)
puddle
- The index of the puddle of interest.
setPoolMinSize(int)
public void setPoolMinSize(int size)
size
- The minimum number of connections.getPoolMinSize(int)
public void setPoolMinSize(int puddle, int size)
puddle
- The index of the puddle of interest.size
- The minimum number of connections.getPoolMinSize(int)
public int getPoolMinAvail(int puddle)
puddle
- The index of the puddle of interest.
setPoolMinAvail(int)
public void setPoolMinAvail(int value)
value
- The minimum number of idle connections.getPoolMinAvail(int)
public void setPoolMinAvail(int puddle, int value)
puddle
- The index of the puddle of interest.value
- The minimum number of idle connections.getPoolMinAvail(int)
public java.util.logging.Logger getLogger() throws com.sas.services.connection.ConnectionFactoryException
com.sas.services.connection.ConnectionFactoryException
public void resetFactory()
protected void getFactory() throws com.sas.services.connection.ConnectionFactoryException
com.sas.services.connection.ConnectionFactoryException
protected java.lang.String EncodePassword(java.lang.String password)
password
- The password to encode.
protected java.lang.String DecodePassword(java.lang.String password)
password
- The password to decode.
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |