Skip to content

Commit 36b0eee

Browse files
---
yaml --- r: 4035 b: refs/heads/gcs-nio c: 331d0ec h: refs/heads/master i: 4033: fb250f8 4031: f1b3ace
1 parent 5cb3215 commit 36b0eee

42 files changed

Lines changed: 555 additions & 604 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ refs/tags/v0.0.12: 2fd8066e891fb3dfea69b65f6bf6461db79342b9
1111
refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
14-
refs/heads/gcs-nio: b7f137d9c484e56339b3dd66a3d600251ae60f71
14+
refs/heads/gcs-nio: 331d0eca83d73b19d52b1086a5d8e517623acd01
1515
refs/heads/logging-alpha: db5312bffa7fccac194f6a7feb8cc3066de16aff
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/pom.xml

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<dependencies>
2020
<dependency>
2121
<groupId>${project.groupId}</groupId>
22-
<artifactId>gcloud-java</artifactId>
22+
<artifactId>gcloud-java-storage</artifactId>
2323
<version>${project.version}</version>
2424
</dependency>
2525
<dependency>
@@ -92,26 +92,40 @@
9292
<compilerArgument>-Xlint:unchecked</compilerArgument>
9393
</configuration>
9494
</plugin>
95-
<plugin>
96-
<artifactId>maven-jar-plugin</artifactId>
97-
<version>2.6</version>
98-
<configuration>
99-
<archive>
100-
<addMavenDescriptor>true</addMavenDescriptor>
101-
<index>true</index>
102-
<manifest>
103-
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
104-
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
105-
</manifest>
106-
<manifestEntries>
107-
<artifactId>${project.artifactId}</artifactId>
108-
<groupId>${project.groupId}</groupId>
109-
<version>${project.version}</version>
110-
<buildNumber>${buildNumber}</buildNumber>
111-
</manifestEntries>
112-
</archive>
113-
</configuration>
114-
</plugin>
95+
<!-- shade the jar so we can demo adding the NIO jar to add functionality. -->
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-shade-plugin</artifactId>
99+
<version>2.4.3</version>
100+
<configuration>
101+
<shadedArtifactAttached>true</shadedArtifactAttached>
102+
<relocations>
103+
<relocation>
104+
<pattern>com</pattern>
105+
<shadedPattern>shaded.gcloud-nio.com</shadedPattern>
106+
<excludes>
107+
<exclude>com.google.gcloud.**</exclude>
108+
</excludes>
109+
</relocation>
110+
<relocation>
111+
<pattern>org</pattern>
112+
<shadedPattern>shaded.gcloud-nio.org</shadedPattern>
113+
</relocation>
114+
<relocation>
115+
<pattern>google</pattern>
116+
<shadedPattern>shaded.gcloud-nio.google</shadedPattern>
117+
</relocation>
118+
</relocations>
119+
</configuration>
120+
<executions>
121+
<execution>
122+
<phase>package</phase>
123+
<goals>
124+
<goal>shade</goal>
125+
</goals>
126+
</execution>
127+
</executions>
128+
</plugin>
115129
</plugins>
116130
</build>
117131
</project>

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageConfiguration.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
import static com.google.common.base.Preconditions.checkArgument;
@@ -146,7 +130,7 @@ public CloudStorageConfiguration build() {
146130
Builder() {}
147131
}
148132

149-
static final CloudStorageConfiguration DEFAULT = builder().build();
133+
public static final CloudStorageConfiguration DEFAULT = builder().build();
150134

