Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Preface

This document contains prerequisite configuration for web applications (including portlets) to use the Resource Server.

Dependencies

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

<dependency>
  <groupId>org.jasig.resourceserver</groupId>
  <artifactId>resource-server-utils</artifactId>
  <version>1.0.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).

Configuration

The Context for your web application will need to have "cross context dispatching" enabled.

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:

<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:

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

Embedding a resource in your content:

<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

<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.

<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.

  • No labels