Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
xml
xml
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:META-INF/server/symphonyCoreContextwinkCoreContext-server.xml
               classpath:mycontext.xml
  </param-value>
</context-param>
<listener>
  <listener-class>
    org.springframework.web.context.ContextLoaderListener
  </listener-class>
</listener>

Registering Resources and Providers

Apache Wink provides the comorg.hpapache.symphonywink.spring.Registrar class in order to register resources and providers through a Spring context. The Registrar class extends the SymphonyApplication WinkApplication class and must be registered as a singleton spring bean. It is possible to define multiple registrars in the same context. All registrars are automatically collected by the runtime and registered as SymphonyApplication WinkApplication objects during the context loading. The registrar provides the following properties:

...

  • priority - the priority of the SymphonyApplicationWinkApplication
Info
titleReference

For more information on Priorities refer to section 5.1 Registration and Configuration.

Code Block
xml
xml
<bean class="comorg.hpapache.symphonywink.spring.Registrar">
  <property name="classes">
    <set value-type="java.lang.Class">
      <value>package.className</value>
    </set>
  </property>
  <property name="instances">
    <set>
      <ref bean="resources.resource1" />
      <ref bean="resources.resource2" />
      <ref bean="providers.provider1" />
    </set>
  </property>
</bean>

...

Apache Wink provides a set of customizable properties. When working with Spring, the user developer should redefine the custom properties file using the Spring context:

Code Block
xml
xml
<bean id="customPropertiesFactory"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="locations">
    <list>
      <value>WEB-INF/configuration.properties</value>
    </list>
  </property>
</bean>
<bean id="customConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="ignoreUnresolvablePlaceholders" value="true" />
  <property name="order" value="1" />
  <property name="propertiesArray">
    <list>
      <props>
       <prop key="symphonywink.propertiesFactory">customPropertiesFactory</prop>
      </props>
    </list>
  </property>
</bean>

...

Code Block
xml
xml
<bean id="custom.MediaTypeMapper" class="comorg.hpapache.symphonywink.server.internal.MediaTypeMapper">
  <property name="mappings">
    <list>
      <map>
        <entry key="userAgentStartsWith" value="Mozilla/" />
        <entry key="resultMediaType">
          <util:constant static-field=" javax.ws.rs.core.MediaType.ATOM" />
        </entry>
        <entry key="typeToSend">
          <util:constant static-field="javax.ws.rs.core.MediaType.TEXT_XML" />
        </entry>
      </map>
    </list>
  </property>
</bean>
<bean id="customConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="ignoreUnresolvablePlaceholders" value="true" />
  <property name="order" value="1" />
  <property name="propertiesArray">
    <list>
      <props>
        <prop key="symphonywink.MediaTypeMapper">custom.MediaTypeMapper</prop>
      </props>
    </list>
  </property>
</bean>

...

Code Block
xml
xml
<bean id="custom.Shortcuts"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="locations">
    <list>
      <value>WEB-INF/shortcuts</value>
    </list>
  </property>
</bean>
<bean id="customConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="ignoreUnresolvablePlaceholders" value="true" />
  <property name="order" value="1" />
  <property name="propertiesArray">
    <list>
      <props>
        <prop key="symphonywink.alternateShortcutsMap">custom.Shortcuts</prop>
      </props>
    </list>
  </property>
</bean>

...