org.apache.felix.ipojo.extender

## Interface InstanceBuilder

All Known Implementing Classes:
  DefaultInstanceBuilder

    public interface InstanceBuilder

Support class for fluent instance declaration building. This class can be used to specify instance details like naming, component's type, component's version. The `context(org.osgi.framework.BundleContext)` method can be used to override the default `BundleContext` used for declaration service registration.

Since:
  1.11.2

### Method Summary

All Methods Instance Methods Abstract Methods
`DeclarationHandle` `build()` Build the declaration handle (never contains any configuration).
`ConfigurationBuilder` `configure()` Access the dedicated builder for configuration (properties).
`InstanceBuilder` `context(org.osgi.framework.BundleContext context)` Override the default BundleContext used for declaration service registration.
`InstanceBuilder` `name(java.lang.String name)` Specify the instance name.
`InstanceBuilder` `type(java.lang.Class<?> type)` Specify the component's type of this instance.
`InstanceBuilder` `type(java.lang.String type)` Specify the component's type of this instance.
`InstanceBuilder` `version(java.lang.String version)` Specify the component's version of this instance.

### Method Detail

#### name

    InstanceBuilder name(java.lang.String name)

Specify the instance name. Using null will result in an anonymous instance.

Parameters:
  `name` - instance name or null
Returns:
  this builder

#### type

    InstanceBuilder type(java.lang.String type)

Specify the component's type of this instance.

Parameters:
  `type` - type of the instance (cannot be null).
Returns:
  this builder

#### type

    InstanceBuilder type(java.lang.Class<?> type)

Specify the component's type of this instance.

Parameters:
  `type` - type of the instance (cannot be null).
Returns:
  this builder

#### version

    InstanceBuilder version(java.lang.String version)

Specify the component's version of this instance. If null is used, the factory without any version attribute will be used.

Parameters:
  `version` - component's version (can be null).
Returns:
  this builder

#### context

    InstanceBuilder context(org.osgi.framework.BundleContext context)

Override the default BundleContext used for declaration service registration. Use this with <bold>caution</bold>, for example, if the bundle does not import the ``org.apache.felix.ipojo.extender`` package, declarations may not be linked and activated properly.

Parameters:
  `context` - new context to be used.
Returns:
  this builder

#### configure

    ConfigurationBuilder configure()

Access the dedicated builder for configuration (properties). Notice that when this method is used, the called must use `ConfigurationBuilder.build()` to build the instance declaration configured with the right set of properties. Any attempt to use `build()` will result in a new declaration with no properties associated. Good usage (produced declaration has the associated properties):

         DeclarationHandle handle = builder.configure()
                                                .property("hello", "world")
                                                .build();

Bad usage (produced declaration does not have the associated properties):

         builder.configure()
                    .property("hello", "world");

         DeclarationHandle handle = builder.build();

Returns:
  the instance configuration builder

#### build

    DeclarationHandle build()

Build the declaration handle (never contains any configuration). Notice that the declaration is not yet published (no automatic activation). The client has to do it through `DeclarationHandle.publish()`

Returns:
  the handle to the declaration