151135
static CloudStorageConfiguration fromMap(Map<String, ?> env) {
152136
Builder builder = builder();

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileAttributeView.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
import static com.google.common.base.Preconditions.checkNotNull;

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileAttributes.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
import com.google.common.base.Optional;

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileSystem.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
import static com.google.common.base.Preconditions.checkArgument;
204
import static com.google.common.base.Preconditions.checkNotNull;
215

226
import com.google.common.collect.ImmutableSet;
7+
import com.google.gcloud.storage.StorageOptions;
238

249
import java.io.IOException;
2510
import java.net.URI;
@@ -34,6 +19,7 @@
3419
import java.util.Objects;
3520
import java.util.Set;
3621

22+
import javax.annotation.Nullable;
3723
import javax.annotation.concurrent.Immutable;
3824

3925
/**
@@ -60,7 +46,7 @@ public final class CloudStorageFileSystem extends FileSystem {
6046
* provides a simpler alternative.
6147
*
6248
* @see #forBucket(String, CloudStorageConfiguration)
63-
* @see java.nio.file.FileSystems#getFileSystem(java.net.URI)
49+
* @see java.nio.file.FileSystems#getFileSystem(URI)
6450
*/
6551
public static CloudStorageFileSystem forBucket(String bucket) {
6652
return forBucket(bucket, CloudStorageConfiguration.DEFAULT);
@@ -72,10 +58,21 @@ public static CloudStorageFileSystem forBucket(String bucket) {
7258
* @see #forBucket(String)
7359
*/
7460
public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config) {
75-
checkArgument(
76-
!bucket.startsWith(URI_SCHEME + ":"), "Bucket name must not have schema: %s", bucket);
77-
return new CloudStorageFileSystem(
78-
new CloudStorageFileSystemProvider(), bucket, checkNotNull(config));
61+
return forBucket(bucket, config, null);
62+
}
63+
64+
/**
65+
* Creates a new filesystem for a particular bucket, with customizable settings and storage
66+
* options.
67+
*
68+
* @see #forBucket(String)
69+
*/
70+
public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config,
71+
@Nullable StorageOptions storageOptions) {
72+
checkArgument(!bucket.startsWith(URI_SCHEME + ":"),
73+
"Bucket name must not have schema: %s", bucket);
74+
return new CloudStorageFileSystem(new CloudStorageFileSystemProvider(storageOptions),
75+
bucket, checkNotNull(config));
7976
}
8077

8178
public static final String URI_SCHEME = "gs";

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileSystemProvider.java

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
import static com.google.common.base.Preconditions.checkArgument;
@@ -82,14 +66,14 @@ public final class CloudStorageFileSystemProvider extends FileSystemProvider {
8266
private final Storage storage;
8367

8468
// used only when we create a new instance of CloudStorageFileSystemProvider.
85-
private static StorageOptions storageOptions;
69+
private static StorageOptions defaultStorageOptions;
8670

8771
/**
88-
* Sets options that are only used by the constructor.
72+
* Sets default options that are only used by the constructor.
8973
*/
9074
@VisibleForTesting
9175
public static void setGCloudOptions(StorageOptions newStorageOptions) {
92-
storageOptions = newStorageOptions;
76+
defaultStorageOptions = newStorageOptions;
9377
}
9478

9579
/**
@@ -99,14 +83,19 @@ public static void setGCloudOptions(StorageOptions newStorageOptions) {
9983
* @see CloudStorageFileSystem#forBucket(String)
10084
*/
10185
public CloudStorageFileSystemProvider() {
102-
this(storageOptions);
86+
this(defaultStorageOptions);
10387
}
10488

105-
private CloudStorageFileSystemProvider(@Nullable StorageOptions gcsStorageOptions) {
106-
if (gcsStorageOptions == null) {
107-
this.storage = StorageOptions.defaultInstance().service();
89+
CloudStorageFileSystemProvider(@Nullable StorageOptions explicitOptions) {
90+
// explicit options have priority over default options.
91+
if (explicitOptions == null) {
92+
if (defaultStorageOptions == null) {
93+
this.storage = StorageOptions.defaultInstance().service();
94+
} else {
95+
this.storage = defaultStorageOptions.service();
96+
}
10897
} else {
109-
this.storage = gcsStorageOptions.service();
98+
this.storage = explicitOptions.service();
11099
}
111100
}
112101

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageObjectAttributes.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
import static com.google.common.base.Preconditions.checkNotNull;

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageObjectImmutableException.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
/**

branches/gcs-nio/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageOption.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package com.google.gcloud.storage.contrib.nio;
182

193
import java.nio.file.CopyOption;

0 commit comments

Comments
 (0)