Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sdk/storage/azure-storage-queue/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,14 @@

<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ abstract class BaseQueueClientBuilder<T extends BaseClientBuilder<T>> extends Ba

@Override
protected final UserAgentPolicy getUserAgentPolicy() {
return new UserAgentPolicy(QueueConfiguration.NAME, QueueConfiguration.VERSION, super.getConfiguration());
QueueConfiguration queueConfiguration = new QueueConfiguration();
return new UserAgentPolicy(queueConfiguration.getName(), queueConfiguration.getVersion(), super.getConfiguration());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,46 @@
// Licensed under the MIT License.
package com.azure.storage.queue;

import com.azure.core.util.logging.ClientLogger;
import java.io.IOException;
import java.util.Properties;

/*
* Gets the SDK information for this library component.
*/
class QueueConfiguration {
//TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141
static final String NAME = "azure-storage-queue";
static final String VERSION = "12.0.0-preview.3";
private final ClientLogger logger = new ClientLogger(QueueClient.class);
private final Properties properties = new Properties();

public QueueConfiguration() {
loadProperties();
}

private void loadProperties() {
try {
properties.load(this.getClass().getClassLoader().getResourceAsStream("client.properties"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of loading properties should we being using reflections and getting the package information?

} catch (IOException e) {
throw logger.logExceptionAsError(new RuntimeException("Please check the client properties for queue module. "
+ "Error Details: " + e.getMessage()));
}
}

public String getName() {
String name = properties.getProperty("artifactId");
if (name == null || name.contains("${")) {
throw logger.logExceptionAsError(new RuntimeException("Please check the client properties for queue module name. "
+ "Module Name: " + name));
}
return name;
}

public String getVersion() {
String version = properties.getProperty("version");
if (version == null || version.contains("${")) {
throw logger.logExceptionAsError(new RuntimeException("Please check the client properties for queue module version. "
+ "Module Version: " + version));
}
return version;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=${project.version}
artifactId=${project.artifactId}