|By Piram Manickam, Subrahmanya SV||
|April 10, 2012 01:30 PM EDT||
This article introduces the concepts of Component Oriented Development and Assembly (CODA) using the OSGi Service platform with an example application. The article starts with an introduction to software components, elaborates with an example application, followed by an overview of the OSGi Service platform, and an implementation of the example application using this platform.
Introduction to Software Components
Components are parts that can be assembled to form a larger system. Electronic components such as ICs (Integrated Circuits) are assembled together to build an electronic system; similarly software components are assembled together to build a software system. Software systems have a static form as well as a dynamic runtime form. Software components can be assembled either in static form or dynamic form. In either case, the software component is an independent unit of development, deployment, and assembly. Using components to build software systems will provide many architectural advantages apart from promoting ease of reuse.
Age Calculation - An Example Application
Consider an application meant for calculating the age of people. Assume this application prompts the user to provide her personal details such as name and date of birth. Once the user provides the details, the application calculates the age of the person as of today and displays it with a personal greeting. Such an application can be built from the following software components:
- UserProfile Component: Responsible for collecting the personal details of the user such as name and date of birth
- Age Component: Responsible for calculating the age, given the date of birth
- Greeting Component: Responsible for displaying the greeting message along with age of the person; needs to make use of the UserProfile component to obtain input from the user and Age component to calculate the age
- AgeCalculationApp Component: Responsible for invoking the Greeting service provided by Greeting component
The components can be represented in a UML component diagram as shown in Figure 1. The dotted arrow lines in the diagram denote dependency.
Figure 1: Components in the Age Calculation application
Interfaces of Software Components
A software interface is a collection of software operations. Software components interact with one another by invoking the software operations. To facilitate structured interactions across components, each component exposes one or more software interfaces through which other components can interact. The exposed interfaces of a component are called as its "provided interfaces." Internals of the component implement the service contracts exposed by the provided interfaces.
Apart from providing services, a component needs to consume services provided by other components. The set of services that a component wants to consume is specified through "required interfaces". A component can work with any other component that provides the required interfaces. Hence there is no tight coupling between one component and another; the dependency of a component is only with interfaces and not with other components.
Interfaces in the Age Calculation Application
Let us identify the interfaces provided and required by each of the four components in the Age Calculation application.
The Age component is responsible for calculating the age, given the date of birth. Hence it needs to provide a service for calculating the age. Let's expose this service through a provided interface IAgeCalculation. The Java code for this interface is given in Figure 2.
Figure 2: AgeCalculation Java interface code
In the IAgeCalculation interface definition, Calendar is a data type defined in java.util package to represent the date. IAge is a custom-defined data type to hold the age. The Java code for IAge is shown in Figure 3.
Figure 3: Java code for data type IAge
The Age Component can be represented in a UML component diagram as shown in Figure 4. The lollipop connector from the component denotes provided interface.
Figure 4: UML representation of Age component
The UserProfile component is responsible for collecting the personal information from end user and passing it back to the consuming component. Let us define an interface called as IUserProfileCollection to expose this service. The Java code for this interface is shown in Figure 5.
Figure 5: Java code for IUserProfileCollection interface
When the method collectUserProfile() is called, the component starts an interactive session with the end user to collect her personal information. During the user interaction session, the method isProfileCollected() will return false; after the user interaction session has finished and the user profile has been collected, this method will return true. At this time, the user profile is ready for pick-up by the consuming component and it can do so by invoking giveUserProfile() method.
giveUserProfile() method returns the user profile information through a custom defined data type IUserProfile. Java code for IUserProfile data type is given in Figure 6.
Figure 6: Java code for IUserProfile data type
The UserProfile component in a UML component diagram notation is shown in Figure 7.
Figure 7: UML representation of UserProfile component
The Greeting component is responsible for displaying the greeting message along with the age. We'll expose this service through the IGreeting interface. The Java code for IGreeting interface is shown in Figure 8.
Figure 8: Java code for interface IGreeting
The Greeting component provides the IGreeting service, and it requires the IAgeCalculation and IUserProfileCollection services. The required and provided interfaces of the Greeting component can be represented using the UML component diagram as shown in Figure 9. The receptacle sockets in the component diagram denote required interfaces.
Figure 9: UML representation of Greeting component
The AgeCalculationApp component is responsible for invoking the IGreeting service of Greeting component. The AgeCalculationApp itself does not provide any service. The UML diagram for this component is shown in Figure 10.
Figure 10: UML representation of AgeCalculationApp
Components are assembled together to build a software system. Components for an assembly should be chosen such a way that, amongst the chosen components the set of required interfaces is fulfilled by the set of provided interfaces. The four components of the example application can be assembled to result in Age Calculation application. UML component diagram denoting this assembly is shown in Figure 11. Connectors with a lollipop and a receptacle together show how two components assemble over a common interface (one component provides the interface and another component requires it).
Figure 11: UML representation of Age Calculation application assembly
Once an application is assembled, specific components from the assembly can be replaced with compatible newer components. Let us say we have two new components - GUIUserProfile and GUIGreeting, which have same interfaces as UserProfile and Greeting components, respectively. Then these new components can replace the old components to provide us with a GUI application. The application assembly would then look like Figure 12.
Figure 12: Age Calculation GUI Application Assembly
Introduction to the OSGi Service Platform
OSGi Service is a standards based software development platform. The platform standards are specified by the OSGi Alliance (http://www.osgi.org), formerly known as the Open Services Gateway initiative. OSGi alliance is an industry backed nonprofit organization.
OSGi platform provides a modularity and component model on top of Java. Figure 13 illustrates how OSGi logically fits in a development / deployment stack.
Figure 13: OSGi From Development / Deployment Perspective
At the core of the OSGi platform is the OSGi framework defined by standards. OSGi framework is the runtime environment on which OSGi applications can be executed. OSGi framework specifies a common API using which application developers can develop OSGi applications. The OSGi framework specifications is used by OSGi framework developers also, who build implementations of the framework as per the specifications.
There are a number of framework implementations available from different developers. A few well known framework implementations are listed below:
- Apache Felix (http://felix.apache.org)
- Eclipse Equinox (http://www.eclipse.org/equinox)
- Knoplerfish (http://www.knoplerfish.org)
The functionality of OSGi framework is divided into many layers. For our purposes, we shall focus on Modules Layer and Services Layer. Figure 14 illustrates the layers we would like to focus.
The modules layer is the bottom most layer interacting with the runtime framework. The modules layer defines a modularity framework on top of standard Java so that modules expose and interact via well-defined APIs. Individual module is called as a "bundle" in OSGi. OSGi bundle is the atomic unit of deployment on an OSGi framework. An OSGi bundle is nothing but a Java Archive (JAR) File with some special manifest information that would be used by the OSGi framework when the bundle is deployed. Unlike a normal JAR file, which exposes all its code when it is deployed on a Java Virtual Machine (JVM), the bundle does not expose all the code contained within. Only code (Java packages) marked for explicit export is exposed outside the bundle.
Figure 14: OSGi Framework Functional Layers
Above the Module layer is the Services layer. An OSGi Service is defined by a Java interface. Any bundle can implement the service, and register the service with the OSGi Service Registry. OSGi Service Registry, defined as part of framework standards, supports a publish, subscribe, and look-up mechanism of exchanging services across components. A bundle can register the service that it has implemented with the OSGi Service Registry. A bundle requiring a service can query the OSGi Service Registry to look-up any registered service implementation. Instead of looking-up, a bundle can also subscribe to be notified on service registration / unregistration events. These mechanisms make the bundles that provide service and bundles that consume service unaware of each other, leading to independent development and deployment of these components. Once deployed, they can be assembled dynamically using the OSGi Service Registry.
Implementing Age Calculation Using OSGi
The Age Calculation application has one bundle for each of the components. Each bundle has a Java package that is exposed for access from outside and an internal Java package. The exposed package defines the interfaces and the internal package contains implementation classes. The package diagram for all the bundles is shown in Figure 15.
Figure 15: Age Calculation Application bundles
The service provided by each bundle is exposed by using the OSGi Declarative Services framework. Using the same framework, each bundle also specifies the list of services it requires. The OSGi Declarative Services framework (also known as Service Component Runtime), will perform the work of registering the provided service with the OSGi Service Registry and obtaining the required service through look-up into OSGi Service Registry. Thus, the Declarative Services framework provides automatic assembly of deployed components.
As an example, let us consider the Greeting bundle. The Declarative Services specification of the components in this bundle is done through an XML file, which is given in Figure 16.
Figure 16: Greeting component Declarative Service Definition
The XML file contains following metadata about the Greeting component:
- A component by name com.demo.greeting is defined
- The component is implemented by the class com.demo.greeting.internal.Greeting
- The component requires two interfaces - IuserProfileCollection and IAgeCalculation. These required interfaces should be dynamically wired to this component using setUserProfileCollection() and setAgeCalculation() methods on the component implementation class.
- The component provides a service through the provided interface com.demo.greeting.IGreeting.
To understand how the Greeting component works, some portions of the implementation class is presented in Figure 17. The Greeting class has two field variables referring to the services required by this component. In the component Declarative Service metadata setter methods of these two variables are linked to the service reference (required interface). Hence when the Service Component Runtime (SCR) activates this component, it would call the setter methods to point these variables to objects which provide the service. For example, an instance of AgeCalculator object from Age component would be passed to ageCalculation_ member variable.
Figure 17: Implementation of Greeting component
The Greeting class's implementation of greet() method obtains the user profile by invoking IUserProfileCollection service. From the obtained profile, date of birth is extracted and IAgeCalculation service is used to calculate the age. Finally the method displays the age along with a greeting to the user.
Output from the Example Application
The Age Calculation application, with console mode user interaction components, has the following output.
osgi> What is your first name?
What is your last name?
What is your title (Mr./Ms./Mrs./Prof./Dr.)?
What is your year of birth?
What is your month of birth (1-12)?
What is your date of birth (1-31)?
Hello Mr. Albert Einstein, you are 132 years, 10 months, and 3 days old.
If we replace the Greeting and UserProfile components in the application assembly with GUIGreeting and GUIUserProfile components, the application output is as below:
The source code of the application can be downloaded as a zip file containing an Eclipse workspace folder. To open the source code and run the application simply unzip the folder and switch the Eclipse workspace to point to the unzipped folder. Choose the appropriate components in the Run Configuration to run either console version or the GUI version of the assembly. For example, for the GUI version, the following run configuration will be applicable:
|newuniverse 01/31/12 03:10:00 AM EST|
The enterprise market will drive IoT device adoption over the next five years. In his session at @ThingsExpo, John Greenough, an analyst at BI Intelligence, division of Business Insider, analyzed how companies will adopt IoT products and the associated cost of adopting those products. John Greenough is the lead analyst covering the Internet of Things for BI Intelligence- Business Insider’s paid research service. Numerous IoT companies have cited his analysis of the IoT. Prior to joining BI Intelligence, he worked analyzing bank technology for Corporate Insight and The Clearing House Payment...
Jul. 7, 2015 02:00 AM EDT Reads: 1,233
"ciqada is a combined platform of hardware modules and server products that lets people take their existing devices or new devices and lets them be accessible over the Internet for their users," noted Geoff Engelstein of ciqada, a division of Mars International, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 7, 2015 01:15 AM EDT Reads: 856
SYS-CON Events announced today that Secure Infrastructure & Services will exhibit at SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Secure Infrastructure & Services (SIAS) is a managed services provider of cloud computing solutions for the IBM Power Systems market. The company helps mid-market firms built on IBM hardware platforms to deploy new levels of reliable and cost-effective computing and high availability solutions, leveraging the cloud and the benefits of Infrastructure-as-a-Service (IaaS...
Jul. 6, 2015 11:00 PM EDT Reads: 1,921
The 4th International Internet of @ThingsExpo, co-located with the 17th International Cloud Expo - to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA - announces that its Call for Papers is open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than
Jul. 6, 2015 05:00 PM EDT Reads: 1,979
SYS-CON Events announced today that ProfitBricks, the provider of painless cloud infrastructure, will exhibit at SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. ProfitBricks is the IaaS provider that offers a painless cloud experience for all IT users, with no learning curve. ProfitBricks boasts flexible cloud servers and networking, an integrated Data Center Designer tool for visual control over the cloud and the best price/performance value available. ProfitBricks was named one of the coolest Clo...
Jul. 6, 2015 05:00 PM EDT Reads: 2,163
"In the IoT space we are helping customers, mostly enterprises and industry verticals where time-to-value is critical, and we help them with the ability to do faster insights and actions using our platform so they can transform their business operations," explained Venkat Eswara, VP of Marketing at Vitria, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 6, 2015 04:30 PM EDT Reads: 695
SYS-CON Events announced today that WHOA.com, an ISO 27001 Certified secure cloud computing company, participated as “Bronze Sponsor” of SYS-CON's 16th International Cloud Expo® New York, which took place June 9-11, 2015, at the Javits Center in New York City, NY. WHOA.com is a leader in next-generation, ISO 27001 Certified secure cloud solutions. WHOA.com offers a comprehensive portfolio of best-in-class cloud services for business including Infrastructure as a Service (IaaS), Secure Cloud Desktop, Cloud Storage, Disaster Recovery, Integrated Applications and Security.
Jul. 6, 2015 02:45 PM EDT Reads: 1,115
SYS-CON Events announced today that Intelligent Systems Services will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Established in 1994, Intelligent Systems Services Inc. is located near Washington, DC, with representatives and partners nationwide. ISS’s well-established track record is based on the continuous pursuit of excellence in designing, implementing and supporting nationwide clients’ mission-critical systems. ISS has completed many successful projects in Healthcare, Commercial, Manu...
Jul. 6, 2015 02:15 PM EDT Reads: 1,192
The Internet of Things is not only adding billions of sensors and billions of terabytes to the Internet. It is also forcing a fundamental change in the way we envision Information Technology. For the first time, more data is being created by devices at the edge of the Internet rather than from centralized systems. What does this mean for today's IT professional? In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists addressed this very serious issue of profound change in the industry.
Jul. 6, 2015 02:15 PM EDT Reads: 1,897
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
Jul. 6, 2015 02:00 PM EDT Reads: 1,450
SYS-CON Events announced today that kintone has been named “Bronze Sponsor” of SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. kintone promotes cloud-based workgroup productivity, transparency and profitability with a seamless collaboration space, build your own business application (BYOA) platform, and workflow automation system.
Jul. 6, 2015 01:45 PM EDT Reads: 2,163
Discussions about cloud computing are evolving into discussions about enterprise IT in general. As enterprises increasingly migrate toward their own unique clouds, new issues such as the use of containers and microservices emerge to keep things interesting. In this Power Panel at 16th Cloud Expo, moderated by Conference Chair Roger Strukhoff, panelists addressed the state of cloud computing today, and what enterprise IT professionals need to know about how the latest topics and trends affect their organization.
Jul. 6, 2015 01:15 PM EDT Reads: 1,849
SYS-CON Events announced today that SoftLayer, an IBM company, has been named “Gold Sponsor” of SYS-CON's 17th International Cloud Expo®, which will take place November 3–5, 2015 at the Santa Clara Convention Center in Santa Clara, CA. SoftLayer operates a global cloud infrastructure platform built for Internet scale. With a global footprint of data centers and network points of presence, SoftLayer provides infrastructure as a service to leading-edge customers ranging from Web startups to global enterprises. SoftLayer’s modular architecture, full-featured API, and sophisticated automation pro...
Jul. 6, 2015 01:15 PM EDT Reads: 2,221
17th Cloud Expo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterprises are using some form of XaaS – software, platform, and infrastructure as a service.
Jul. 6, 2015 01:00 PM EDT Reads: 1,777
SYS-CON Events announced today that CommVault has been named “Bronze Sponsor” of SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. A singular vision – a belief in a better way to address current and future data management needs – guides CommVault in the development of Singular Information Management® solutions for high-performance data protection, universal availability and simplified management of data on complex storage networks. CommVault's exclusive single-platform architecture gives companies unp...
Jul. 6, 2015 12:15 PM EDT Reads: 2,109
Buzzword alert: Microservices and IoT at a DevOps conference? What could possibly go wrong? In this Power Panel at DevOps Summit, moderated by Jason Bloomberg, the leading expert on architecting agility for the enterprise and president of Intellyx, panelists peeled away the buzz and discuss the important architectural principles behind implementing IoT solutions for the enterprise. As remote IoT devices and sensors become increasingly intelligent, they become part of our distributed cloud environment, and we must architect and code accordingly. At the very least, you'll have no problem fillin...
Jul. 6, 2015 11:45 AM EDT Reads: 2,600
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
Jul. 6, 2015 11:30 AM EDT Reads: 1,790
The 5th International DevOps Summit, co-located with 17th International Cloud Expo – being held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits, DevOps is corr...
Jul. 6, 2015 11:15 AM EDT Reads: 1,829
Internet of Things (IoT) will be a hybrid ecosystem of diverse devices and sensors collaborating with operational and enterprise systems to create the next big application. In their session at @ThingsExpo, Bramh Gupta, founder and CEO of robomq.io, and Fred Yatzeck, principal architect leading product development at robomq.io, discussed how choosing the right middleware and integration strategy from the get-go will enable IoT solution developers to adapt and grow with the industry, while at the same time reduce Time to Market (TTM) by using plug and play capabilities offered by a robust IoT ...
Jul. 6, 2015 11:00 AM EDT Reads: 2,555
Today air travel is a minefield of delays, hassles and customer disappointment. Airlines struggle to revitalize the experience. GE and M2Mi will demonstrate practical examples of how IoT solutions are helping airlines bring back personalization, reduce trip time and improve reliability. In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect with GE, and Dr. Sarah Cooper, M2Mi’s VP Business Development and Engineering, will explore the IoT cloud-based platform technologies driving this change including privacy controls, data transparency and integration of real time context wi...
Jul. 6, 2015 09:45 AM EDT Reads: 1,821