Reference Guide

Table Of Contents
NOTE
The usage of
SwitchComponent
may be omitted and directly annotate
SwitchManager
if preferred. The
generated example application does not provide a SwitchComponent.java file.
SwitchComponent.java (Sample Application OSGi Service Component):
package com.hp.hm.impl;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
...
@Component
@Service
public class SwitchComponent implements SwitchService {
private SwitchService delegate;
public SwitchComponent() {
delegate = new SwitchManager();
}
@Override
public Switch create(String name) {
return delegate.add(name);
}
@Override
public Collection<Switch> getAll() {
delegate.getAll();
}
@Override
public Switch get(Id<Switch, UUID> id) {
return delegate.get(id);
}
@Override
public void delete(Id<Switch, Long> id) {
delegate.delete(id);
}
}
SwitchComponent is annotated with @Component to make it part of the OSGi component
management framework (lifecycle management) and thus it is allowed to consume other
160