Book Image

Mastering Eclipse Plug-in Development

By : Alex Blewitt, Bandlem Limited
Book Image

Mastering Eclipse Plug-in Development

By: Alex Blewitt, Bandlem Limited

Overview of this book

Table of Contents (18 chapters)
Mastering Eclipse Plug-in Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Plugging in to JFace and the Common Navigator Framework
Index

Preface

The Eclipse platform provides an extensible system for building plug-ins and applications in a modular fashion. While other books discuss the general mechanism to create plug-ins, this book dives deeper into the underlying mechanisms, including how to create plug-ins that have their own extension points and how to use OSGi services within an Eclipse application. It is expected that you are familiar with Eclipse plug-in development already and you understand the content covered in Eclipse 4 Plug-in Development by Example Beginner's Guide, Packt Publishing. By the end of this book, you will know how to write extensible plug-ins for both Eclipse extensions as well as standalone OSGi frameworks and provide end-to-end delivery of Eclipse applications with help and update sites.

What this book covers

Chapter 1, Plugging in to JFace and the Common Navigator Framework, demonstrates how to create JFace wizards and how to integrate content into the Common Navigator Framework, which is then used by Package Explorer to provide a tree view of the project's contents.

Chapter 2, Creating Custom Extension Points, shows how the Eclipse extension registry can be used to create an extensible plug-in that allows other plug-ins to contribute functionalities and how it can be used outside of an OSGi or Eclipse runtime.

Chapter 3, Using OSGi Services to Dynamically Wire Applications, introduces OSGi services as a means to extend an application's functionality. This chapter shows how these services can be configured declaratively with Declarative Services or Blueprint and how they can be configured using Config Admin along with the new changes in OSGi R6.

Chapter 4, Using the Gogo Shell and Commands, discusses how to use the Gogo shell embedded in Eclipse 4 and how to extend it by creating custom commands in Gogo script and Java.

Chapter 5, Native Code and Fragment Bundles, demonstrates how to load native code into an OSGi or Eclipse application and how fragment bundles can be used to extend the capabilities of the framework or existing OSGi bundles.

Chapter 6, Understanding ClassLoaders, goes into detail as to how the key concepts of a Java ClassLoader work and how they are used in an OSGi runtime. It also explains how non-OSGi workarounds, such as the Thread Context ClassLoader and ServiceLoader, can be used in an OSGi framework, along with presenting upgrade strategies for non-OSGi JARs.

Chapter 7, Designing Modular Applications, discusses modular design patterns such as the whiteboard pattern and extender pattern along with 18 best practices, including how to use semantic versioning and tools that can automate version number management.

Chapter 8, Event-driven Applications with EventAdmin, introduces the OSGi EventAdmin service and how E4 uses events under the covers to provide an interactive workspace, along with 7 steps for designing event-driven applications.

Chapter 9, Deploying and Updating with P2, shows how to create and manage P2 repositories (update sites) along with creating custom touchpoints and categories.

Chapter 10, User Assistance in Eclipse, demonstrates how to write help documentation for an Eclipse- or RCP-based product along with cheat sheets and running a public facing help server.

What you need for this book

To run the exercises in this book, you will need a computer with an up-to-date operating system (running Windows, Linux, or Mac OS X). Java also needs to be installed; the book's exercises were tested against JDK 1.7, but newer versions of Java should also work. The exercises were written and tested against both Eclipse Standard 4.4 (Luna) as well as 4.3 (Kepler). The principles should work for future versions of Eclipse as well, but note that each release of Eclipse has a migration guide in the Platform Plug-in Developer Guide help topic that will list any incompatibilities. This help information is also available online at http://help.eclipse.org/ for the current release.

The exercises are available on the Packt website as well as on GitHub at https://github.com/alblue/com.packtpub.e4.advanced/. Using the GitHub code will require a Git installation such as EGit for Eclipse (available from the Eclipse Marketplace) or a standalone Git client from http://git-scm.com/.

Who this book is for

This book is aimed at existing Eclipse plug-in developers who know the basics of plug-in development but want to learn some of the techniques in greater detail.

Developers wishing to write extensible plug-ins will find the advice in chapters 1 and 2 useful to integrate with some parts of the Eclipse framework that they may not have previously used.

Those that are unfamiliar with OSGi services or don't know how to integrate into Eclipse will find chapter 3 a good introduction, which is usually not covered in other Eclipse plug-in development books. Those wishing to extend the Gogo shell will find the information in chapter 4 beneficial, and chapter 5 will benefit those who need help in including native code dependencies. Developers who need to include non-OSGi JARs will find the techniques discussed in chapter 6 to be useful.

For those who are looking for advice on how to structure modular applications, the practices in chapters 7 and 8 will be beneficial.

Finally, for developers responsible for providing products, chapters 9 and 10 show how to customize and publish P2 repositories as well as provide user assistance (help) for applications.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "A cursor need to be closed to free the resource the object holds by calling the close() method."

A block of code is set as follows:

public void deleted(String pid) {
  System.out.println("Removing echo server with pid " + pid);
  EchoServer removed = echoServers.remove(pid);
  if (removed != null) {
    removed.stop();
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

      </goals>
   </execution>
   <execution>
      <id>baseline</id>
      <phase>package</phase>
      <goals>
        <goal>baseline</goal>
      </goals>
   </execution>
 </executions>
</plugin>

Any command-line input or output is written as follows:

$ mvn install
$ mvn versions:set -DnewVersion=1.0.1
... make changes to Java files ...
$ mvn package

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Clicking on Reset (to scan the directory) followed by Finish will set up the baseline."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. Alternatively, the code is available on GitHub at the book's repository https://github.com/alblue/com.packtpub.e4.advanced/.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.