diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java index a963a871f6..1531274df9 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java @@ -20,6 +20,7 @@ package org.jclouds.blobstore; import static com.google.common.base.Preconditions.checkNotNull; +import java.io.IOException; import java.net.URI; import java.util.Properties; @@ -28,6 +29,7 @@ import javax.inject.Inject; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpPropertiesBuilder; +import com.google.common.io.Resources; import com.google.inject.Module; /** @@ -37,6 +39,17 @@ import com.google.inject.Module; public class BlobStoreContextFactory { private final Properties properties; + public BlobStoreContextFactory() throws IOException { + this(init()); + } + + static Properties init() throws IOException { + Properties properties = new Properties(); + properties.load(Resources.newInputStreamSupplier( + Resources.getResource("blobstore.properties")).getInput()); + return properties; + } + @Inject public BlobStoreContextFactory(Properties properties) { this.properties = properties; diff --git a/tools/vfs/src/main/resources/jclouds.properties b/blobstore/src/main/resources/blobstore.properties similarity index 58% rename from tools/vfs/src/main/resources/jclouds.properties rename to blobstore/src/main/resources/blobstore.properties index c161933ed3..18c0cd7e11 100644 --- a/tools/vfs/src/main/resources/jclouds.properties +++ b/blobstore/src/main/resources/blobstore.properties @@ -16,29 +16,6 @@ # limitations under the License. # ==================================================================== # -# -# -# Copyright (C) 2009 Cloud Conscious, LLC. -# -# ==================================================================== -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ==================================================================== -# atmos.contextbuilder=org.jclouds.atmosonline.saas.blobstore.AtmosBlobStoreContextBuilder atmos.propertiesbuilder=org.jclouds.atmosonline.saas.AtmosStoragePropertiesBuilder azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder diff --git a/demos/antjruby/build.xml b/demos/antjruby/build.xml new file mode 100644 index 0000000000..6e25b24eb3 --- /dev/null +++ b/demos/antjruby/build.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/JavaOverSsh.java b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJava.java similarity index 95% rename from tools/antcontrib/src/main/java/org/jclouds/tools/ant/JavaOverSsh.java rename to tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJava.java index 376f369fa6..516d113a94 100644 --- a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/JavaOverSsh.java +++ b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJava.java @@ -16,7 +16,7 @@ * limitations under the License. * ==================================================================== */ -package org.jclouds.tools.ant; +package org.jclouds.tools.ant.taskdefs.sshjava; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.scriptbuilder.domain.Statements.exec; @@ -51,7 +51,7 @@ import com.google.common.collect.Lists; * * @author Adrian Cole */ -public class JavaOverSsh extends Java { +public class SSHJava extends Java { private final SSHExec exec; private final Scp scp; private final SSHUserInfo userInfo; @@ -68,7 +68,7 @@ public class JavaOverSsh extends Java { private String outputProperty; private boolean append; - public JavaOverSsh() { + public SSHJava() { super(); setFork(true); exec = new SSHExec(); @@ -76,7 +76,7 @@ public class JavaOverSsh extends Java { userInfo = new SSHUserInfo(); } - public JavaOverSsh(Task owner) { + public SSHJava(Task owner) { this(); bindToOwner(owner); } @@ -97,6 +97,7 @@ public class JavaOverSsh extends Java { copyPathTo(getCommandLine().getClasspath(), remoteDirectory.getAbsolutePath() + "/classpath"); } + if (getCommandLine().getBootclasspath() != null) { copyPathTo(getCommandLine().getBootclasspath(), remoteDirectory.getAbsolutePath() + "/bootclasspath"); diff --git a/tools/antcontrib/src/test/java/org/jclouds/tools/ant/JavaOverSshTest.java b/tools/antcontrib/src/test/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJavaTest.java similarity index 92% rename from tools/antcontrib/src/test/java/org/jclouds/tools/ant/JavaOverSshTest.java rename to tools/antcontrib/src/test/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJavaTest.java index 539ebae90a..4c1724d3c5 100644 --- a/tools/antcontrib/src/test/java/org/jclouds/tools/ant/JavaOverSshTest.java +++ b/tools/antcontrib/src/test/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJavaTest.java @@ -16,7 +16,7 @@ * limitations under the License. * ==================================================================== */ -package org.jclouds.tools.ant; +package org.jclouds.tools.ant.taskdefs.sshjava; import static org.testng.Assert.assertEquals; @@ -32,6 +32,7 @@ import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.types.Environment; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Environment.Variable; +import org.jclouds.tools.ant.TestClass; import org.testng.annotations.Test; import com.google.common.collect.Iterables; @@ -39,14 +40,14 @@ import com.google.common.collect.Iterables; /** * @author Adrian Cole */ -@Test(groups = "unit", testName = "jclouds.JavaOverSshTest") -public class JavaOverSshTest { +@Test(groups = "unit", testName = "jclouds.SSHJavaTest") +public class SSHJavaTest { public static final Entry LAST_ENV = Iterables.getLast(System.getenv() .entrySet()); // TODO, this test will break in windows public void testFull() throws SecurityException, NoSuchMethodException { - JavaOverSsh task = makeJavaOverSsh(); + SSHJava task = makeSSHJava(); String expected = String .format( "export %s=\"%s\"%ncd /tmp/foo\n%s -Xms16m -Xmx32m -cp classpath -Dfooble=baz -Dfoo=bar org.jclouds.tools.ant.TestClass %s hello world\n", @@ -92,7 +93,7 @@ public class JavaOverSshTest { Java java = makeJava(); java.execute(); - JavaOverSsh javaOverSsh = makeJavaOverSsh(); + SSHJava javaOverSsh = makeSSHJava(); addDestinationTo(javaOverSsh); javaOverSsh.execute(); @@ -104,7 +105,7 @@ public class JavaOverSshTest { .getProperty("result")); } - private void addDestinationTo(JavaOverSsh javaOverSsh) throws UnknownHostException { + private void addDestinationTo(SSHJava javaOverSsh) throws UnknownHostException { String sshHost = System.getProperty("jclouds.test.ssh.host"); String sshPort = System.getProperty("jclouds.test.ssh.port"); String sshUser = System.getProperty("jclouds.test.ssh.username"); @@ -124,8 +125,8 @@ public class JavaOverSshTest { } } - private JavaOverSsh makeJavaOverSsh() { - JavaOverSsh task = new JavaOverSsh(); + private SSHJava makeSSHJava() { + SSHJava task = new SSHJava(); populateTask(task); task.setRemotedir(new File("/tmp/foo")); task.setVerbose(true); diff --git a/tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java b/tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java index e352888307..9588217f95 100755 --- a/tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java +++ b/tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; -import java.util.Properties; import java.util.Map.Entry; import org.jclouds.blobstore.util.BlobStoreUtils; @@ -36,7 +35,6 @@ import org.jclouds.http.HttpUtils; import com.google.common.io.ByteStreams; import com.google.common.io.Closeables; -import com.google.common.io.Resources; /** * @@ -51,10 +49,10 @@ public class GetPath { public static void main(String... args) throws IOException { if (args.length < 2) throw new IllegalArgumentException(INVALID_SYNTAX); - URI locationAndCredentials; + URI uri; try { - locationAndCredentials = HttpUtils.createUri(args[0]); - checkArgument(locationAndCredentials.getScheme().equals("blobstore"), "wrong scheme"); + uri = HttpUtils.createUri(args[0]); + checkArgument(uri.getScheme().equals("blobstore"), "wrong scheme"); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(String.format("%s%n%s", e.getMessage(), INVALID_SYNTAX)); } @@ -64,8 +62,9 @@ public class GetPath { File destinationDir = new File(args[1]); destinationDir.mkdirs(); - BlobStoreContext context = init(locationAndCredentials); - String path = locationAndCredentials.getPath(); + BlobStoreContext context = new BlobStoreContextFactory() + .createContext(uri); + String path = uri.getPath(); if (path.startsWith("/")) path = path.substring(1); String container = BlobStoreUtils.parseContainerFromPath(path); @@ -103,10 +102,4 @@ public class GetPath { } } - private static BlobStoreContext init(URI locationAndCredentials) throws IOException { - Properties properties = new Properties(); - properties.load(Resources.newInputStreamSupplier(Resources.getResource("jclouds.properties")) - .getInput()); - return new BlobStoreContextFactory(properties).createContext(locationAndCredentials); - } } diff --git a/tools/getpath/src/main/resources/jclouds.properties b/tools/getpath/src/main/resources/jclouds.properties deleted file mode 100644 index 8a575d0450..0000000000 --- a/tools/getpath/src/main/resources/jclouds.properties +++ /dev/null @@ -1,47 +0,0 @@ -# -# -# Copyright (C) 2009 Cloud Conscious, LLC. -# -# ==================================================================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ==================================================================== -# -# -# -# Copyright (C) 2009 Cloud Conscious, LLC. -# -# ==================================================================== -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ==================================================================== -# -azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder -azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder -cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder -cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder -s3.contextbuilder=org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder -s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder \ No newline at end of file diff --git a/tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java b/tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java index c4e5b9b1f7..ea98edf6c2 100755 --- a/tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java +++ b/tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java @@ -44,7 +44,7 @@ public class PropertiesTest { @BeforeTest public void setUp() throws IOException { properties = new Properties(); - properties.load(Resources.newInputStreamSupplier(Resources.getResource("jclouds.properties")) + properties.load(Resources.newInputStreamSupplier(Resources.getResource("blobstore.properties")) .getInput()); } diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java index 6dbdcfeab9..efb8e259aa 100644 --- a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java @@ -23,7 +23,6 @@ import java.net.URI; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Properties; import org.apache.commons.vfs.Capability; import org.apache.commons.vfs.FileName; @@ -43,7 +42,6 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.io.Resources; import com.google.inject.Module; /** @@ -80,12 +78,9 @@ public class BlobStoreFileProvider extends AbstractOriginatingFileProvider { try { String uriToParse = rootName.getFriendlyURI(); authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES); - Properties properties = new Properties(); - properties.load(Resources.newInputStreamSupplier( - Resources.getResource("jclouds.properties")).getInput()); URI location = HttpUtils.createUri(uriToParse); - blobStore = new BlobStoreContextFactory(properties).createContext( + blobStore = new BlobStoreContextFactory().createContext( location, new Credentials(UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData( authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils diff --git a/tools/vfs/src/test/resources/jclouds.properties b/tools/vfs/src/test/resources/jclouds.properties deleted file mode 100644 index 7ce23cd5a2..0000000000 --- a/tools/vfs/src/test/resources/jclouds.properties +++ /dev/null @@ -1,51 +0,0 @@ -# -# -# Copyright (C) 2009 Cloud Conscious, LLC. -# -# ==================================================================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ==================================================================== -# -# -# -# Copyright (C) 2009 Cloud Conscious, LLC. -# -# ==================================================================== -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ==================================================================== -# -atmos.contextbuilder=org.jclouds.atmosonline.saas.blobstore.AtmosBlobStoreContextBuilder -atmos.propertiesbuilder=org.jclouds.atmosonline.saas.AtmosStoragePropertiesBuilder -azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder -azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder -cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder -cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder -s3.contextbuilder=org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder -s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder -stub.contextbuilder=org.jclouds.blobstore.integration.StubBlobStoreContextBuilder -stub.propertiesbuilder=org.jclouds.blobstore.integration.StubPropertiesBuilder