// Aim - Query the connector to determine what connection properties it // requires and what are the metadata of the respective properties. // The Workflow // - Get the connection factory (see above). // - Get a connection spec. // - Get the metadata for the connection spec // From the outside: IConnectionSpecMetaData connectionSpecMetaData = cs.getMetaData(); Set connectionPropertiesNames = csmd.retrieveAllConnectionPropertiesNames(); Iterator iter = connectionPropertiesNames.iterator(); while (iter.hasNext()) { // Save the name. IConnectionProperty currentProperty = connectionSpecMetaData.getConnectionProperty((String) iter.next()); Boolean isMandatory currentProperty.isMandatory() Object defaultValue = currentProperty.defaultValue(); // Etc… } // From the inside: // Here is a possible implementation for a certain connection // property interface. Its structure: public IPrimitive getMetadata() { return m_metadata; } // Whether it is a user level or a system level property: // - Things like serve name, port, system id, etc. are system // level properties. // - Things like user name, password, language, etc are user // level properties. public String getType() { return m_type; // This is a possible implementation for connection spec metadata // interface. public class JDBCConnectionSpecMetaData implements IConnectionSpecMetaData { public JDBCConnectionSpecMetaData() { } private static Map m_allProperties; static { m_allProperties = new HashMap(); IString metadata = new StringPrimitive(-1, -1, ""); m_allProperties.put( "username", new JDBCConnectionProperty( metadata, IConnectionProperty.CONNECTION_PROPERTY_TYPE_USER, false)); m_allProperties.put( "password", new JDBCConnectionProperty( metadata, IConnectionProperty.CONNECTION_PROPERTY_TYPE_USER, false)); m_allProperties.put( "url", new JDBCConnectionProperty( metadata, IConnectionProperty.CONNECTION_PROPERTY_TYPE_SYSTEM, false)); } // To return all the possible connection properties. public Set getAllConnectionProperties() { return new HashMap(m_allProperties).entrySet(); } // To return a set of all possible connection property names. public Set retrieveAllConnectionPropertiesNames() { return new HashMap(m_allProperties).keySet(); } public IConnectionProperty getConnectionProperty(String propertyName) { return (IConnectionProperty) m_allProperties.get(propertyName); } } } // Some properties only accept a predefined set of values. public Set getValidValues() { return null; } // To return whether or not the property is mandatory. public boolean getIsMandatory() { return false; } // To return a default value for this connection property, if any. public Object getDefaultValue() { return null; }