This topic explains how to use the StreamBase Embedded Adapter wizard to generate the base code for a custom embedded adapter. For additional details, please refer to the StreamBase Help topics listed in Related Topics.
In the StreamBase Java API, we provide the com.streambase.sb.adapter.InputAdapter and com.streambase.sb.adapter.OutputAdapter classes, which you can
extend to define custom embedded adapters for your StreamBase
applications. Embedded adapters run in the same server process (sbd) that is hosting and processing your
StreamBase application's requests, thus eliminating the client/server
communication overhead seen with external adapters. Embedded adapters start and stop
automatically with the StreamBase application, which simplifies many
administration tasks.
The Embedded Adapter wizard helps you get started with the Java API by stepping you
through the definition process. The Java source file that it generates has commented
TODO sections that you can later edit to add the
functionality you want.
After you replace these sections with your implementation code, you can use the adapter immediately in applications that you run locally in StreamBase Studio. If you are running your applications remotely, you may want to generate a JAR first.
To open the wizard, click → → . Edit these fields in the wizard:
- Type
-
Select between Input Adapter and Output Adapter. Input adapters take information from outside of a StreamBase application and provide it in the form of a stream or streams to the application. Output adapters take streams from a StreamBase application and make them available outside of the application.
- Source folder
-
Specify the path to an existing folder within your StreamBase Studio project, or to a referenced folder. The default path entered for you is the
java-srcsubfolder of the current project. - Package
-
Specify the name of a Java package to contain your adapter class, such as com.mycompany.mysbapp.myadapter.
- Name
-
Specify a name for your class, such as
MyInputAdapter. - Display Name
-
Specify a display name to identify your adapter within StreamBase Studio. If not specified, the adapter name in the field above is used.
- Ports
-
For Input Adapters, specify the number of output ports. For Output Adapters, specify the number of input ports.
For example:
|
If the wizard detects that the Java Client API is not on your project's build path, it displays a message informing you of the problem and suggesting a solution. See Adding StreamBase Client API to the Project Build Path.
When ready, click to display the next page (either the input or output adapter page).
Use the Input Adapter dialog to set properties for your custom embedded Input
Adapter. Input adapters take information from outside of a StreamBase
application and provide it in the form of a stream or streams to the application.
This class implements com.streambase.sb.adapter.InputAdapter. Input adapters should
call sendOutput( to provide tuples to the application.
int, Tuple)
-
Define the properties for the adapter:
-
Click the button in the Input Adapter page.
-
In the New Adapter Property dialog, set the
Type,Name,Displayname, anddefaultvalues. -
In the New Adapter Property dialog, set the
Property,Name,Displayname, andDefaultValue. By default, properties are required: uncheckOptional propertyif you want to make this property optional. -
Click to add the property to the Input Adapter page.
-
Repeat the previous steps for each property you want to add.
Use the other buttons to modify or manage properties in the adapter. For example, select a property and click to change its values; use the and buttons to change the order of properties in the generated adapter.
-
-
Optionally, change the default setting to Use a background thread. When enabled, this option generates code that enqueues the tuples in a thread separate from the application’s main thread.
-
Optionally, change which method stubs will be created:
-
init()
-
resume() and suspend()
-
shutdown()
-
-
When you are ready, click .
Two Java classes will be generated: an adapter class and a bean info class. You will not need to edit the content of the bean info class, but you do need to provide implementations for the methods marked
// TODO. You will need to edit the body of the constructor method if you have an Enum type as a configurable parameter. -
The wizard prompts you to refresh the project's Typecheck Environment. Do this in one of the following ways:
-
Switch to the project's EventFlow application and press Ctrl-F5, or run Refresh Project Typecheck Environment from the context menu.
-
Select the project's name in the Package Explorer, right-click, and choose → .
Notice that refreshing the typecheck environment (Ctrl-F5) is not the same as the Apply and Typecheck operation (Ctrl-T).
The new adapter does not appear in the Project Adapters drawer of the Palette view until you run this step.
Tip
You must repeat this step whenever you make changes to source files for your Java adapter.
-
Use the Output Adapter dialog to set properties for your custom embedded Input
Adapter. Output adapters take streams from a StreamBase application
and make them available outside of the application. This class implements
com.streambase.sb.adapter.OutputAdapter. Output
adapters should override the method processTuple( to receive tuples from the
application.
int, Tuple)
-
Define the properties for the adapter:
-
Click the button in the Output Adapter page.
-
In the New Adapter Property dialog, set the
Property,Name,Displayname, andDefaultValue. By default, properties are required: uncheckOptional propertyif you want to make this property optional. -
Click to add the property to the Output Adapter page.
-
Repeat the previous steps for each property you want to add.
Use the other buttons to modify or manage properties in the adapter. For example, select a property and click to change its values; use the and buttons to change the order of properties in the generated adapter.
-
-
Optionally, change the default setting to Use a background thread. When enabled, this option generates code that enqueues the tuples in a thread separate from the application’s main thread.
-
Optionally, change which method stubs will be created:
-
init()
-
resume() and suspend()
-
shutdown()
-
-
When you are ready, click .
Two Java classes will be generated: an adapter class and a bean info class. You will not need to edit the content of the bean info class, but you do need to provide implementations for the methods marked
// TODO. You will need to edit the body of the constructor method if you have an Enum type as a configurable parameter. -
The wizard prompts you to refresh the project's Typecheck Environment. Do so after clicking to dismiss the wizard: right-click the project in the Package Explorer, and choose → . This makes the new adapter available for use by your applications.
Tip
You must repeat this step whenever you make changes to source files that you want your applications to use.
-
For general information about using the StreamBase API for Java clients, start in API Guide.
-
For the Java API Javadoc, see the StreamBase Application Programming Interfaces topic of the StreamBase Reference Guide.
