Declaring the Capabilities of the Java code (Java Integration stage in DataStage)
The Capabilities
class defines the capabilities
of your Java™ code by encapsulating
a list of attributes and parameters.
The following is a list of the available methods that
the Capabilities
class provides. For details about
the methods, see the Javadoc information
in the Java Integration stage
API documentation.
getMinimumInputLinkCount()
getMaximumInputLinkCount()
getMinimumOutputStreamLinkCount()
getMaximumOutputStreamLinkCount()
getMinimumRejectLinkCount()
getMaximumRejectLinkCount()
getColumnTransferBehavior()
isWaveGenerator()
isRunOnConductor()
setMinumumInputLinkCount()
setMaximumInputLinkCount()
setMinimumOutputStreamLinkCount()
setMaximumOutputStreamLinkCount()
setMinimumRejectLinkCount()
setMaximumRejectLinkCount()
setIsWaveGenerator()
setColumnTransferBehavior()
setIsRunOnConductor()
Right after instantiating your Processor
code,
the Java Integration stage invokes
the getCapabilities()
method in your Processor
code
to get its associated Capabilities
object to determine
whether your Java code can be
run in the current job design.
By overriding the getCapabilities()
method
in the Processor
class, your Java code can customize the values of the capabilities
to address your Java code, and
pass it to the Java Integration
stage.
public Capabilities getCapabilities()
{
Capabilities capabilities = new Capabilities();
capabilities.setMinimumInputLinkCount(1);
capabilities.setMaximumInputLinkCount(1);
capabilities.setMaximumOutputStreamLinkCount(0);
capabilities.setMaximumRejectLinkCount(0);
return capabilities;
}
The job ends if the current job design does not fit the
specified capabilities. getCapabilities()
method. If the number of
links it outside of the specified bounds, then the Java Integration stage will send an appropriate
message to the job log and will abort the job.package samples;
import com.ibm.is.cc.javastage.api.*;
public class ReworkedSimplePeek extends Processor
{
private InputLink m_inputLink;
public Capabilities getCapabilities()
{
Capabilities capabilities = new Capabilities();
capabilities.setMinimumInputLinkCount(1);
capabilities.setMaximumInputLinkCount(1);
capabilities.setMaximumOutputStreamLinkCount(0);
capabilities.setMaximumRejectLinkCount(0);
return capabilities;
}
public boolean validateConfiguration(
Configuration configuration, boolean isRuntime)throws Exception
{
m_inputLink = configuration.getInputLink(0);
return true;
}
public void process() throws Exception
{
do
{
InputRecord inputRecord = m_inputLink.readRecord();
if (inputRecord == null)
{
// No more input. Your code must return from process() method.
break;
}
for (int i = 0; i < m_inputLink.getColumnCount(); i++)
{
Object value = inputRecord.getValue(i);
Logger.information(value.toString());
}
}
while (true);
}
}