Developer Introduction
Developing for the Alpaca API has been designed to be easy to generate small stand alone applications leveraging the power of the entire BroadWorks OCI. This is as easy as a single step due to the Alpaca runner performing compile and run in a single step.
Samples can be downloaded, placed into the Alpaca directory and ran via ./runner Sample.java
.
Setup
There are no extra setup steps required to begin development. However, if the Alpaca Library will be integrated into a multi file project then the Alpaca Library jar and its dependencies located in ./lib
will need to be added to the project classpath.
Getting Started
BroadWorksServer
The starting point for any Alpaca Library application is the BroadWorksServer
object. Creating a BroadWorksServer
will perform the login procedure and verify that the server matches the expected platform version.
BroadWorksServer bws =
BroadWorksServer.getBroadWorksServer(server, username, password);
The BroadWorksServer
object is used in all system level requests. If an object contains a reference to the BroadWorksServer
then it can be ommitted. For example, if you use the connection to retrieve a User
then if a request takes a User
as a parameter the BroadWorksServer
will be ommitted.
Alpaca Properties
Using properties located in the alpaca.properties.xml
file can be accomplished by using the class P
. This class has inner classes with links to all property types. If you wanted to login to the BroadWorksServer
using the credentials in the configuration it could be accomplished by:
String server = P.CoreProperties.getPrimaryBroadWorksServerAddress();
String username = P.CoreProperties.getPrimaryBroadWorksUserId();
String password = P.CoreProperties.getPrimaryBroadWorksPassword();
BroadWorksServer bws =
BroadWorksServer.getBroadWorksServer(server, username, password);
Firing Requests
All OCI Requests have a corresponding Java class that can be created. To get all the Access Devices in a BroadWorks system you would need to send a SystemAccessDeviceGetAllRequest
. In Alpaca this would be accomplished by calling:
SystemAccessDeviceGetAllRequest accessDeviceGetAllRequest =
new SystemAccessDeviceGetAllRequest(bws);
All required fields for the request will be in the constructor. However, many OCI request have optional fields that can be accessed by calling .setX(Y)
on the Request
object prior to sending it to BroadWorks.
After the Request
has been created it can be sent to the system by calling .fire()
. For GET type requests they will return a specific Response
.
SystemAccessDeviceGetAllResponse accessDeviceGetAllResponse =
accessDeviceGetAllRequest.fire();
Requests can also be fired asynchronously by calling .asyncFire()
and passing in the function to call on completion.
accessDeviceGetAllRequest.asyncFire(response -> {
response.getAccessDeviceTable();
});