restlet-2.0.14/ 0000775 0001750 0001750 00000000000 12001473210 013722 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/ 0000775 0001750 0001750 00000000000 12001473202 020273 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/pom.xml 0000600 0001750 0001750 00000004115 12001473201 021576 0 ustar jamespage jamespage
4.0.0
org.restlet.jse
org.restlet.parent
2.0.14
org.restlet.ext.spring
Restlet Extension - Spring Framework
Integration with Spring Framework.
cglib
cglib-nodep
2.2
commons-logging
commons-logging
1.1.1
org.springframework
spring-asm
3.0.1.RELEASE
org.springframework
spring-beans
3.0.1.RELEASE
org.springframework
spring-context
3.0.1.RELEASE
org.springframework
spring-core
3.0.1.RELEASE
org.springframework
spring-expression
3.0.1.RELEASE
org.springframework
spring-web
3.0.1.RELEASE
org.springframework
spring-webmvc
3.0.1.RELEASE
org.restlet.jse
org.restlet
2.0.14
restlet-2.0.14/org.restlet.ext.spring/src/ 0000775 0001750 0001750 00000000000 12001473201 021061 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/src/META-INF/ 0000775 0001750 0001750 00000000000 11757206452 022244 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/src/META-INF/MANIFEST.MF 0000664 0001750 0001750 00000000146 11757206450 023675 0 ustar jamespage jamespage Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 20.6-b01 (Sun Microsystems Inc.)
restlet-2.0.14/org.restlet.ext.spring/src/org/ 0000775 0001750 0001750 00000000000 11757206352 021672 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/src/org/restlet/ 0000775 0001750 0001750 00000000000 11757206352 023354 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/src/org/restlet/ext/ 0000775 0001750 0001750 00000000000 11757206352 024154 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/src/org/restlet/ext/spring/ 0000775 0001750 0001750 00000000000 11757206352 025456 5 ustar jamespage jamespage restlet-2.0.14/org.restlet.ext.spring/src/org/restlet/ext/spring/SpringResource.java 0000664 0001750 0001750 00000010264 11757206352 031276 0 ustar jamespage jamespage /**
* Copyright 2005-2012 Restlet S.A.S.
*
* The contents of this file are subject to the terms of one of the following
* open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL
* 1.0 (the "Licenses"). You can select the license that you prefer but you may
* not use this file except in compliance with one of these Licenses.
*
* You can obtain a copy of the Apache 2.0 license at
* http://www.opensource.org/licenses/apache-2.0
*
* You can obtain a copy of the LGPL 3.0 license at
* http://www.opensource.org/licenses/lgpl-3.0
*
* You can obtain a copy of the LGPL 2.1 license at
* http://www.opensource.org/licenses/lgpl-2.1
*
* You can obtain a copy of the CDDL 1.0 license at
* http://www.opensource.org/licenses/cddl1
*
* You can obtain a copy of the EPL 1.0 license at
* http://www.opensource.org/licenses/eclipse-1.0
*
* See the Licenses for the specific language governing permissions and
* limitations under the Licenses.
*
* Alternatively, you can obtain a royalty free commercial license with less
* limitations, transferable or non-transferable, directly at
* http://www.restlet.com/products/restlet-framework
*
* Restlet is a registered trademark of Restlet S.A.S.
*/
package org.restlet.ext.spring;
import java.io.IOException;
import java.io.InputStream;
import org.restlet.representation.Representation;
import org.springframework.core.io.AbstractResource;
/**
* Spring Resource based on a Restlet Representation. DON'T GET CONFUSED,
* Spring's notion of Resource is different from Restlet's one, actually it's
* closer to Restlet's Representations.
*
* @see Spring home page
* @author Jerome Louvel
*/
public class SpringResource extends AbstractResource {
/** The description. */
private final String description;
/** Indicates if the representation has already been read. */
private volatile boolean read = false;
/** The wrapped representation. */
private final Representation representation;
/**
* Constructor.
*
* @param representation
* The description.
*/
public SpringResource(Representation representation) {
this(representation, "Restlet Representation");
}
/**
* Constructor.
*
* @param representation
* The description.
* @param description
* The description.
*/
public SpringResource(Representation representation, String description) {
if (representation == null) {
throw new IllegalArgumentException(
"Representation must not be null");
}
this.representation = representation;
this.description = (description != null) ? description : "";
}
/**
* This implementation compares the underlying InputStream.
*/
@Override
public boolean equals(Object obj) {
return ((obj == this) || ((obj instanceof SpringResource) && ((SpringResource) obj).representation
.equals(this.representation)));
}
/**
* This implementation always returns true
.
*/
@Override
public boolean exists() {
return true;
}
/**
* Returns the description.
*
* @return The description.
*/
public String getDescription() {
return this.description;
}
/**
* This implementation throws IllegalStateException if attempting to read
* the underlying stream multiple times.
*/
public InputStream getInputStream() throws IOException,
IllegalStateException {
if (this.read && this.representation.isTransient()) {
throw new IllegalStateException(
"Representation has already been read and is transient.");
}
this.read = true;
return this.representation.getStream();
}
/**
* This implementation returns the hash code of the underlying InputStream.
*/
@Override
public int hashCode() {
return this.representation.hashCode();
}
/**
* This implementation always returns true
.
*/
@Override
public boolean isOpen() {
return true;
}
}
restlet-2.0.14/org.restlet.ext.spring/src/org/restlet/ext/spring/SpringHost.java 0000664 0001750 0001750 00000007244 11757206352 030430 0 ustar jamespage jamespage /**
* Copyright 2005-2012 Restlet S.A.S.
*
* The contents of this file are subject to the terms of one of the following
* open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL
* 1.0 (the "Licenses"). You can select the license that you prefer but you may
* not use this file except in compliance with one of these Licenses.
*
* You can obtain a copy of the Apache 2.0 license at
* http://www.opensource.org/licenses/apache-2.0
*
* You can obtain a copy of the LGPL 3.0 license at
* http://www.opensource.org/licenses/lgpl-3.0
*
* You can obtain a copy of the LGPL 2.1 license at
* http://www.opensource.org/licenses/lgpl-2.1
*
* You can obtain a copy of the CDDL 1.0 license at
* http://www.opensource.org/licenses/cddl1
*
* You can obtain a copy of the EPL 1.0 license at
* http://www.opensource.org/licenses/eclipse-1.0
*
* See the Licenses for the specific language governing permissions and
* limitations under the Licenses.
*
* Alternatively, you can obtain a royalty free commercial license with less
* limitations, transferable or non-transferable, directly at
* http://www.restlet.com/products/restlet-framework
*
* Restlet is a registered trademark of Restlet S.A.S.
*/
package org.restlet.ext.spring;
import java.util.Map;
import org.restlet.Component;
import org.restlet.Context;
import org.restlet.resource.ServerResource;
import org.restlet.routing.VirtualHost;
/**
* Virtual host that is easily configurable with Spring. Here is a usage
* example:
*
*
* <bean id="virtualHost" class="org.restlet.ext.spring.SpringHost">
* <constructor-arg ref="component" />
* <property name="hostDomain"
* value="mydomain.com|www.mydomain.com" />
* <property name="attachments">
* <map>
* <entry key="/">
* <ref bean="application" />
* </entry>
* </map>
* </property>
* </bean>
*
*
* Concurrency note: instances of this class or its subclasses can be invoked by
* several threads at the same time and therefore must be thread-safe. You
* should be especially careful when storing state in member variables.
*
* @see Spring home page
* @author Jerome Louvel
*/
public class SpringHost extends VirtualHost {
/**
* Constructor.
*
* @param component
* The parent component.
*/
public SpringHost(Component component) {
super(component.getContext());
}
/**
* Constructor.
*
* @param context
* The parent context.
*/
public SpringHost(Context context) {
super(context);
}
/**
* Sets the map of routes to attach. The map keys are the URI templates and
* the values can be either Restlet instances, {@link ServerResource}
* subclasses (as {@link Class} instances or as qualified class names).
*
* @param routes
* The map of routes to attach.
*/
public void setAttachments(Map routes) {
SpringRouter.setAttachments(this, routes);
}
/**
* Sets the default route to attach. The route can be either Restlet
* instances, {@link ServerResource} subclasses (as {@link Class} instances
* or as qualified class names).
*
* @param route
* The default route to attach.
*/
public void setDefaultAttachment(Object route) {
SpringRouter.setAttachment(this, "", route);
}
}
restlet-2.0.14/org.restlet.ext.spring/src/org/restlet/ext/spring/SpringFinder.java 0000664 0001750 0001750 00000014764 11757206352 030727 0 ustar jamespage jamespage /**
* Copyright 2005-2012 Restlet S.A.S.
*
* The contents of this file are subject to the terms of one of the following
* open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL
* 1.0 (the "Licenses"). You can select the license that you prefer but you may
* not use this file except in compliance with one of these Licenses.
*
* You can obtain a copy of the Apache 2.0 license at
* http://www.opensource.org/licenses/apache-2.0
*
* You can obtain a copy of the LGPL 3.0 license at
* http://www.opensource.org/licenses/lgpl-3.0
*
* You can obtain a copy of the LGPL 2.1 license at
* http://www.opensource.org/licenses/lgpl-2.1
*
* You can obtain a copy of the CDDL 1.0 license at
* http://www.opensource.org/licenses/cddl1
*
* You can obtain a copy of the EPL 1.0 license at
* http://www.opensource.org/licenses/eclipse-1.0
*
* See the Licenses for the specific language governing permissions and
* limitations under the Licenses.
*
* Alternatively, you can obtain a royalty free commercial license with less
* limitations, transferable or non-transferable, directly at
* http://www.restlet.com/products/restlet-framework
*
* Restlet is a registered trademark of Restlet S.A.S.
*/
package org.restlet.ext.spring;
import java.util.logging.Level;
import org.restlet.Context;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.Restlet;
import org.restlet.resource.Finder;
import org.restlet.resource.ServerResource;
/**
* Finder that is specialized for easier usage by Spring wiring services. The
* idea is to create a singleton Spring bean based on that SpringFinder and
* configure it using Spring's "lookup-method" element to return instances of a
* "prototype" bean for {@link #create()}. Finally, attach the SpringFinder to
* your Router. When the {@link #create()} method is invoked, a new instance of
* your prototype bean will be created and returned. A sample XML for
* "lookup-method":
*
*
* <bean id="myFinder" class="org.restlet.ext.spring.SpringFinder">
* <lookup-method name="create" bean="myResource"/>
* </bean>
*
* <bean id="myResource" class="com.mycompany.rest.resource.MyResource" scope="prototype">
* <property name="aProperty" value="anotherOne"/>
* <property name="oneMore" value="true"/>
* </bean>
*
*
* Note that the Code Generation
* Library (cglib) will be required in order to use the Spring's lookup
* method mechanism.
*
* Concurrency note: instances of this class or its subclasses can be invoked by
* several threads at the same time and therefore must be thread-safe. You
* should be especially careful when storing state in member variables.
*
* @see Spring home page
* @author Jerome Louvel
*/
public class SpringFinder extends Finder {
/**
* Constructor.
*/
public SpringFinder() {
super();
}
/**
* Constructor.
*
* @param context
* The parent context.
*/
public SpringFinder(Context context) {
super(context);
}
/**
* Constructor.
*
* @param context
* The context.
* @param targetClass
* The target resource class.
*/
public SpringFinder(Context context, Class> targetClass) {
super(context, targetClass);
}
/**
* Constructor.
*
* @param restlet
* The parent Restlet.
*/
public SpringFinder(Restlet restlet) {
super(restlet.getContext());
}
/**
* Creates a new instance of the {@link ServerResource} class designated by
* the "targetClass" property. This method is intended to be configured as a
* lookup method in Spring.
*
* @return The created resource or null.
*/
public ServerResource create() {
ServerResource result = null;
if (getTargetClass() != null) {
try {
// Invoke the default constructor
result = (ServerResource) getTargetClass().newInstance();
} catch (Exception e) {
getLogger()
.log(
Level.WARNING,
"Exception while instantiating the target server resource.",
e);
}
}
return result;
}
/**
* Calls the {@link #create()} method that can be configured as a lookup
* method in Spring.
*/
@Override
public ServerResource create(Class extends ServerResource> targetClass,
Request request, Response response) {
return create(request, response);
}
@Override
public org.restlet.resource.ServerResource create(Request request,
Response response) {
return create();
}
/**
* Creates a new instance of the resource class designated by the
* "targetClass" property. For easier Spring configuration, the default
* target resource's constructor is invoked. The created instance must be
* initialized by invoking the
* {@link org.restlet.resource.Resource#init(Context, Request, Response)}
* method on the resource.
*
* @return The created resource or null.
*/
@SuppressWarnings("deprecation")
public org.restlet.resource.Resource createResource() {
org.restlet.resource.Resource result = null;
if (getTargetClass() != null) {
try {
// Invoke the default constructor
result = (org.restlet.resource.Resource) getTargetClass()
.newInstance();
} catch (Exception e) {
getLogger()
.log(
Level.WARNING,
"Exception while instantiating the target resource.",
e);
}
}
return result;
}
@SuppressWarnings("deprecation")
@Override
public org.restlet.resource.Resource createTarget(Request request,
Response response) {
org.restlet.resource.Resource result = createResource();
if (result != null) {
result.init(getContext(), request, response);
}
return result;
}
}
restlet-2.0.14/org.restlet.ext.spring/src/org/restlet/ext/spring/package.html 0000664 0001750 0001750 00000000243 11757206352 027736 0 ustar jamespage jamespage
Integration with Spring Framework 3.0.
@since Restlet 1.0
@see Spring Framework