concept component in category osgi

This is an excerpt from Manning's book OSGi in Depth.
This is a reasonable number, especially if you consider that OSGi is still an emerging technology. Furthermore, because you can mix and match the components from different vendors, the overall gains are even larger! For example, you can use the Felix OSGi framework with the Eclipse service implementations and perhaps implement a few services of your own along the way.
A Blueprint-flavored bundle is a bundle that contains XML documents specified using Blueprint’s schema that describe how components can be created and assembled together. Component is a rather loose term, but in the context of the OSGi platform a component is essentially either a Java object, an OSGi service, or an OSGi reference (to a service).
Before we look at the SabNamespaceHandler class, note how we defined an anonymous Java component nested within the <service> tag in the previous XML example. This is another one of Blueprint’s advantages—being able to succinctly nest anonymous components within components and avoid the verbosity and indirection of using refs.

This is an excerpt from Manning's book OSGi in Action: Creating Modular Applications in Java.
The Java platform also inhibits good modularity practices. The main culprit is the Java class path. Why does the class path pose problems for modularity? Largely due to all the issues it hides, such as code versions, dependencies, and consistency. Applications are generally composed of various versions of libraries and components. The class path pays no attention to code versions—it returns the first version it finds. Even if it did pay attention, there is no way to explicitly specify dependencies. The process of setting up your class path is largely trial and error; you just keep adding libraries until the VM stops complaining about missing classes.
Figure 1.2 shows the sort of “class path hell” often found when more than one JAR file provides a given set of classes. Even though each JAR file may have been compiled to work as a unit, when they’re merged at execution time, the Java class path pays no attention to the logical partitioning of the components. This tends to lead to hard-to-predict errors, such as NoSuchMethodError, when a class from one JAR file interacts with an incompatible class version from another.
Although component-oriented programming has been around for a while, there’s no single definition for most of the concepts it embodies (which is similar to module orientation). Therefore, you shouldn’t take the discussion in this section as the bible for all component-oriented approaches. The main questions we intend to address for the scope of this chapter and the next are, what are components, and why do we want them? We’ll answer these questions in the following two subsections, respectively.
The Declarative Services framework creates a unique ComponentContext object for each component it activates. This object plays a role for components similar to the role the BundleContext object plays for bundles—it provides access to execution environment facilities. The ComponentContext interface is as follows:
public interface ComponentContext { public Dictionary getProperties(); public Object locateService(String name); public Object locateService(String name, ServiceReference reference); public Object[] locateServices(String name); public BundleContext getBundleContext(); public Bundle getUsingBundle(); public ComponentInstance getComponentInstance(); public void enableComponent(String name); public void disableComponent(String name); public ServiceReference getServiceReference(); }The getProperties() method allows a component to access its configuration properties. The methods for locating services provide an alternative approach to service injection for using services; this alternative strategy is discussed in the “Lookup strategy” sidebar. The getBundleContext() method provides access to the containing bundle’s BundleContext object. The getUsingBundle() method is related to component factories, which we’ll discuss later.
The getComponentInstance(), enableComponent(), and disableComponent() methods provide a component with a way to programmatically control the component lifecycle; we’ll discuss them further in the next section. Finally, the getService-Reference() method allows a component to access the ServiceReference of this component if it provides a service.
In the general case, whether or not a component is satisfied is dictated by whether or not its service dependencies are satisfied. But this isn’t the only type of dependency considered by Declarative Services; another situation is where a component is dependent on its configuration properties.
A key aspect of all component technologies is that they describe functional building blocks that are typically more coarse-grained than what we normally associate with objects (although object orientation isn’t required for component orientation). These building blocks are typically business logic; they provide functionality via interfaces. Conversely, components may consume functionality provided by other components via their interfaces. Components for a given approach are usually programmed according to a particular pattern defined by a component model. A component framework is used to execute components.
Doesn’t it sound like modules and components have a lot in common? They both provide stuff to each other and consume stuff from each other. They’re also packaged as independent deployment units. Couldn’t these two be considered one and the same or at least be combined? Yes, they could, but components and modules serve different purposes and are somewhat orthogonal (they’re not completely orthogonal, because components are made from code that can ultimately be packaged into modules).
Modules deal with code packaging and the dependencies among code. Components deal with implementing higher-level functionality and the dependencies among components. Components need their code dependencies managed, but they technically don’t need a module system to do it (often it’s us programmers doing it via the class path).
A good summary is that you can think of modules as dealing with static code and compile-time dependencies, whereas components deal with instances and execution-time dependencies.
The general approach for creating an application from components is to compose it. This means you grab the components implementing the functionality you need and compose them (match required interfaces to provided interfaces) to form an application. Component compositions can be declarative, such as using some sort of composition language to describe the components and bindings among them; or implicit, where the composition is the deployed set of components. For the application to execute, the application’s constituent components must somehow be loaded into the component framework and instantiated. Figure 11.1 shows a trivial component composition.
This description of component orientation is by no means complete. Depending on the component model, components may have a variety of capabilities, such as explicit lifecycle control. Some component models and frameworks differentiate between component types and instances (for example, there can be multiple component instances from a given type), whereas others treat them as being the same (only one instance per component). You’ll see some of these differences rear their heads in our later discussions of specific OSGi-based component frameworks. For now, it’s sufficient if your general understanding of component orientation is as a programming approach promoting coarse-grained, composable application building blocks. Now let’s look at why we want it.