Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

OK.. so far we have added a new type of module (in this case JBI) and defined a server that is capable of handling it.

We could start up Eclipse with our plugins in place and we should start seeing some results! Note that the runtime settings are being requested by the server definition (ie. the location of our ServiceMix installation).

However, what we now what is to be able to create a project which can interact with both our server and runtime definitions. This means be able to reference the runtime when creating the project and also leverage the WTP publish/deploy architecture so that we can publish our project to a runtime.  In order to do this we need to create a new type of Facet, facet's are basically a way to introduce functionality to projects in Eclipse, therefore a project can have one or more facets (ie. it could be a Java project and a EJB project).

Lets look at the project facet definition from our core JBI plugin.

Code Block
xml
xml
       <extension
		point="org.eclipse.wst.common.project.facet.core.facets">
		<project-facet id="jst.jbi.component">
			<label>%jbi.component.facet.label</label>
			<description>
				%jbi.component.facet.description
			</description>
			<icon>icons/jbi-component.gif</icon>
		</project-facet>
		<project-facet-version facet="jst.jbi.component"
			version="1.0">			
			<constraint>
	        <and>
	          <requires facet="jst.java" version="[1.4"/>
	        </and>
	        <conflicts group="modules"/>
	      </constraint>
	      <group-member id="modules"/>
		</project-facet-version>
		<action facet="jst.jbi.component" version="1.0" type="install">
			<delegate
					class="org.eclipse.jst.jbi.ui.project.facet.JbiFacetInstallDelegate" />
			<config-factory
					class="org.eclipse.jst.jbi.internal.project.operations.JbiFacetInstallDataModelProvider" />
		</action>
		<template id="template.jst.jbi.component">
			<label>%jbi.component.facet.label</label>			
			<fixed facet="jst.java"/>
	      	<fixed facet="jst.jbi.component"/>
		</template>
	</extension>

As we can see we basically introduce a facet called jst.jbi.component. In the definition we can give a little information about the type of requirements this facet would have, in this case we need a version of the Java facet equal to or greater than 1.4 (since JBI has that requirement). Also important is the concept of building delegates and config factories in order to allow the facet to have information gathered that it needs in a model (represented in the config-factory) and a delegate that is responsible for installing any requirements into the project for this facet.

Also note that we provide a template, this can be used in the wizard to show the default facets, in our case we wanted only that the java facet be there.