Versions Compared

Key

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

...

Step 2 : Web page code

HomePage.java

Code Block
/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.example.reportincident;

import java.util.Iterator;
import org.apache.camel.example.reportincident.model.Incident;
import org.apache.camel.example.reportincident.service.IncidentService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.IDataProvider;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;

/**
 * Homepage
 */
public class HomePage extends WebPage {

	private static final long serialVersionUID = 1L;

	private static final transient Log LOG = LogFactory.getLog(HomePage.class);

	@SpringBean
	private IncidentService incidentService;

	/**
	 * Constructor that is invoked when page is invoked without a session.
	 * 
	 * @param parameters
	 *            Page parameters
	 */
	public HomePage(final PageParameters parameters) {

		LOG.debug("Spring service : " + incidentService.toString());

		// Add the simplest type of label
		add(new Label("message", "List of incidents coming from web services or file : "));

		// Add paging
		DataView dataView = new DataView("pageable", new IncidentProvider()) {

			@Override
			protected void populateItem(final Item item) {
				Incident incident = (Incident) item.getModelObject();
package org.apache.camel.example.reportincident;

import java.util.Iterator;
import org.apache.camel.example.reportincident.model.Incident;
import org.apache.camel.example.reportincident.service.IncidentService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.IDataProvider;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;

/**
 * Homepage
 */
public class HomePage extends WebPage {

	private static final long serialVersionUID = 1L;

	private static final transient Log LOG = LogFactory.getLog(HomePage.class);

	@SpringBean
	private IncidentService incidentService;

	/**
	 * Constructor that is invoked when page is invoked without a session.
	 * 
	 * @param parameters
	 *            Page parameters
	 */
	public HomePage(final PageParameters parameters) {

		LOG.debug("Spring service : " + incidentService.toString());

		// Add the simplest type of label
		add(new Label("message", "List of incidents coming from web services or file : "));

		// Add paging
		DataView dataView = new DataView("pageable", new IncidentProvider()) {

			@Override
			protected void populateItem(final Item item) {
				Incident incident = (Incident) item.getModelObject();
				item.add(new Label("incidentId", String.valueOf(incident
						.getIncidentId())));
				item.add(new Label("incidentDate", String.valueOf(incident
						.getIncidentDate())));
				item.add(new Label("incidentRef", incident.getIncidentRef()));
				item.add(new Label("givenName", incident.getGivenName()));
				item.add(new Label("familyName", incident.getFamilyName()));
				item.add(new Label("summary", incident.getSummary()));
				item.add(new Label("details", incident.getDetails()));
				item.add(new Label("email", incident.getEmail()));
				item.add(new Label("phone", incident.getPhone()));
				item.add(new Label("creationUser", incident.getCreationUser()));
				item.add(new Label("creationDate", String.valueOf(incident
						.getCreationDate())));

				item.add(new LabelAttributeModifier("incidentIdclass", String.valueOf(incidenttrue,
						.getIncidentIdnew AbstractReadOnlyModel()))); {
				item.add(new Label("incidentDate", String.valueOf(incident
			@Override
			.getIncidentDate())));
				item.add(new Label("incidentRef", incident.getIncidentRef()));public Object getObject() {
								return (item.add(new Label("givenName", incident.getGivenName()));
				item.add(new Label("familyName", incident.getFamilyName()));
				item.add(new Label("summary", incident.getSummary()));
				item.add(new Label("details", incident.getDetails()));
				item.add(new Label("email", incident.getEmail()));
				item.add(new Label("phone", incident.getPhone()));
				item.add(new Label("creationUser", incident.getCreationUser()));
				item.add(new Label("creationDate", String.valueOf(incident
						.getCreationDate())));

				item.add(new AttributeModifier("class", true,
						new AbstractReadOnlyModel() {
							@Override
							public Object getObjectgetIndex() % 2 == 1) ? "even"
										: "odd";
							}
						}));
			}
		};
		
        // dataView.setItemsPerPage(20);
        add(dataView);

        // add(new PagingNavigator("navigator", dataView));

	}

	private class IncidentProvider implements IDataProvider {

		public Iterator iterator(int first, int count) {
			return incidentService.findIncident().iterator();
		}

		public int size() {
			return incidentService.findIncident().size();
		}

		public IModel model(Object object) {
			return new Model((Incident) object);
		}

		public void detach() {
			// TODO Auto-generated method stub

		}
	}

		return (item.getIndex() % 2 == 1) ? "even"
										: "odd";
							}
						}private class IncidentDetachModel extends LoadableDetachableModel {

		private long id;

		@Override
		protected Object load() {
			return incidentService.findIncident(String.valueOf(id));
			}

		};/**
		
 * @param c
		 */
		public IncidentDetachModel(Incident   // dataView.setItemsPerPage(20);
        add(dataView);

        // add(new PagingNavigator("navigator", dataViewi) {
			this(i.getIncidentId());

		}

		privatepublic class IncidentProvider implements IDataProvider IncidentDetachModel(long id) {

		public Iterator	if iterator(intid first, int count== 0) {
			return incidentService.findIncident().iterator	throw new IllegalArgumentException();
			}

			publicthis.id int size() {
			return incidentService.findIncident().size()= id;
		}

		public IModel model(Object object) {
			return new Model((Incident) object);
		}

		public void detach() {
			// TODO Auto-generated method stub

		}
	}

	private class IncidentDetachModel extends LoadableDetachableModel {

		private long id;

		@Override
		protected Object load() {
			return incidentService.findIncident(String.valueOf(id));
		}

	}

}

WicketApplication.java

Code Block

package org.apache.camel.example.reportincident;

import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

/**
 * Application object for your web application. If you want to run this application without deploying, run the Start class.
 * 
 * @see org.apache.wicket.example.Start#main(String[])
 */
public class WicketApplication extends WebApplication
{    
	
	/**
		 * @param cInit
		 */
		public IncidentDetachModel(Incident i    public void init() {
			this(i.getIncidentId());
		}

		public IncidentDetachModel(long id) {

			if (id == 0) {
				throw new IllegalArgumentException();
			}
			this.id = id;
		}

	}

}

WicketApplication.java

Code Block

package org.apache.camel.example.reportincident;

import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

        super.init();
        addComponentInstantiationListener(new SpringComponentInjector(this));
    }

	
    /**
 * Application object for your* webConstructor
 application. If you want to run this application without deploying, run the Start class.
 * 
*/
	public WicketApplication()
	{
	}
	
	/**
	 * @see org.apache.wicket.example.Start#main(String[]Application#getHomePage()
	 */
	public class WicketApplication extends WebApplication
{    
	
	/**
	 * Init
	 */
    public void init() {
        super.init();
        addComponentInstantiationListener(new SpringComponentInjector(this));
    }

	
    /**
     * Constructor
     */
	public WicketApplication()
	{
	}
	
	/**
	 * @see org.apache.wicket.Application#getHomePage()
	 */
	public Class<HomePage> getHomePage()
	{
		return HomePage.class;
	}

}

Step 3 : web.xml configuration

Class<HomePage> getHomePage()
	{
		return HomePage.class;
	}

}

Step 3 : web.xml configuration

Code Block
xml
xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://
Code Block
xmlxml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_/web-app_2_4.xsd"
	version="2.4">

