/**
   * An apform instance to represent a legacy component discovered in the OSGi registry
   *
   * @param ipojoInstance
   */
  public ApformOSGiInstance(Specification specification, ServiceReference<?> reference) {

    super(
        new InstanceDeclaration(
            VersionedReference.any(generateImplementationName(specification, reference)),
            generateInstanceName(specification, reference)));

    this.specification = specification;

    for (PropertyDefinition property : specification.getDeclaration().getPropertyDefinitions()) {
      Object value = reference.getProperty(property.getName());

      if (value != null) this.declaration.getProperties().put(property.getName(), value.toString());
    }

    this.reference = reference;
    this.bundle = reference.getBundle();
    this.bundleContext =
        AccessController.doPrivileged(
            new PrivilegedAction<BundleContext>() {
              public BundleContext run() {
                return bundle.getBundleContext();
              }
            });

    this.service = null;
  }