2.5. Felix

Felix is a platform for component applications that implements the OSGi standard with extensions.

iPOJO Service Requirement

// Service reference injected into field.
@Requires private LogService log;

// Service reference injected into constructor argument.
public MyComponent (@Requires LogService log) { ... }

// Service reference injected through method invocation.
@Bind public void bindLogService(LogService log) { ... }
@Unbind public void unbindLogService(LogService log) { ... }
@Modified public void modifiedLogService(LogService log) { ... }

// Example adjusted from documentation, see references.

iPOJO Service Provision

// Service provision with implicitly declared interfaces.
@Component @Provides
public class FooProvider implements FooService {
    ...
}

// Service provision with explicitly declared interfaces.
@Component @Provides (specifications={FooService.class})
public class FooProvider implements FooService {
    ...

    // Public service property declaration.
    @ServiceProperty (name="foo", value="foo")
    private String aFoo;

    // Private component property declaration.
    @Property (name="bar", falue="bar")
    private String aBar;

    // Property change notification.
    @Updated public void updated (Dictionary properties) {
        ...
    }
}

// Example adjusted from documentation, see references.

iPOJO Lifecycle Management

// Component with requirements and lifecycle management.
@Component @Instantiate
public class FooComponent {
    @Requires private LogService log;

    @Validate private void start () {
        // Called when all instance requirements become available.
        ...
    }

    @Invalidate private void stop () {
        // Called when some instance requirement ceases being available.
        ...
    }

    // Setting controller field to false disables component instance.
    @Controller private boolean enabled;
}

// Example adjusted from documentation, see references.