Hi,

I like it to use Optionals if it is possible that a field could be null.


In context of OSGi Services with SCR that means I have to handle it like this:

```

@Component
public class MyComponent
{

    Optional<Foo> oFoo = Optional.empty();

    @Reference(cardinality = ReferenceCardinality.OPTIONAL)
    void bindFoo(Foo foo)
    {
        oFoo = Optional.of(foo);
    }
}

```

What I really want to do is this:

```

@Component
public class MyComponent
{

    @Reference
    Optional<Foo> oFoo;

}

```


We have something like this in OSGi - CDI Integration Specification
https://youtu.be/7-UUJ4WkMsg?t=839

It would be nice to have this feature with the new version of the R8 DS Spec.


Regards

Stefan

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to