Configuration files

Markus Sabadello edited this page Feb 6, 2017 · 28 revisions

XDI2

Clone this wiki locally

The XDI2 server uses the following configuration files:

applicationContext.xml

This is the main configuration file of the XDI2 server.

Its purpose is to "mount" messaging containers and messaging container factories at the specified URLs, where they are exposed as XDI endpoints that can receive and process incoming XDI messages.

Its basic structure is as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">

	<!-- XDI ENDPOINT REGISTRY AND TRANSPORT -->

	<bean id="UriMessagingContainerRegistry" class="xdi2.transport.registry.impl.uri.UriMessagingContainerRegistry" init-method="init" destroy-method="shutdown" />

	<bean id="HttpTransport" class="xdi2.transport.impl.http.HttpTransport" init-method="init" destroy-method="shutdown">
		<property name="uriMessagingContainerRegistry" ref="UriMessagingContainerRegistry" />
		<property name="interceptors">
			<util:list>
				<bean class="xdi2.transport.impl.http.interceptor.impl.DebugHttpTransportInterceptor" />
				<bean class="xdi2.transport.impl.http.interceptor.impl.StatusHttpTransportInterceptor" />
			</util:list>
		</property>
	</bean>

	<bean id="WebSocketTransport" class="xdi2.transport.impl.websocket.WebSocketTransport" init-method="init" destroy-method="shutdown">
		<property name="uriMessagingContainerRegistry" ref="UriMessagingContainerRegistry" />
		<property name="endpointPath" value="/xdi/" />
	</bean>

	<!-- SPRING -->

	<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
		<property name="converters">
			<list>
				<bean class="xdi2.transport.spring.XDI2SpringConverter" />
			</list>
		</property>
	</bean>

	<!-- CONFIGURE MESSAGING TARGETS AND MESSAGING TARGET FACTORIES HERE -->

</beans>

For more information, see:

WEB-INF/web.xml

This configuration file is used if the server is started as a web application (see Startup and shutdown). It should look as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">

	<display-name>xdi2-transport-http</display-name>
	
	<!-- XDI SERVLET -->

	<servlet>
		<servlet-name>EndpointServlet</servlet-name>
		<servlet-class>xdi2.transport.impl.http.impl.servlet.EndpointServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>EndpointServlet</servlet-name>
		<url-pattern>/*</url-pattern>
		<url-pattern>/</url-pattern>
	</servlet-mapping>

	<!-- LISTENERS -->

	<listener>
		<listener-class>xdi2.transport.impl.http.impl.servlet.PluginsLoaderListener</listener-class>
	</listener>

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

	<listener>
		<listener-class>xdi2.transport.impl.websocket.impl.listener.WebSocketsListener</listener-class>
	</listener>

</web-app>

The "root path" of the server may be modified by adjusting the <url-pattern /> as necessary.

Other than that, no change to this file should be necessary under normal circumstances.

server-applicationContext.xml

This configuration file is used if the server is started in standalone or embedded mode (see Startup and shutdown). It should look as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">

	<bean id="servletHolder" class="org.eclipse.jetty.servlet.ServletHolder">
		<property name="servlet" ref="EndpointServlet" />
		<property name="name" value="EndpointServlet" />
	</bean>

	<bean id="servletMapping" class="org.eclipse.jetty.servlet.ServletMapping">
		<property name="servletName" value="EndpointServlet" />
		<property name="pathSpec" value="/xdi/*" />
	</bean>

	<bean id="servletHandler" class="org.eclipse.jetty.servlet.ServletHandler">
		<property name="servlets" ref="servletHolder" />
		<property name="servletMappings" ref="servletMapping" />
	</bean>

	<bean id="servletContextHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">
		<property name="servletHandler" ref="servletHandler" />
		<property name="contextPath" value="/" />
	</bean>

	<bean id="server" class="org.eclipse.jetty.server.Server">
		<property name="connectors">
			<util:list>
				<bean id="Connector" class="org.eclipse.jetty.server.nio.NetworkTrafficSelectChannelConnector">
					<constructor-arg ref="server" />
					<property name="port" value="8080" />
				</bean>
			</util:list>
		</property>
		<property name="handler" ref="servletContextHandler" />
	</bean>

	<bean id="XDIStandaloneServer" class="xdi2.server.impl.standalone.XDIStandaloneServer">
		<property name="server" ref="server" />
		<property name="endpointServlet" ref="EndpointServlet" />
	</bean>

	<bean id="EndpointServlet" class="xdi2.transport.impl.http.impl.servlet.EndpointServlet" init-method="init" destroy-method="destroy" />

</beans>