Versions Compared

Key

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

...

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 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 objects during the context loading. The registrar provides the following properties:

...

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>

...

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="symphony.MediaTypeMapper">custom.MediaTypeMapper</prop>
      </props>
    </list>
  </property>
</bean>

...