Versions Compared

Key

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

...

If your web application is a maven project, simply add the following dependency to your pom:

No Formatcode
xml
xml
<dependency>
  <groupId>org.jasig.resourceserver</groupId>
  <artifactId>resource-server-utils</artifactId>
  <version>1.0.9<14</version>
</dependency>

If your web application is not a maven project, you will need to include the resource-server-utils jar in your application's classpath (for example, in WEB-INF/lib).

...

This is enabled for an application deployed in tomcat by creating a META-INF directory including a file named "context.xml" with simply the following contents:

Code Block
xml
xml
<Context crossContext="true"/>

If your web application is a maven project, this directory will need to be created using the path 'src/main/webapp/META-INF'.

Example Usage

Declaring the resource server taglib in a JSP:

Code Block
xml
xml
<%@ taglib prefix="rs" uri="http://www.jasig.org/resource-server" %>

Embedding a resource in your content:

Code Block
xml
xml
<rs:resourceURL var="starIcon" value="/rs/famfamfam/silk/1.3/star.png"/>
<img src="${starIcon}" alt="A Star" title="A Star"/>

Fallback Support

If your web application could be deployed in a situation where the Resource Server is not available or an older version is available that does not contain your resource Maven WAR Overlay support can be used to provide a fall back version of the resource file.

First add the following dependency. This is a WAR file that only contains the content provided by the Resource Server

Code Block
xml
xml

<dependency>
    <groupId>org.jasig.resourceserver</groupId>
    <artifactId>resource-server-content</artifactId>
    <version>1.1.4</version>
    <type>war</type>
</dependency>

Second in the build section of the pom add the maven-war-plugin and explicitly include each resource path for the resources your web application uses.

Code Block
xml
xml

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <overlays>
                    <overlay>
                        <groupId>org.jasig.resourceserver</groupId>
                        <artifactId>resource-server-content</artifactId>
                        <includes>
                            <include>rs/jquery/1.4.2/</include>
                            <include>rs/jqueryui/1.8/</include>
                            <include>rs/famfamfam/silk/1.3/</include>
                        </includes>
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
    </plugins>
</build>

You're all set. Now same resources that are available in the Resource Server are available in your web application. If possible the Resource Server versions will be used, this is better for shared caching in the user's browser, but if the Resource Server is not available for any reason your application will still function correctly.