IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Adapter Toolkit > Implementing code from the IBM WebSphere Adapter Toolkit > Enterprise metadata discovery general interfaces and implementation for application adapters > Enterprise metadata discovery implementation samples

WBIMetadataDiscoveryImpl sample

WBIMetadataDiscoveryImpl is the main entry class for invoking enterprise metadata discovery.

Interaction between the enterprise metadata discovery service and an EIS originates in an implementation of the WBIMetadataDiscoveryImpl class.

You must implement the methods described below.


Constructor

The constructor should call super(Bundle Name). The bundle name is the name of the resource bundle for property-group properties of the enterprise metadata discovery; for example: super("com.abc.j2c.testapp.emd"). When creating resource bundles the EMD.properties and LogMessages.properties should share the same package name.

public EISSAMetadataDiscovery() throws MetadataException {
		super("com.ibm.j2ca.eissa.emd");
		helper = new PropertyNameHelper(null, "com.ibm.j2ca.eissa.emd", null);
	}

The WBIAdapterTypeImpl constructor requires the following parameters:

  1. The name of the class representing the ResourceAdapter class.

    This is used to create property groups for ResourceAdapter in enterprise metadata discovery.

  2. Number of outbound connections
  3. Number of inbound connections


getAdapterTypeSummaries

Set supportedInMetadataService to true for connections that you want IBM Integration Designer to display when performing enterprise metadata discovery. Add the connections to adapterType using the add<Inbound/Outbound>ConnectionType() method:

	public AdapterTypeSummary[] getAdapterTypeSummaries() throws MetadataException {

		if (helper.getLogUtils().isTraceEnabled(Level.FINE))
			helper.getLogUtils().traceMethodEntrance("EISSAMetadataDiscovery", "getAdapterTypeSummaries");

		adapterType = new WBIAdapterTypeImpl
		("com.ibm.j2ca.eissa.EISSAResourceAdapter", 2, 1);
		adapterType.setDescription("VTA");
		adapterType.setDisplayName("VTA");
		adapterType.setId("VTA");
		adapterType.setVendor("IBM");
		adapterType.setVersion("6.1");

		EISSAOutboundConnectionType outConnTypeForMetadata
		= new EISSAOutboundConnectionType
(adapterType, helper);
		outConnTypeForMetadata.setIsSupportedInMetadataService(true);
		outConnTypeForMetadata.setIsSupportedAtRuntime(false);
		outConnTypeForMetadata.setManagedConnectionFactoryJavaBean
("com.ibm.j2ca.eissa.outbound.EISSAManagedConnectionFactory"); 
		outConnTypeForMetadata.setResourceAdapterJavaBean
("com.ibm.j2ca.eissa.EISSAResourceAdapter"); 
		adapterType.addOutboundConnectionType(outConnTypeForMetadata);

		EISSAOutboundConnectionType outConnTypeForRuntime = 
new EISSAOutboundConnectionType(adapterType, helper);
		outConnTypeForRuntime.setIsSupportedInMetadataService(false);
		outConnTypeForRuntime.setIsSupportedAtRuntime(true);
		outConnTypeForRuntime.setManagedConnectionFactoryJavaBean
("com.ibm.j2ca.eissa.outbound.EISSAManagedConnectionFactory"); 
		outConnTypeForRuntime.setResourceAdapterJavaBean
("com.ibm.j2ca.eissa.EISSAResourceAdapter"); 
		adapterType.addOutboundConnectionType(outConnTypeForRuntime);

		EISSAInboundConnectionType inConnTypeForRuntime = 
new EISSAInboundConnectionType(adapterType, helper);
		inConnTypeForRuntime.setResourceAdapterJavaBean
("com.ibm.j2ca.eissa.EISSAResourceAdapter"); 
		inConnTypeForRuntime.setActivationSpecJavaBean
("com.ibm.j2ca.eissa.inbound.EISSAActivationSpecWithXid"); 
		adapterType.addInboundConnectionType(inConnTypeForRuntime);

		return new WBIAdapterTypeImpl[] { adapterType };
	}


getAdapterType

This method returns the instance of adapterType for a given ID. If the enterprise metadata discovery implementation supports only one adapterType, then it returns either that ID or the input ID.


getMetadatatree

This method returns an instance of the WBIMetadataTreeImpl implementation. Each enterprise metadata discovery implementation extends the WBIMetadataTreeImpl class and an instance of that class is returned from this method.

public MetadataTree getMetadataTree(MetadataConnection conn)
throws MetadataException {

		this.connection = (WBIMetadataConnectionImpl) conn;
		connType = (WBIOutboundConnectionTypeImpl)
		connection.getConnectionType();

		EISSAMetadataTree tree = 
		new EISSAMetadataTree(connection, helper);
		tree.setSelectionStyle(MetadataTree.MULTI_SELECT);

		return tree;
	}


createServiceDescription

This class returns an instance of the inbound or outbound service description, depending on which input selection is set.

You might usefully iterate through import configurations in the MetadataSelection set and then use the properties specified on MetadataSelection to complete the service description.

The instance of ServiceDescription created should be filled in with name, namespace, function description and configurations as shown below. The method copyPropertyValues(), defined on connection configurations, copies the properties that match between the connection configuration that was used to perform discovery and the one that used for run time. The copy is based on names.

For example, if a property name Username exists in the configuration used for discovery and that used for run time, the Username value is copied.

public ServiceDescription createServiceDescription
        (MetadataSelection importSelection) throws MetadataException {
        ServiceDescription description = null;
        WBIMetadataSelectionImpl selection = (WBIMetadataSelectionImpl) 
                               importSelection;
        MetadataImportConfiguration[] confArray = selection.getSelection();
        if (confArray.length == 0)
            return description;
        super.getLogUtils().trace(Level.FINER, 
	                          CLASSNAME, "createServiceDescription()", 
				  "Number of MetadataImportConfigurations " + confArray.length);
        PropertyGroup serviceType = 
			 selection.getAppliedSelectionProperties();
        String directionality = getDirectionality(serviceType);
        String nameSpace = getNameSpace(serviceType);
        boolean inbound = false;
        if (directionality.equals("Inbound")) {
            super.getLogUtils().trace(Level.FINER, CLASSNAME, 
	                              "createServiceDescription()", 
				      "Selected Service Type is:Inbound");
            inbound = true;
        }         if (inbound) {
            description = createInboundServiceDescription
                   (importSelection, selection, nameSpace);
        } else {
            description = createOutboundServiceDescription
                   (importSelection, selection, nameSpace);
        }         return description;
    } 


setToolContext

To implement setToolContext(), initialize the LogUtils instance and set it on the Foundation Class WBIMetadataDiscoveryImpl.

public void setToolContext(ToolContext toolContext) {
	super.setToolContext(toolContext);
		try {
			AdapterType adapterType = 
new WBIAdapterTypeImpl("com.ibm.j2ca.eissa.EISSAResourceAdapter",  2, 1);LogUtils logUtils = 
new LogUtils(toolContext.getLogger(), "com.ibm.j2ca.eissa.emd",  adapterType.getId(), adapterType.getVersion());
			LogRecord record = 
new LogRecord(Level.FINEST, "Entering setToolContext");
			toolContext.getLogger().log(record);
			helper.setLogUtils(logUtils);
			helper.setToolContext(toolContext);
			super.setLogUtils(logUtils);
		} catch (Exception e) {
			throw new RuntimeException(e.getMessage());
		} 
	}

Enterprise metadata discovery implementation samples