For OSGi deployments, you need to configure the servlet options and REST configuration in the blueprint.xml file; for example:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<service interface="javax.servlet.http.HttpServlet">
<service-properties>
<entry key="alias" value="/api-docs/*"/>
<entry key="init-prefix" value="init."/>
<entry key="init.base.path" value="//localhost:8080/"/>
<entry key="init.api.path" value="//localhost:8181/api-docs"/>
<entry key="init.api.title" value="Camel Rest Example API"/>
<entry key="init.api.version" value="1.2"/>
<entry key="init.api.description"
value="Camel Rest Example with Swagger that provides an User REST service"/>
</service-properties>
<bean class="org.apache.camel.component.swagger.DefaultCamelSwaggerServlet" />
</service>
<!--
The namespace for the camelContext element in Blueprint
is 'http://camel.apache.org/schema/blueprint'.
While it is not required to assign id's to the <camelContext/> and <route/> elements,
it is a good idea to set those for runtime management purposes (logging, JMX MBeans, ...)
-->
<camelContext id="log-example-context"
xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="jetty" port="8080"/>
<rest path="/say">
<get uri="/hello">
<to uri="direct:hello"/>
</get>
<get uri="/bye" consumes="application/json">
<to uri="direct:bye"/>
</get>
<post uri="/bye">
<to uri="mock:update"/>
</post>
</rest>
<route id="rte1-log-example">
<from uri="direct:hello"/>
<transform>
<constant>Hello World</constant>
</transform>
</route>
<route id="rte2-log-example">
<from uri="direct:bye"/>
<transform>
<constant>Bye World</constant>
</transform>
</route>
</camelContext>
</blueprint>
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<service interface="javax.servlet.http.HttpServlet">
<service-properties>
<entry key="alias" value="/api-docs/*"/>
<entry key="init-prefix" value="init."/>
<entry key="init.base.path" value="//localhost:8080/"/>
<entry key="init.api.path" value="//localhost:8181/api-docs"/>
<entry key="init.api.title" value="Camel Rest Example API"/>
<entry key="init.api.version" value="1.2"/>
<entry key="init.api.description"
value="Camel Rest Example with Swagger that provides an User REST service"/>
</service-properties>
<bean class="org.apache.camel.component.swagger.DefaultCamelSwaggerServlet" />
</service>
<!--
The namespace for the camelContext element in Blueprint
is 'http://camel.apache.org/schema/blueprint'.
While it is not required to assign id's to the <camelContext/> and <route/> elements,
it is a good idea to set those for runtime management purposes (logging, JMX MBeans, ...)
-->
<camelContext id="log-example-context"
xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="jetty" port="8080"/>
<rest path="/say">
<get uri="/hello">
<to uri="direct:hello"/>
</get>
<get uri="/bye" consumes="application/json">
<to uri="direct:bye"/>
</get>
<post uri="/bye">
<to uri="mock:update"/>
</post>
</rest>
<route id="rte1-log-example">
<from uri="direct:hello"/>
<transform>
<constant>Hello World</constant>
</transform>
</route>
<route id="rte2-log-example">
<from uri="direct:bye"/>
<transform>
<constant>Bye World</constant>
</transform>
</route>
</camelContext>
</blueprint>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
service
The service element exposes the camel swagger servlet (<bean class="org.apache.camel.component.swagger.DefaultCamelSwaggerServlet"/>) and initializes several servlet properties.
alias
The alias property binds the camel swagger servlet to /api-docs/*.
init-prefix
The init-prefix property sets the prefix for all camel swagger servlet properties to init.. This is analogous to using init-param elements in the web.xml configuration in WAR implementations.
restConfiguration
In the camelContext, the restConfiguration element specifies Jetty as the web servlet on port 8080.
rest
In the camelContext, the rest element sets two REST endpoints and routes them to the camel endpoints defined in the following two route elements.
Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.
Hacer que el código abierto sea más inclusivo
Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.
Acerca de Red Hat
Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.