	<display-name>reportincident.web</display-name>

	<context-param>
		<param-name>contextClass</param-name>
		<param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<filter>
		<filter-name>camel.example.reportincident.web</filter-name>
		<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
		<init-param>
				<param-name>applicationClassName</param-name>
				<param-value>org.apache.camel.example.reportincident.WicketApplication</param-value>
				<param-name>applicationFactoryClassName</param-name>
				<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
    	</init-param>
	</filter>
	<filter-mapping>
		<filter-name>camel.example.reportincident.web</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>


</web-app>

Step 4 : Add spring stuffs

To allow our web bundle to have access to the osgi (1) service org.apache.camel.example.reportincident.service.IncidentService, we have to add the following line in the file called }} that we create in the directory {{.

Code Block
xml
xml

<?xml version="1.0"
Code Block
xmlxml

<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans.xsd
                    http://www.springframework.org/schema/osgi
                    http://www.springframework.org/schema/osgi/spring-osgi.xsd">
                    
 <osgi:reference id="incidentService" interface="org.apache.camel.example.reportincident.service.IncidentService"/> (1)
 
</beans>

Step 4 : Adapt the pom.xml file

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.apache.camel.example</groupId>
	<artifactId>reportincident.web</artifactId>
	<packaging>war</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>Report Incident Web Bundle</name>

	<properties>
		<wicket.version>1.3.5</wicket.version>
		<jetty.version>6.1.4</jetty.version>
		<felix-version>1.4.3</felix-version>
		<spring-version>2.5.6</spring-version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.apache.camel.example</groupId>
			<artifactId>reportincident.service</artifactId>
			<version>1.0-SNAPSHOT</version>
			<scope>provided</scope>
		</dependency>
		
		<!-- SPRING DEPENDENCIES -->
	    <dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring-version}</version>
			<scope>provided</scope>
		</dependency>
	    <dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring-version}</version>
			<scope>provided</scope>
		</dependency>
		<!-- 
	    <dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring-version}</version>
			<scope>provided</scope>
		</dependency>
		 -->
		<!--  WICKET DEPENDENCIES -->
		<dependency>
			<groupId>org.apache.wicket</groupId>
			<artifactId>wicket</artifactId>
			<version>${wicket.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.wicket</groupId>
			<artifactId>wicket-spring-annot</artifactId>
			<version>${wicket.version}</version>
			<scope>provided</scope>
		</dependency>
        <dependency>
            <groupId>org.apache.wicket</groupId>
			<artifactId>wicket-extensions</artifactId>
			<version>${wicket.version}</version>
			<scope>provided</scope>
		</dependency>

		<!-- LOGGING DEPENDENCIES - LOG4J -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.4.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.14</version>
			<scope>test</scope>
		</dependency>

		<!--  JUNIT DEPENDENCY FOR TESTING -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.2</version>
			<scope>test</scope>
		</dependency>

		<!--  JETTY DEPENDENCIES FOR TESTING  -->
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty</artifactId>
			<version>${jetty.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty-util</artifactId>
			<version>${jetty.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty-management</artifactId>
			<version>${jetty.version}</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>
	<build>
		<resources>
			<resource>
				<filtering>false</filtering>
				<directory>src/main/resources</directory>
			</resource>
			<resource>
				<filtering>false</filtering>
				<directory>src/main/java</directory>
				<includes>
					<include>**</include>
				</includes>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<filtering>false</filtering>
				<directory>src/test/java</directory>
				<includes>
					<include>**</include>
				</includes>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</testResource>
		</testResources>
		<plugins>

			<plugin>
				<inherited>true</inherited>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
					<optimise>true</optimise>
					<debug>true</debug>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>maven-jetty-plugin</artifactId>
			</plugin>


			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.1-alpha-2</version>
				<configuration>
					<archive>
						<!-- add the generated manifest to the war -->
						<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
					</archive>
					<!-- 
					<webResources>
						<resource>
							<directory>src/main/resources/META-INF/spring</directory>
							<targetPath>META-INF/spring</targetPath>
						</resource>
					</webResources>
					 -->
				</configuration>

			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<configuration>
					<downloadSources>true</downloadSources>
				</configuration>
			</plugin>

			<!-- to generate the MANIFEST-FILE required by the bundle -->
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>${felix-version}</version>
				<extensions>true</extensions>
				<executions>
					<execution>
						<id>bundle-manifest</id>
						<phase>process-classes</phase>
						<goals>
							<goal>manifest</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<supportedProjectTypes>
						<supportedProjectType>bundle</supportedProjectType>
						<supportedProjectType>war</supportedProjectType>
					</supportedProjectTypes>
					<instructions>
						<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
						<Bundle-ClassPath>
							.,
							WEB-INF/classes,
						</Bundle-ClassPath>
						<Import-Package>
							javax.servlet;version="[2.5.0, 3.0.0)",
							javax.servlet.http;version="[2.5.0, 3.0.0)",
							javax.servlet.resources;version="[2.5.0, 3.0.0)",
							org.apache.camel.example.reportincident.service,
							org.springframework.web.context;version="[2.5.6, 3.0.0)",
							org.springframework.web.context.support;version="[2.5.6, 3.0.0)",
							org.springframework.osgi.web.context.support,
							org.xml.sax;resolution:=optional,
							org.w3c.dom;resolution:=optional,
							*
						</Import-Package>
						<Private-Package>org.apache.camel.example.reportincident</Private-Package>
						<Export-Package></Export-Package>
						<Webapp-Context>reportincidentweb</Webapp-Context>
						<_failok>true</_failok>
					</instructions>
				</configuration>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.apache.camel.example</groupId>
	<artifactId>reportincident.web</artifactId>
	<packaging>war</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>Report Incident Web Bundle</name>

	<properties>
		<wicket.version>1.3.5</wicket.version>
		<jetty.version>6.1.4</jetty.version>
		<felix-version>1.4.3</felix-version>
		<spring-version>2.5.6</spring-version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.apache.camel.example</groupId>
			<artifactId>reportincident.service</artifactId>
			<version>1.0-SNAPSHOT</version>
			<scope>provided</scope>
		</dependency>
		
		<!-- SPRING DEPENDENCIES -->
	    <dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring-version}</version>
			<scope>provided</scope>
		</dependency>
	    <dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring-version}</version>
			<scope>provided</scope>
		</dependency>
		<!-- 
	    <dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring-version}</version>
			<scope>provided</scope>
		</dependency>
		 -->
		<!--  WICKET DEPENDENCIES -->
		<dependency>
			<groupId>org.apache.wicket</groupId>
			<artifactId>wicket</artifactId>
			<version>${wicket.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.wicket</groupId>
			<artifactId>wicket-spring-annot</artifactId>
			<version>${wicket.version}</version>
			<scope>provided</scope>
		</dependency>
        <dependency>
            <groupId>org.apache.wicket</groupId>
			<artifactId>wicket-extensions</artifactId>
			<version>${wicket.version}</version>
			<scope>provided</scope>
		</dependency>

		<!-- LOGGING DEPENDENCIES - LOG4J -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.4.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.14</version>
			<scope>test</scope>
		</dependency>

		<!--  JUNIT DEPENDENCY FOR TESTING -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.2</version>
			<scope>test</scope>
		</dependency>

		<!--  JETTY DEPENDENCIES FOR TESTING  -->
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty</artifactId>
			<version>${jetty.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty-util</artifactId>
			<version>${jetty.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty-management</artifactId>
			<version>${jetty.version}</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>
	<build>
		<resources>
			<resource>
				<filtering>false</filtering>
				<directory>src/main/resources</directory>
			</resource>
			<resource>
				<filtering>false</filtering>
				<directory>src/main/java</directory>
				<includes>
					<include>**</include>
				</includes>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<filtering>false</filtering>
				<directory>src/test/java</directory>
				<includes>
					<include>**</include>
				</includes>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</testResource>
		</testResources>
		<plugins>

			<plugin>
				<inherited>true</inherited>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
					<optimise>true</optimise>
					<debug>true</debug>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>maven-jetty-plugin</artifactId>
			</plugin>


			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.1-alpha-2</version>
				<configuration>
					<archive>
						<!-- add the generated manifest to the war -->
						<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
					</archive>
					<!-- 
					<webResources>
						<resource>
							<directory>src/main/resources/META-INF/spring</directory>
							<targetPath>META-INF/spring</targetPath>
						</resource>
					</webResources>
					 -->
				</configuration>

			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<configuration>
					<downloadSources>true</downloadSources>
				</configuration>
			</plugin>

			<!-- to generate the MANIFEST-FILE required by the bundle -->
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>${felix-version}</version>
				<extensions>true</extensions>
				<executions>
					<execution>
						<id>bundle-manifest</id>
						<phase>process-classes</phase>
						<goals>
							<goal>manifest</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<supportedProjectTypes>
						<supportedProjectType>bundle</supportedProjectType>
						<supportedProjectType>war</supportedProjectType>
					</supportedProjectTypes>
					<instructions>
						<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
						<Bundle-ClassPath>
							.,
							WEB-INF/classes,
						</Bundle-ClassPath>
						<Import-Package>
							javax.servlet;version="[2.5.0, 3.0.0)",
							javax.servlet.http;version="[2.5.0, 3.0.0)",
							javax.servlet.resources;version="[2.5.0, 3.0.0)",
							org.apache.camel.example.reportincident.service,
							org.springframework.web.context;version="[2.5.6, 3.0.0)",
							org.springframework.web.context.support;version="[2.5.6, 3.0.0)",
							org.springframework.osgi.web.context.support,
							org.xml.sax;resolution:=optional,
							org.w3c.dom;resolution:=optional,
							*
						</Import-Package>
						<Private-Package>org.apache.camel.example.reportincident</Private-Package>
						<Export-Package></Export-Package>
						<Webapp-Context>reportincidentweb</Webapp-Context>
						<_failok>true</_failok>
					</instructions>
				</configuration>

			</plugin>
		</plugins>
	</build>
</project>

Package the application

To simplify our deployment procedure, we will use the provisioning mechanism of Apache Servicemix called 'Feature'. In a feature xml file, we will define the bundles that we will package and their dependencies. The bundles can be linked to a feature and features can be linked together. This file will be packaged in a jar.

The advantage of the feature is that you avoid to deploy manually your bundles in your OSGI server and they can be versioned as you will see in the file. Moreover, the feature can be seen as a contract between your development and the deployment team. Different versions can be created according to the environment where the code will be deployed (development, acceptance and production).

Tip

If you prefer to generate automatically the file based on the dependencies of yours pom, then you can use the maven plugin maven-features-plugin

Create the file reportincident.features-1.0-SNAPSHOT-features.xml in the directory src/main of the project reportincident.features

Remarks :
(1) - The reportincident feature has the number version 1.0
(2) - Each feature is a collection of bundles or bundles/features. The bundle tag contains the URI syntax used by PAX URI to install the JAR or the resource on the OSGI server. We us the mvn protocol to download the jar from Maven repository but other protocols exist (see OPS4J for more info)
(3) - The camel feature include a list of camel-xx features.

Code Block
xml
xml

<?xml version="1.0" encoding="UTF-8"?>
<features>
	<feature name="reportincident" version="1.0"> (1)
		<bundle>mvn:org.apache.camel.example/reportincident.activemq/1.0-SNAPSHOT</bundle> (2)
		<bundle>mvn:org.apache.camel.example/reportincident.queueservice/1.0-SNAPSHOT</bundle>
		<bundle>mvn:org.apache.camel.example/reportincident.model/1.0-SNAPSHOT</bundle>
		<bundle>mvn:org.apache.camel.example/reportincident.persistence/1.0-SNAPSHOT</bundle>
		<bundle>mvn:org.apache.camel.example/reportincident.service/1.0-SNAPSHOT</bundle>
		<bundle>mvn:org.apache.camel.example/reportincident.webservice/1.0-SNAPSHOT</bundle>
		<bundle>mvn:org.apache.camel.example/reportincident.routing/1.0-SNAPSHOT</bundle>
                <bundle>mvn:org.apache.camel.example/reportincident.web/1.0-SNAPSHOT/war</bundle>
	</feature>
	
	<feature name="camel" version="2.0-M1">
		<feature>camel-core</feature> (3)
		<feature>camel-spring</feature>
		<feature>camel-osgi</feature>
		<feature>camel-bindy</feature>
		<feature>camel-jms</feature>
		<feature>camel-cxf</feature>
		<feature>camel-activemq</feature>
	</feature>

	<feature name="camel-core">
		<bundle>mvn:org.apache.camel/camel-core/2.0-M1</bundle>
	</feature>

	<feature name="camel-spring">
		<bundle>mvn:org.apache.camel/camel-spring/2.0-M1</bundle>
	</feature>

	<feature name="camel-osgi">
		<bundle>mvn:org.apache.camel/camel-osgi/2.0-M1</bundle>
	</feature>

	<feature name="camel-bindy">
		<bundle>mvn:org.apache.camel/camel-bindy/2.0-M1</bundle>
	</feature>
	
	<feature name="camel-mail">
	   <bundle>mvn:org.springframework/spring-context-support/2.5.5</bundle> 
       <bundle>mvn:org.apache.camel/camel-mail/2.0-M1</bundle>
	</feature>
	
    <feature name="camel-velocity">
       <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.velocity/1.5_1</bundle> 
       <bundle>mvn:org.apache.camel/camel-velocity/2.0-M1</bundle>
	</feature>

	<feature name="camel-jms">
        <bundle>mvn:org.springframework/spring-jms/2.5.6</bundle>	    
		<bundle>mvn:org.apache.camel/camel-jms/2.0-M1</bundle>
	</feature>

	<feature name="camel-activemq">
		<feature>activemq</feature>
		<bundle>mvn:org.apache.activemq/activemq-camel/5.2.0</bundle>
	</feature>

	<feature name="camel-cxf">
		<feature>cxf</feature>
		<bundle>mvn:org.apache.camel/camel-cxf/2.0-M1</bundle>
	</feature>
	
	<feature name="cxf-osgi">
		<bundle>mvn:org.apache.servicemix.cxf/org.apache.servicemix.cxf.transport.osgi/4.0.0</bundle>
	</feature>

	<feature name="cxf" version="2.2">
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.fastinfoset/1.2.2_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlsec/1.3.0_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j/1.5.4_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jetty-bundle/6.1.14_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlbeans/2.4.0_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlresolver/1.2_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlschema/1.4.2_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.7.0_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jdom/1.1_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.werken-xpath/0.9.4_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.neethi/2.0.4_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.abdera/0.4.0-incubating_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.junit/4.4_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/3.0.1_1</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io/1.3.2_1</bundle>
		<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.javamail-api-1.4/1.2.0</bundle>
		<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxws-api-2.1/1.2.0</bundle>
		<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.saaj-api-1.3/1.2.0</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.wsdl4j/1.6.1_1</bundle>
		<bundle>mvn:org.apache.geronimo.specs/geronimo-ws-metadata_2.0_spec/1.1.2</bundle>
		<bundle>mvn:org.apache.cxf/cxf-bundle/2.2</bundle>
	</feature>

	<feature name="web-core">
		<bundle>mvn:org.apache.geronimo.specs/geronimo-servlet_2.5_spec/1.1.2</bundle>
		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jetty-bundle/6.1.14_1</bundle>
	</feature>

	<feature name="web">
		<feature>web-core</feature>
		<bundle>mvn:org.ops4j.pax.web/pax-web-bundle/0.6.0</bundle>
		<bundle>mvn:org.ops4j.pax.web/pax-web-jsp/0.6.0</bundle>
		<bundle>mvn:org.ops4j.pax.web-extender/pax-web-ex-war/0.5.1</bundle>
		<bundle>mvn:org.ops4j.pax.web-extender/pax-web-ex-whiteboard/0.5.1</bundle>
		<bundle>mvn:org.ops4j.pax.url/pax-url-war/0.4.0</bundle>
		<bundle>mvn:org.apache.servicemix.war/org.apache.servicemix.war.deployer/4.0.0</bundle>
	</feature>
	
	<feature name="spring-web">
	    <bundle>mvn:org.springframework/spring-web/2.5.6</bundle>
        <bundle>mvn:org.springframework.osgi/spring-osgi-web/1.2.0-rc1</bundle> 
	</feature>
	
    <feature name="transaction">
        <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle>mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.5_spec/2.0.0</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.howl/1.0.1-1_1</bundle>
        <bundle>mvn:org.apache.geronimo.components/geronimo-transaction/2.2-r634076</bundle>
        <bundle>mvn:org.springframework/spring-tx/2.5.6</bundle>
        <bundle>mvn:org.apache.servicemix.transaction/org.apache.servicemix.transaction/1.0.0</bundle>
    </feature>
    
    <feature name="connector">
        <feature>transaction</feature>
        <bundle>mvn:org.apache.geronimo.components/geronimo-connector/2.2-r634076</bundle>
        <bundle>mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/1.1.1</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jencks/2.1_1</bundle>
    </feature>
    
    <feature name="common">
    	<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/2.1.6_1</bundle>
	<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/1.2.0</bundle>
	<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.1/1.2.0</bundle>
	<bundle>mvn:commons-collections/commons-collections/3.2.1</bundle>
	<bundle>mvn:commons-lang/commons-lang/2.4</bundle>
	<bundle>mvn:commons-pool/commons-pool/1.4</bundle>
	<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.asm/2.2.3_1</bundle>
    </feature>
    
    <feature name="activemq" version="5.2.0">
    	<feature>connector</feature>
    	<bundle>mvn:org.apache.geronimo.specs/geronimo-j2ee-management_1.1_spec/1.0.1</bundle>
    	<bundle>mvn:org.apache.xbean/xbean-spring/3.4.3</bundle>
	<bundle>mvn:org.apache.activemq/activemq-core/5.2.0</bundle>
	<bundle>mvn:org.apache.activemq/activemq-ra/5.2.0</bundle>
	<bundle>mvn:org.apache.activemq/activemq-console/5.2.0</bundle>
	<bundle>mvn:org.apache.activemq/activemq-pool/5.2.0</bundle>
	<bundle>mvn:org.apache.servicemix.activemq/org.apache.servicemix.activemq.commands/4.0.0</bundle>
    </feature>
    
    <feature name="hibernate">
        <bundle>mvn:org.springframework/spring-orm/2.5.6</bundle>
        <bundle>mvn:org.springframework/spring-jdbc/2.5.6</bundle>
    	<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6_2-SNAPSHOT</bundle>
    	<bundle>mvn:org.antlr/com.springsource.antlr/2.7.7</bundle>
    	<bundle>mvn:org.jgroups/com.springsource.org.jgroups/2.5.1</bundle>
    	<bundle>mvn:org.jboss.javassist/com.springsource.javassist/3.3.0.ga</bundle>
    	<bundle>mvn:org.hibernate/com.springsource.org.hibernate/3.3.1.GA</bundle>
    </feature>
    
    <feature name="jdbc-driver">
	<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/1.2.2_3</bundle>
    	<bundle>mvn:com.mysql.jdbc/com.springsource.com.mysql.jdbc/5.1.6</bundle>
    </feature>
    
    <feature name="wicket">
    	<bundle>mvn:org.apache.wicket/wicket/1.3.5</bundle>
    	<bundle>mvn:org.apache.wicket/wicket-ioc/1.3.5</bundle>
    	<bundle>mvn:org.apache.wicket/wicket-spring/1.3.5</bundle>
    	<bundle>mvn:org.apache.wicket/wicket-spring-annot/1.3.5</bundle>
    	<bundle>mvn:org.apache.wicket/wicket-extensions/1.3.5</bundle>
    </feature>
     
</features>

To generate the jar file containing the feature xml file, adapt the pom.xml like this :

Code Block
xml
xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.apache.camel.example</groupId>
	<artifactId>reportincident.features</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>Report Incident Project Features</name>

	<build>
		<resources>
			<!-- standard Maven folder -->
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.3</version>
				<executions>
					<execution>
						<phase>copy-resources</phase>
						<goals>
							<goal>resources</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

</project>

Package the application

To simplify our deployment procedure, we will use the provisioning mechanism of Apache Servicemix called 'Feature'. Using a feature file, we will define the bundles that we will package and their dependencies. This file will be packaged in a jar.

The advantage of the feature is that you avoid to deploy manually your bundles and they can be versioned as you will see in the file. Moreover, the feature can be seen as a contract between your development and the deployment team. Different versions can be created according to the environment where the code will be deployed (development, acceptance and production).

Tip

If you prefer to generate automatically the file based on the dependencies of yours pom, then you can use the maven plugin maven-features-plugin


During the execution of the maven command :

Code Block

mvn clean install

maven will put the file reportincident.features-1.0-SNAPSHOT-features.xml in the jar and the jar will be installed in your Maven local repository under the directory {{localMavenRepository/org/apache/camel/example/reportincident.features/1.0-SNAPSHOT

Deploy

The deployment process is very simple and two steps will be necessary :

Step 1 : Copy properties files in etc directory

Step 2 : Edit the file

...

Test it

Conclusion

TODO

...