Reference Guide

Table Of Contents
public Switch create(String name) {
...
if (auditLogService != null) {
// TODO: com.hp.sdn.rs.misc.ControllerResource (super class of
// RESTful Web Services) offers a method to retrieve the
// authenticated user: getAuthRecord(). SwitchService may be
// modified to receive com.hp.api.auth.Authentication as
// parameter and extract the authenticated user from there.
String user = "hm";
String source = "Health Monitor";
String activity = "Device Added";
String description = "OpenFlow Switch: "
+ deviceToAdd.getId().getValue();
auditLogService.post(user, source, activity, description);
}
return deviceToAdd;
}
...
}
SwitchComponent.java Consuming AuditLogService:
package com.hp.hm.impl;
import com.hp.sdn.adm.auditlog.AuditLogService;
...
@Component
@Service
public class SwitchComponent implements SwitchService {
...
@Reference(policy = ReferencePolicy.DYNAMIC,
cardinality = ReferenceCardinality.OPTIONAL_UNARY)
private volatile AuditLogService auditLogService;
@Activate
public void activate() {
delegate = new SwitchManager(systemInformationService);
delegate.setAlertService(alertService);
delegate.setAuditLogService(auditLogService);
}
...
protected void bindAuditLogService(AuditLogService service) {
auditLogService = service;
if (delegate != null) {
delegate.setAuditLogService(service);
216