marked stateless objects as Singleton

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2015 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-10-31 00:48:49 +00:00
parent 16e3526430
commit bcd1c2343a
46 changed files with 127 additions and 2 deletions

View File

@ -95,4 +95,13 @@ public interface AtmosStorageClient {
@ExceptionParser(ThrowKeyNotFoundOn404.class)
@Path("/rest/namespace/{path}")
Future<AtmosObject> readFile(@PathParam("path") String path, GetOptions... options);
// signature currently doesn't work
// @POST
// @QueryParams(keys = "acl")
// @Headers(keys = { "x-emc-useracl", "x-emc-groupacl" }, values = { "root=FULL_CONTROL",
// "other=READ" })
// @Consumes(MediaType.WILDCARD)
// void makePublic(@Endpoint URI url);
}

View File

@ -1,5 +1,7 @@
package org.jclouds.atmosonline.saas.functions;
import javax.inject.Singleton;
import org.jclouds.atmosonline.saas.domain.AtmosObject;
import com.google.common.base.Function;
@ -8,6 +10,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class AtmosObjectName implements Function<Object, String> {
public String apply(Object in) {

View File

@ -1,6 +1,7 @@
package org.jclouds.atmosonline.saas.functions;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import org.jclouds.atmosonline.saas.domain.AtmosObject;
@ -16,6 +17,7 @@ import com.google.common.base.Function;
* @see ParseMetadataFromHeaders
* @author Adrian Cole
*/
@Singleton
public class ParseObjectFromHeadersAndHttpContent implements Function<HttpResponse, AtmosObject> {
private final ParseSystemMetadataFromHeaders systemMetadataParser;

View File

@ -28,6 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.atmosonline.saas.domain.FileType;
import org.jclouds.atmosonline.saas.domain.SystemMetadata;
@ -41,6 +42,7 @@ import com.google.common.collect.Maps;
/**
* @author Adrian Cole
*/
@Singleton
public class ParseSystemMetadataFromHeaders implements Function<HttpResponse, SystemMetadata> {
private final DateService dateService;

View File

@ -28,6 +28,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.atmosonline.saas.domain.UserMetadata;
import org.jclouds.atmosonline.saas.reference.AtmosStorageHeaders;
import org.jclouds.http.HttpResponse;
@ -40,6 +42,7 @@ import com.google.inject.internal.ImmutableSet;
/**
* @author Adrian Cole
*/
@Singleton
public class ParseUserMetadataFromHeaders implements Function<HttpResponse, UserMetadata> {
private final Set<String> sysKeys = ImmutableSet.of("atime", "ctime", "gid", "itime", "mtime",
"nlink", "policyname", "size", "uid");

View File

@ -126,5 +126,6 @@ public class AtmosStorageClientLiveTest {
} catch (IOException e) {
}
}
}

View File

@ -25,12 +25,16 @@ package org.jclouds.blobstore.functions;
import java.lang.reflect.Constructor;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.blobstore.ContainerNotFoundException;
import org.jclouds.blobstore.KeyNotFoundException;
import org.jclouds.http.functions.ReturnTrueOn404;
import com.google.common.base.Function;
@Singleton
public class ReturnVoidOnNotFoundOr404 implements Function<Exception, Void> {
static final Void v;
@ -45,7 +49,12 @@ public class ReturnVoidOnNotFoundOr404 implements Function<Exception, Void> {
}
}
ReturnTrueOn404 rto404 = new ReturnTrueOn404();
private final ReturnTrueOn404 rto404;
@Inject
private ReturnVoidOnNotFoundOr404(ReturnTrueOn404 rto404) {
this.rto404 = rto404;
}
public Void apply(Exception from) {
if (from instanceof KeyNotFoundException || from instanceof ContainerNotFoundException) {

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.blobstore.functions.impl;
import javax.inject.Singleton;
import org.jclouds.blobstore.functions.GenerateMD5;
import org.jclouds.http.HttpUtils;
@ -30,6 +32,7 @@ import org.jclouds.http.HttpUtils;
*
* @author Adrian Cole
*/
@Singleton
public class BouncyCastleGenerateMD5 implements GenerateMD5 {
public byte[] apply(Object from) {

View File

@ -26,6 +26,8 @@ package org.jclouds.blobstore.functions.impl;
import java.io.IOException;
import java.io.InputStream;
import javax.inject.Singleton;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.bouncycastle.crypto.digests.MD5Digest;
@ -37,6 +39,7 @@ import org.jclouds.blobstore.internal.BlobRuntimeException;
*
* @author Adrian Cole
*/
@Singleton
public class BouncyCastleGenerateMD5Result implements GenerateMD5Result {
public MD5InputStreamResult apply(InputStream toEncode) {
MD5Digest eTag = new MD5Digest();

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.blobstore.functions.impl;
import javax.inject.Singleton;
import org.jclouds.blobstore.functions.CalculateSize;
import org.jclouds.http.HttpUtils;
@ -30,6 +32,7 @@ import org.jclouds.http.HttpUtils;
*
* @author Adrian Cole
*/
@Singleton
public class CalculateSizeByLength implements CalculateSize {
public Long apply(Object from) {

View File

@ -24,6 +24,7 @@
package org.jclouds.blobstore.strategy.internal;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.blobstore.options.ListOptions;
import org.jclouds.blobstore.strategy.CountListStrategy;
@ -34,6 +35,7 @@ import org.jclouds.blobstore.strategy.ListBlobMetadataStrategy;
*
* @author Adrian Cole
*/
@Singleton
public class CountBlobTypeInList implements CountListStrategy {
protected final ListBlobMetadataStrategy getAllBlobMetadata;

View File

@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.domain.ResourceMetadata;
@ -48,6 +49,7 @@ import com.google.common.collect.Sets;
*
* @author Adrian Cole
*/
@Singleton
public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStrategy {
/**
* maximum duration of an blob Request

View File

@ -26,6 +26,7 @@ package org.jclouds.blobstore.strategy.internal;
import java.util.Arrays;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.functions.ObjectMD5;
@ -40,6 +41,7 @@ import org.jclouds.util.Utils;
*
* @author Adrian Cole
*/
@Singleton
public class FindMD5InList implements ContainsValueInListStrategy {
protected final ObjectMD5 objectMD5;

View File

@ -34,6 +34,7 @@ import java.util.concurrent.TimeoutException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.KeyNotFoundException;
@ -56,6 +57,7 @@ import com.google.common.collect.Sets;
*
* @author Adrian Cole
*/
@Singleton
public class GetAllBlobsInListAndRetryOnFailure implements GetBlobsInListStrategy {
/**
* maximum duration of an blob Request

View File

@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.domain.BlobMetadata;
@ -47,6 +48,7 @@ import com.google.common.collect.Sets;
*
* @author Adrian Cole
*/
@Singleton
public class ListBlobMetadataInContainer implements ListBlobMetadataStrategy {
/**
* maximum duration of an blob Request

View File

@ -23,6 +23,7 @@
*/
package org.jclouds.http.functions;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import org.apache.commons.io.IOUtils;
@ -36,6 +37,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ParseETagHeader implements Function<HttpResponse, String> {
public String apply(HttpResponse from) {

View File

@ -26,6 +26,7 @@ package org.jclouds.http.functions;
import java.io.InputStream;
import javax.annotation.Resource;
import javax.inject.Singleton;
import org.apache.commons.io.IOUtils;
import org.jclouds.http.HttpResponse;
@ -41,6 +42,7 @@ import com.google.gson.Gson;
*
* @author Adrian Cole
*/
@Singleton
public abstract class ParseJson<T> implements Function<HttpResponse, T> {
@Resource

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.http.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import com.google.common.base.Function;
@ -30,8 +32,8 @@ import com.google.common.base.Function;
/**
*
* @author Adrian Cole
* @since 4.0
*/
@Singleton
public class ReturnFalseOn404 implements Function<Exception, Boolean> {
public Boolean apply(Exception from) {

View File

@ -25,6 +25,8 @@ package org.jclouds.http.functions;
import java.io.InputStream;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponse;
import com.google.common.base.Function;
@ -34,6 +36,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnInputStream implements Function<HttpResponse, InputStream> {
public InputStream apply(HttpResponse from) {

View File

@ -26,6 +26,8 @@ package org.jclouds.http.functions;
import java.io.IOException;
import java.io.InputStream;
import javax.inject.Singleton;
import org.jclouds.http.HttpException;
import org.jclouds.http.HttpResponse;
import org.jclouds.util.Utils;
@ -36,6 +38,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnStringIf200 implements Function<HttpResponse,String> {
public String apply(HttpResponse from) {

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.http.functions;
import javax.inject.Singleton;
import org.apache.commons.io.IOUtils;
import org.jclouds.http.HttpResponse;
@ -33,6 +35,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnTrueIf2xx implements Function<HttpResponse, Boolean> {
public Boolean apply(HttpResponse from) {

View File

@ -23,10 +23,13 @@
*/
package org.jclouds.http.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import com.google.common.base.Function;
@Singleton
public class ReturnTrueOn404 implements Function<Exception, Boolean> {
public Boolean apply(Exception from) {

View File

@ -25,6 +25,8 @@ package org.jclouds.http.functions;
import java.lang.reflect.Constructor;
import javax.inject.Singleton;
import org.apache.commons.io.IOUtils;
import org.jclouds.http.HttpResponse;
@ -35,6 +37,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnVoidIf2xx implements Function<HttpResponse, Void> {
static final Void v;
static {

View File

@ -36,6 +36,7 @@ import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
@ -56,6 +57,7 @@ import com.google.common.collect.Maps;
*
* @author Adrian Cole
*/
@Singleton
public class JavaUrlHttpCommandExecutorService extends
BaseHttpCommandExecutorService<HttpURLConnection> {

View File

@ -35,6 +35,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import org.apache.commons.io.IOUtils;
@ -62,6 +63,7 @@ import com.google.common.annotations.VisibleForTesting;
* @author Adrian Cole
*/
@SingleThreaded
@Singleton
public class GaeHttpCommandExecutorService extends BaseHttpCommandExecutorService<HTTPRequest> {
private final URLFetchService urlFetchService;

View File

@ -30,6 +30,7 @@ import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.functions.ParseJson;
@ -41,6 +42,7 @@ import com.google.gson.Gson;
*
* @author Adrian Cole
*/
@Singleton
public class ParseMetadataFromJsonResponse extends ParseJson<Map<String, String>> {
@Inject

View File

@ -28,6 +28,7 @@ import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.functions.ParseJson;
@ -38,6 +39,7 @@ import com.google.gson.Gson;
*
* @author Adrian Cole
*/
@Singleton
public class ParseSessionTokenFromJsonResponse extends ParseJson<String> {
@Inject

View File

@ -30,6 +30,7 @@ import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.functions.ParseJson;
import org.jclouds.nirvanix.sdn.domain.UploadInfo;
@ -42,6 +43,7 @@ import com.google.gson.Gson;
* @see UploadInfo
* @author Adrian Cole
*/
@Singleton
public class ParseUploadInfoFromJsonResponse extends ParseJson<UploadInfo> {
@Inject

View File

@ -25,8 +25,11 @@ package org.jclouds.rackspace.cloudservers.functions;
import java.net.InetAddress;
import javax.inject.Singleton;
import com.google.common.base.Function;
@Singleton
public class IpAddress implements Function<Object, String> {
public String apply(Object from) {

View File

@ -32,12 +32,14 @@ import org.jclouds.rackspace.cloudservers.domain.Addresses;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* This parses {@link Addresses} from a gson string.
*
* @author Adrian Cole
*/
@Singleton
public class ParseAddressesFromJsonResponse extends ParseJson<Addresses> {
@Inject

View File

@ -32,12 +32,14 @@ import org.jclouds.rackspace.cloudservers.domain.BackupSchedule;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* This parses {@link BackupSchedule} from a gson string.
*
* @author Adrian Cole
*/
@Singleton
public class ParseBackupScheduleFromJsonResponse extends ParseJson<BackupSchedule> {
@Inject

View File

@ -32,12 +32,14 @@ import org.jclouds.rackspace.cloudservers.domain.Flavor;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* This parses {@link Flavor} from a gson string.
*
* @author Adrian Cole
*/
@Singleton
public class ParseFlavorFromJsonResponse extends ParseJson<Flavor> {
@Inject

View File

@ -33,6 +33,8 @@ import org.jclouds.rackspace.cloudservers.domain.Flavor;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.inject.internal.Lists;
/**
@ -40,6 +42,7 @@ import com.google.inject.internal.Lists;
*
* @author Adrian Cole
*/
@Singleton
public class ParseFlavorListFromJsonResponse extends ParseJson<List<Flavor>> {
@Inject

View File

@ -32,12 +32,14 @@ import org.jclouds.rackspace.cloudservers.domain.Image;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* This parses {@link Image} from a gson string.
*
* @author Adrian Cole
*/
@Singleton
public class ParseImageFromJsonResponse extends ParseJson<Image> {
@Inject

View File

@ -33,6 +33,8 @@ import org.jclouds.rackspace.cloudservers.domain.Image;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.inject.internal.Lists;
/**
@ -40,6 +42,7 @@ import com.google.inject.internal.Lists;
*
* @author Adrian Cole
*/
@Singleton
public class ParseImageListFromJsonResponse extends ParseJson<List<Image>> {
@Inject

View File

@ -36,12 +36,14 @@ import org.jclouds.http.functions.ParseJson;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* This parses a list of {@link InetAddress} from a gson string.
*
* @author Adrian Cole
*/
@Singleton
public class ParseInetAddressListFromJsonResponse extends ParseJson<List<InetAddress>> {
@Inject

View File

@ -32,12 +32,14 @@ import org.jclouds.rackspace.cloudservers.domain.Server;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* This parses {@link Server} from a gson string.
*
* @author Adrian Cole
*/
@Singleton
public class ParseServerFromJsonResponse extends ParseJson<Server> {
@Inject

View File

@ -33,6 +33,8 @@ import org.jclouds.rackspace.cloudservers.domain.Server;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.inject.internal.Lists;
/**
@ -40,6 +42,7 @@ import com.google.inject.internal.Lists;
*
* @author Adrian Cole
*/
@Singleton
public class ParseServerListFromJsonResponse extends ParseJson<List<Server>> {
@Inject

View File

@ -32,12 +32,14 @@ import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* This parses {@link SharedIpGroup} from a gson string.
*
* @author Adrian Cole
*/
@Singleton
public class ParseSharedIpGroupFromJsonResponse extends ParseJson<SharedIpGroup> {
@Inject

View File

@ -33,6 +33,8 @@ import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup;
import com.google.gson.Gson;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.inject.internal.Lists;
/**
@ -40,6 +42,7 @@ import com.google.inject.internal.Lists;
*
* @author Adrian Cole
*/
@Singleton
public class ParseSharedIpGroupListFromJsonResponse extends ParseJson<List<SharedIpGroup>> {
@Inject

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.Flavor;
@ -33,6 +35,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnFlavorNotFoundOn404 implements Function<Exception, Flavor> {
public Flavor apply(Exception from) {

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.Image;
@ -33,6 +35,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnImageNotFoundOn404 implements Function<Exception, Image> {
public Image apply(Exception from) {

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.Server;
@ -33,6 +35,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnServerNotFoundOn404 implements Function<Exception, Server> {
public Server apply(Exception from) {

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup;
@ -33,6 +35,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ReturnSharedIpGroupNotFoundOn404 implements Function<Exception, SharedIpGroup> {
public SharedIpGroup apply(Exception from) {

View File

@ -31,6 +31,8 @@ import static org.jclouds.rackspace.reference.RackspaceHeaders.STORAGE_URL;
import java.net.URI;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.RackspaceAuthentication.AuthenticationResponse;
@ -41,6 +43,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ParseAuthenticationResponseFromHeaders implements
Function<HttpResponse, AuthenticationResponse> {

View File

@ -31,6 +31,7 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import org.jclouds.http.HttpResponse;
@ -49,6 +50,7 @@ import com.google.common.base.Function;
*
* @author Adrian Cole
*/
@Singleton
public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudXSession> {
static final Pattern pattern = Pattern.compile("vcloud-token=(.*); path=.*");