Issue 925: added default ctors so that gson can work w/o using sun.misc.Unsafe

This commit is contained in:
Adrian Cole 2012-05-16 14:51:16 -07:00
parent c4499d8c5e
commit 96e272a91d
44 changed files with 474 additions and 294 deletions

View File

@ -76,8 +76,14 @@ public class Address {
}
}
protected final String addr;
protected final int version;
protected Address() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String addr;
protected int version;
public Address(String addr, int version) {
this.addr = addr;

View File

@ -106,10 +106,16 @@ public class Extension extends Resource {
}
}
private final URI namespace;
private final String alias;
private final Date updated;
private final String description;
protected Extension() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private URI namespace;
private String alias;
private Date updated;
private String description;
protected Extension(Builder<?> builder) {
super(builder);

View File

@ -123,14 +123,20 @@ public class Flavor extends Resource {
}
}
protected Flavor() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private int ram;
private int disk;
private int vcpus;
private final Optional<String> swap;
private Optional<String> swap = Optional.absent();
@SerializedName("rxtx_factor")
private final Optional<Double> rxtxFactor;
private Optional<Double> rxtxFactor = Optional.absent();
@SerializedName("OS-FLV-EXT-DATA:ephemeral")
private final Optional<Integer> ephemeral;
private Optional<Integer> ephemeral = Optional.absent();
protected Flavor(Builder<?> builder) {
super(builder);
@ -142,12 +148,6 @@ public class Flavor extends Resource {
this.ephemeral = Optional.fromNullable(builder.ephemeral);
}
protected Flavor() {
this.swap = Optional.absent();
this.rxtxFactor = Optional.absent();
this.ephemeral = Optional.absent();
}
public int getRam() {
return this.ram;
}

View File

@ -77,6 +77,12 @@ public class FloatingIP implements Comparable<FloatingIP> {
}
protected FloatingIP() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String ip;
@SerializedName("fixed_ip")

View File

@ -73,9 +73,15 @@ public class Host {
}
}
protected Host() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName(value="host_name")
private final String name;
private final String service;
private String name;
private String service;
protected Host(Builder<?> builder) {
this.name = builder.name;

View File

@ -155,18 +155,24 @@ public class HostAggregate {
}
}
private final String id;
private final String name;
protected HostAggregate() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String name;
@SerializedName(value = "availability_zone")
private final String availabilityZone;
private final Set<String> hosts;
private String availabilityZone;
private Set<String> hosts = ImmutableSet.of();
@SerializedName(value = "operational_state")
private final String state;
private String state;
@SerializedName(value = "created_at")
private final Date created;
private Date created;
@SerializedName(value = "updated_at")
private final Optional<Date> updated;
private final Map<String, String> metadata;
private Optional<Date> updated = Optional.absent();
private Map<String, String> metadata = ImmutableMap.of();
protected HostAggregate(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");
@ -179,18 +185,6 @@ public class HostAggregate {
this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata"));
}
// Ensure GSON parsed objects don't have null collections or optionals
protected HostAggregate() {
this.id = null;
this.name = null;
this.availabilityZone = null;
this.hosts = ImmutableSet.of();
this.state = null;
this.created = null;
this.updated = Optional.absent();
this.metadata = ImmutableMap.of();
}
public String getId() {
return this.id;
}

View File

@ -96,13 +96,19 @@ public class HostResourceUsage {
}
}
private final String host;
private final String project;
protected HostResourceUsage() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String host;
private String project;
@SerializedName(value="memory_mb")
private final int memoryMb;
private final int cpu;
private int memoryMb;
private int cpu;
@SerializedName(value="disk_gb")
private final int diskGb;
private int diskGb;
protected HostResourceUsage(Builder<?> builder) {
this.host = checkNotNull(builder.host, "host");

View File

@ -192,18 +192,24 @@ public class Image extends Resource {
}
}
private final Date updated;
private final Date created;
protected Image() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private Date updated;
private Date created;
@SerializedName("tenant_id")
private final String tenantId;
private String tenantId;
@SerializedName("user_id")
private final String userId;
private final Status status;
private final int progress;
private final int minDisk;
private final int minRam;
private final Resource server;
private final Map<String, String> metadata;
private String userId;
private Status status;
private int progress;
private int minDisk;
private int minRam;
private Resource server;
private Map<String, String> metadata = ImmutableMap.of();
protected Image(Builder<?> builder) {
super(builder);

View File

@ -74,12 +74,18 @@ public class Ingress {
}
}
protected Ingress() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName(value = "ip_protocol")
protected final IpProtocol ipProtocol;
protected IpProtocol ipProtocol;
@SerializedName(value = "from_port")
protected final int fromPort;
protected int fromPort;
@SerializedName(value = "to_port")
protected final int toPort;
protected int toPort;
protected Ingress(IpProtocol ipProtocol, int fromPort, int toPort) {
this.fromPort = fromPort;

View File

@ -77,14 +77,20 @@ public class KeyPair implements Comparable<KeyPair> {
}
protected KeyPair() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName("public_key")
String publicKey;
private String publicKey;
@SerializedName("private_key")
String privateKey;
private String privateKey;
@SerializedName("user_id")
String userId;
String name;
String fingerprint;
private String userId;
private String name;
private String fingerprint;
protected KeyPair(String publicKey, String privateKey, @Nullable String userId, String name, String fingerprint) {
this.publicKey = publicKey;

View File

@ -188,27 +188,33 @@ public class Quotas {
}
}
protected Quotas() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName("id")
private final String id;
private String id;
@SerializedName("metadata_items")
private final int metadataItems;
private int metadataItems;
@SerializedName("injected_file_content_bytes")
private final int injectedFileContentBytes;
private final int volumes;
private final int gigabytes;
private final int ram;
private int injectedFileContentBytes;
private int volumes;
private int gigabytes;
private int ram;
@SerializedName("floating_ips")
private final int floatingIps;
private final int instances;
private int floatingIps;
private int instances;
@SerializedName("injected_files")
private final int injectedFiles;
private final int cores;
private int injectedFiles;
private int cores;
@SerializedName("security_groups")
private final int securityGroups;
private int securityGroups;
@SerializedName("security_group_rules")
private final int securityGroupRules;
private int securityGroupRules;
@SerializedName("key_pairs")
private final int keyPairs;
private int keyPairs;
protected Quotas(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");

View File

@ -103,12 +103,18 @@ public class SecurityGroup {
}
protected final String id;
protected SecurityGroup() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
@SerializedName("tenant_id")
protected final String tenantId;
protected final String name;
protected final String description;
protected final Set<SecurityGroupRule> rules;
protected String tenantId;
protected String name;
protected String description;
protected Set<SecurityGroupRule> rules = ImmutableSet.of();
protected SecurityGroup(String id, String tenantId, @Nullable String name, @Nullable String description,
Set<SecurityGroupRule> rules) {

View File

@ -96,12 +96,18 @@ public class SecurityGroupRule extends Ingress {
}
protected final String id;
protected final TenantIdAndName group;
protected SecurityGroupRule() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected TenantIdAndName group;
@SerializedName(value = "parent_group_id")
protected final String parentGroupId;
protected String parentGroupId;
@SerializedName(value = "ip_range")
protected Cidr ipRange;
// type to get around unnecessary structure
private static class Cidr extends ForwardingObject {
@ -117,8 +123,6 @@ public class SecurityGroupRule extends Ingress {
}
}
@SerializedName(value = "ip_range")
protected final Cidr ipRange;
protected SecurityGroupRule(IpProtocol ipProtocol, int fromPort, int toPort, String id, String parentGroupId,
@Nullable TenantIdAndName group, @Nullable String ipRange) {

View File

@ -34,7 +34,6 @@ import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.base.Predicates;
import com.google.common.base.Strings;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Maps;
@ -302,38 +301,41 @@ public class Server extends Resource {
}
}
private final String uuid;
@SerializedName("tenant_id")
private final String tenantId;
@SerializedName("user_id")
private final String userId;
private final Date updated;
private final Date created;
private final String hostId;
private final String accessIPv4;
private final String accessIPv6;
private final Status status;
private final Resource image;
private final Resource flavor;
@SerializedName("key_name")
private final String keyName;
@SerializedName("config_drive")
private final String configDrive;
// TODO: get gson multimap adapter!
private final Map<String, Set<Address>> addresses;
private final Map<String, String> metadata;
protected Server() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String uuid;
@SerializedName("tenant_id")
private String tenantId;
@SerializedName("user_id")
private String userId;
private Date updated;
private Date created;
private String hostId;
private String accessIPv4;
private String accessIPv6;
private Status status;
private Resource image;
private Resource flavor;
@SerializedName("key_name")
private String keyName;
@SerializedName("config_drive")
private String configDrive;
// TODO: get gson multimap adapter!
private Map<String, Set<Address>> addresses = ImmutableMap.of();
private Map<String, String> metadata = ImmutableMap.of();
// Extended status extension
// @Prefixed("OS-EXT-STS:")
private final Optional<ServerExtendedStatus> extendedStatus;
private Optional<ServerExtendedStatus> extendedStatus = Optional.absent();
// Extended server attributes extension
// @Prefixed("OS-EXT-SRV-ATTR:")
private final Optional<ServerExtendedAttributes> extendedAttributes;
private Optional<ServerExtendedAttributes> extendedAttributes = Optional.absent();
// Disk Config extension
@SerializedName("OS-DCF:diskConfig")
private final Optional<String> diskConfig;
private Optional<String> diskConfig = Optional.absent();
protected Server(Builder<?> builder) {
super(builder);
@ -357,28 +359,6 @@ public class Server extends Resource {
this.diskConfig = builder.diskConfig == null ? Optional.<String>absent() : Optional.of(builder.diskConfig);
}
protected Server() {
// for GSON
this.uuid = null;
this.tenantId = null;
this.userId = null;
this.updated = null;
this.created = null;
this.hostId = null;
this.accessIPv4 = null;
this.accessIPv6 = null;
this.status = null;
this.configDrive = null;
this.image = null;
this.flavor = null;
this.metadata = ImmutableMap.of();
this.addresses = ImmutableMap.of();
this.keyName = null;
this.extendedStatus = Optional.absent();
this.extendedAttributes = Optional.absent();
this.diskConfig = Optional.absent();
}
/**
* only present until the id is in uuid form
*

View File

@ -18,7 +18,6 @@
*/
package org.jclouds.openstack.nova.v1_1.domain;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.domain.Resource;
import com.google.common.base.Objects.ToStringHelper;
@ -68,17 +67,19 @@ public class ServerCreated extends Resource {
}
}
private final String adminPass;
protected ServerCreated() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String adminPass;
protected ServerCreated(Builder<?> builder) {
super(builder);
this.adminPass = builder.adminPass;
}
protected ServerCreated() {
this.adminPass =null;
}
/**
* @return the administrative password for this server. Note: this is not available in Server responses.
*/

View File

@ -93,12 +93,18 @@ public class ServerExtendedAttributes {
}
}
protected ServerExtendedAttributes() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName(value=PREFIX + "instance_name")
private final String instanceName;
private String instanceName;
@SerializedName(value=PREFIX + "host")
private final String hostName;
private String hostName;
@SerializedName(value=PREFIX + "hypervisor_hostname")
private final String hypervisorHostName;
private String hypervisorHostName;
protected ServerExtendedAttributes(Builder<?> builder) {
this.instanceName = builder.instanceName;

View File

@ -95,12 +95,18 @@ public class ServerExtendedStatus {
}
}
protected ServerExtendedStatus() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName(value=PREFIX + "task_state")
private final String taskState;
private String taskState;
@SerializedName(value=PREFIX + "vm_state")
private final String vmState;
private String vmState;
@SerializedName(value=PREFIX + "power_state")
private final int powerState;
private int powerState = Integer.MIN_VALUE;
protected ServerExtendedStatus(Builder<?> builder) {
this.taskState = builder.taskState;
@ -108,12 +114,6 @@ public class ServerExtendedStatus {
this.powerState = builder.powerState;
}
protected ServerExtendedStatus() {
this.taskState = null;
this.vmState = null;
this.powerState = Integer.MIN_VALUE;
}
@Nullable
public String getTaskState() {
return this.taskState;

View File

@ -74,8 +74,14 @@ public class ServerWithSecurityGroups extends Server {
}
}
protected ServerWithSecurityGroups() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName(value="security_groups")
private final Set<String> securityGroupNames;
private Set<String> securityGroupNames = ImmutableSet.of();
protected ServerWithSecurityGroups(Builder<?> builder) {
super(builder);

View File

@ -160,26 +160,32 @@ public class SimpleServerUsage {
}
}
protected SimpleServerUsage() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName("name")
private final String instanceName;
private final double hours;
private String instanceName;
private double hours;
@SerializedName("memory_mb")
private final double flavorMemoryMb;
private double flavorMemoryMb;
@SerializedName("local_gb")
private final double flavorLocalGb;
private double flavorLocalGb;
@SerializedName("vcpus")
private final double flavorVcpus;
private double flavorVcpus;
@SerializedName("tenant_id")
private final String tenantId;
private String tenantId;
@SerializedName("flavor")
private final String flavorName;
private String flavorName;
@SerializedName("started_at")
private final Date instanceCreated;
private Date instanceCreated;
@SerializedName("ended_at")
private final Date instanceTerminiated;
private Date instanceTerminiated;
@SerializedName("state")
private final Status instanceStatus;
private final long uptime;
private Status instanceStatus;
private long uptime;
private SimpleServerUsage(Builder<?> builder) {
this.instanceName = checkNotNull(builder.instanceName, "instanceName");

View File

@ -124,20 +124,26 @@ public class SimpleTenantUsage {
}
}
protected SimpleTenantUsage() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName("tenant_id")
private final String tenantId;
private String tenantId;
@SerializedName("total_local_gb_usage")
private final double totalLocalGbUsage;
private double totalLocalGbUsage;
@SerializedName("total_vcpus_usage")
private final double totalVcpusUsage;
private double totalVcpusUsage;
@SerializedName("total_memory_mb_usage")
private final double totalMemoryMbUsage;
private double totalMemoryMbUsage;
@SerializedName("total_hours")
private final double totalHours;
private final Date start;
private final Date stop;
private double totalHours;
private Date start;
private Date stop;
@SerializedName("server_usages")
private final Set<SimpleServerUsage> serverUsages;
private Set<SimpleServerUsage> serverUsages = ImmutableSet.of();
private SimpleTenantUsage(Builder<?> builder) {
this.tenantId = builder.tenantId;

View File

@ -31,9 +31,15 @@ import com.google.gson.annotations.SerializedName;
*/
public class TenantIdAndName {
protected TenantIdAndName() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName("tenant_id")
protected final String tenantId;
protected final String name;
protected String tenantId;
protected String name;
public TenantIdAndName(String tenantId, String name) {
this.tenantId = checkNotNull(tenantId, "tenantId");

View File

@ -82,9 +82,15 @@ public class VirtualInterface {
}
}
private final String id;
protected VirtualInterface() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
@SerializedName(value="mac_address")
private final String macAddress;
private String macAddress;
protected VirtualInterface(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");

View File

@ -177,21 +177,27 @@ public class Volume {
}
}
private final String id;
private final Status status;
private final int size;
protected Volume() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private Status status;
private int size;
@SerializedName(value="availabilityZone")
private final String zone;
private String zone;
@SerializedName(value="createdAt")
private final Date created;
private final Set<VolumeAttachment> attachments;
private final String volumeType;
private final String snapshotId;
private Date created;
private Set<VolumeAttachment> attachments = ImmutableSet.of();
private String volumeType;
private String snapshotId;
@SerializedName(value="displayName")
private final String name;
private String name;
@SerializedName(value="displayDescription")
private final String description;
private final Map<String, String> metadata;
private String description;
private Map<String, String> metadata = ImmutableMap.of();
protected Volume(Builder<?> builder) {
this.id = builder.id;

View File

@ -92,10 +92,16 @@ public class VolumeAttachment {
}
}
private final String id;
private final String volumeId;
private final String serverId;
private final String device;
protected VolumeAttachment() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String volumeId;
private String serverId;
private String device;
protected VolumeAttachment(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");

View File

@ -119,16 +119,22 @@ public class VolumeSnapshot {
}
}
private final String id;
private final String volumeId;
private final Volume.Status status;
private final int size;
protected VolumeSnapshot() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String volumeId;
private Volume.Status status;
private int size;
@SerializedName(value="createdAt")
private final Date created;
private Date created;
@SerializedName(value="displayName")
private final String name;
private String name;
@SerializedName(value="displayDescription")
private final String description;
private String description;
protected VolumeSnapshot(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");

View File

@ -116,14 +116,20 @@ public class VolumeType {
}
}
protected VolumeType() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String name;
@SerializedName("created_at")
private Date created;
@SerializedName("updated_at")
private final Optional<Date> updated;
private Optional<Date> updated = Optional.absent();
@SerializedName(value = "extra_specs")
private final Map<String, String> extraSpecs;
private Map<String, String> extraSpecs = ImmutableMap.of();
protected VolumeType(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");
@ -133,11 +139,6 @@ public class VolumeType {
this.updated = Optional.fromNullable(builder.updated);
}
protected VolumeType() {
this.updated = Optional.absent();
this.extraSpecs = ImmutableMap.of();
}
public String getId() {
return this.id;
}

View File

@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableMap;
public class AuthenticationResponse {
private final String authToken;
private Map<String, URI> services;
private final Map<String, URI> services;
public AuthenticationResponse(String authToken, Map<String, URI> services) {
this.authToken = checkNotNull(authToken, "authToken");
@ -39,10 +39,6 @@ public class AuthenticationResponse {
return services;
}
public void setEndpoints(Map<String, URI> services) {
this.services = services;
}
public String getAuthToken() {
return authToken;
}

View File

@ -134,10 +134,16 @@ public class Link {
}
}
protected Link() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName("rel")
protected final Relation relation;
protected final String type;
protected final URI href;
protected Relation relation;
protected String type;
protected URI href;
protected Link(Relation relation, @Nullable String type, URI href) {
this.relation = checkNotNull(relation, "relation");

View File

@ -106,9 +106,15 @@ public class Resource implements Comparable<Resource> {
}
}
private final String id;
private final String name;
private final Set<Link> links;
protected Resource() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String name;
private Set<Link> links = ImmutableSet.of();
protected Resource(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");
@ -116,12 +122,6 @@ public class Resource implements Comparable<Resource> {
this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links"));
}
protected Resource() {
this.id = null;
this.name = null;
this.links = ImmutableSet.of();
}
/**
* When providing an ID, it is assumed that the resource exists in the current OpenStack
* deployment

View File

@ -28,6 +28,7 @@ import java.util.Set;
import org.jclouds.util.Multimaps2;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
@ -78,9 +79,15 @@ public class Auth implements Comparable<Auth> {
}
}
protected final Token token;
protected Auth() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected Token token;
// TODO: get gson multimap adapter!
protected final Map<String, Set<Endpoint>> serviceCatalog;
protected Map<String, Set<Endpoint>> serviceCatalog = ImmutableMap.of();
public Auth(Token token, Multimap<String, Endpoint> serviceCatalog) {
this.token = checkNotNull(token, "token");

View File

@ -99,10 +99,16 @@ public class Endpoint implements Comparable<Endpoint> {
}
}
protected final boolean v1Default;
protected final String region;
protected final URI publicURL;
protected final URI internalURL;
protected Endpoint() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected boolean v1Default;
protected String region;
protected URI publicURL;
protected URI internalURL;
protected Endpoint(boolean v1Default, @Nullable String region, @Nullable URI publicURL, @Nullable URI internalURL) {
this.v1Default = v1Default;

View File

@ -80,8 +80,14 @@ public class Token implements Comparable<Token> {
}
}
protected final String id;
protected final Date expires;
protected Token() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected Date expires;
public Token(String id, Date expires) {
this.id = checkNotNull(id, "id");

View File

@ -89,9 +89,16 @@ public class Access implements Comparable<Access> {
}
}
protected final Token token;
protected final User user;
protected final Set<Service> serviceCatalog;
protected Access() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected Token token;
protected User user;
protected Set<Service> serviceCatalog = ImmutableSet.of();
public Access(Token token, User user, Set<Service> serviceCatalog) {
this.token = checkNotNull(token, "token");

View File

@ -95,13 +95,19 @@ public class ApiMetadata extends Resource {
}
}
protected ApiMetadata() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@Nullable
private final String status;
private String status;
@Nullable
private final Date updated;
private Date updated;
@SerializedName(value="media-types")
@Nullable
private final Set<MediaType> mediaTypes;
private Set<MediaType> mediaTypes = ImmutableSet.of();
protected ApiMetadata(Builder<?> builder) {
super(builder);

View File

@ -115,19 +115,26 @@ public class Endpoint implements Comparable<Endpoint> {
from.getInternalURL()).tenantId(from.getTenantId());
}
}
protected Endpoint() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
// renamed half-way through
@Deprecated
protected String id;
protected final String versionId;
protected final String region;
protected final URI publicURL;
protected final URI internalURL;
protected final URI adminURL;
protected String versionId;
protected String region;
protected URI publicURL;
protected URI internalURL;
protected URI adminURL;
// renamed half-way through
@Deprecated
protected String tenantName;
protected final String tenantId;
protected String tenantId;
protected Endpoint(String versionId, String region, @Nullable URI publicURL, @Nullable URI internalURL,
@Nullable URI adminURL, @Nullable String tenantId) {

View File

@ -60,8 +60,14 @@ public class MediaType {
}
}
private final String base;
private final String type;
protected MediaType() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String base;
private String type;
protected MediaType(Builder builder) {
this.base = builder.base;

View File

@ -97,13 +97,19 @@ public class Role implements Comparable<Role> {
}
}
protected final String id;
protected final String name;
protected final String serviceId;
protected Role() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected String name;
protected String serviceId;
// renamed half-way through
@Deprecated
protected String tenantName;
protected final String tenantId;
protected String tenantId;
protected Role(String id, String name, @Nullable String serviceId, @Nullable String tenantId) {
this.id = checkNotNull(id, "id");

View File

@ -91,9 +91,15 @@ public class Service implements Comparable<Service> {
}
}
protected final String type;
protected final String name;
protected final Set<Endpoint> endpoints;
protected Service() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String type;
protected String name;
protected Set<Endpoint> endpoints = ImmutableSet.of();
public Service(String type, String name, Set<Endpoint> endpoints) {
this.type = checkNotNull(type, "type");

View File

@ -83,9 +83,15 @@ public class Tenant implements Comparable<Tenant> {
}
}
protected final String id;
protected final String name;
protected final String description;
protected Tenant() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected String name;
protected String description;
protected Tenant(String id, String name, String description) {
this.id = checkNotNull(id, "id");

View File

@ -88,9 +88,15 @@ public class Token implements Comparable<Token> {
}
}
protected final String id;
protected final Date expires;
protected final Tenant tenant;
protected Token() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected Date expires;
protected Tenant tenant;
public Token(String id, Date expires, Tenant tenant) {
this.id = checkNotNull(id, "id");

View File

@ -94,9 +94,15 @@ public class User implements Comparable<User> {
}
}
protected final String id;
protected final String name;
protected final Set<Role> roles;
protected User() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected String name;
protected Set<Role> roles = ImmutableSet.of();
protected User(String id, String name, Set<Role> roles) {
this.id = checkNotNull(id, "id");
@ -104,12 +110,6 @@ public class User implements Comparable<User> {
this.roles = ImmutableSet.copyOf(checkNotNull(roles, "roles"));
}
protected User() {
id = null;
name = null;
roles = ImmutableSet.of();
}
/**
* When providing an ID, it is assumed that the user exists in the current OpenStack deployment
*

View File

@ -49,8 +49,14 @@ public class AccountMetadata {
}
}
protected final int containerCount;
protected final long bytesUsed;
protected AccountMetadata() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected int containerCount;
protected long bytesUsed;
public AccountMetadata(int containerCount, long bytesUsed) {
this.containerCount = containerCount;

View File

@ -65,9 +65,15 @@ public class ContainerMetadata implements Comparable<ContainerMetadata> {
}
}
protected final String name;
protected final int count;
protected final int bytes;
protected ContainerMetadata() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String name;
protected int count;
protected int bytes;
public ContainerMetadata(String name, int count, int bytes) {
this.name = checkNotNull(name, "name");

View File

@ -29,6 +29,12 @@ import com.google.gson.annotations.SerializedName;
*/
public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> {
protected ContainerCDNMetadata() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String name;
private boolean cdn_enabled;
private long ttl;
@ -45,9 +51,6 @@ public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> {
this.cdn_uri = cdnUri;
}
public ContainerCDNMetadata() {
}
/**
* Beware: The container name is not available from HEAD CDN responses and will be null. return
* the name of the container to which these CDN settings apply.