Skip to content

Commit

Permalink
Merge pull request #27 from andrerod/dev_2
Browse files Browse the repository at this point in the history
Using single checkstyle.xml
  • Loading branch information
André Rodrigues committed Jan 14, 2014
2 parents a7b514f + e94143b commit 4333e05
Showing 701 changed files with 45,944 additions and 31,265 deletions.
20 changes: 0 additions & 20 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -164,26 +164,6 @@
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.8</version>
<configuration>
<configLocation>src/config/checkstyle.xml</configLocation>
</configuration>
</plugin>

</plugins>
<pluginManagement>
<plugins>
86 changes: 54 additions & 32 deletions core/src/main/java/com/microsoft/windowsazure/Configuration.java
Original file line number Diff line number Diff line change
@@ -26,94 +26,116 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Configuration {

public class Configuration
{
/**
* Property name for socket connection timeout used by services created with this configuration.
* Property name for socket connection timeout used by services created with
* this configuration.
*/
public static final String PROPERTY_CONNECT_TIMEOUT = "com.microsoft.windowsazure.Configuration.connectTimeout";

/**
* Property name for socket read timeout used by services created with this configuration.
* Property name for socket read timeout used by services created with this
* configuration.
*/
public static final String PROPERTY_READ_TIMEOUT = "com.microsoft.windowsazure.Configuration.readTimeout";

/**
* Property name to control if HTTP logging to console is on or off. If property is set, logging is on, regardless
* of value.
* Property name to control if HTTP logging to console is on or off. If
* property is set, logging is on, regardless of value.
*/
public static final String PROPERTY_LOG_HTTP_REQUESTS = "com.microsoft.windowsazure.Configuration.logHttpRequests";

private static Configuration instance;
Map<String, Object> properties;
Builder builder;

static Log log = LogFactory.getLog(Configuration.class);

public Configuration() {
public Configuration()
{
this.properties = new HashMap<String, Object>();
this.builder = DefaultBuilder.create();
}

public Configuration(Builder builder) {
public Configuration(Builder builder)
{
this.properties = new HashMap<String, Object>();
this.builder = builder;
}

public static Configuration getInstance() {
if (instance == null) {
try {
public static Configuration getInstance()
{
if (instance == null)
{
try
{
instance = Configuration.load();
}
catch (IOException e) {
log.error("Unable to load META-INF/com.microsoft.windowsazure.properties", e);
} catch (IOException e)
{
log.error(
"Unable to load META-INF/com.microsoft.windowsazure.properties",
e);
instance = new Configuration();
}
}
return instance;
}

public static void setInstance(Configuration instance) {
Configuration.instance = instance;
public static void setInstance(final Configuration configuration)
{
Configuration.instance = configuration;
}

public static Configuration load() throws IOException {
Configuration config = new Configuration();

InputStream stream = Configuration.class.getClassLoader().getResourceAsStream(
"META-INF/com.microsoft.windowsazure.properties");
if (stream != null) {
Properties properties = new Properties();
public static Configuration load() throws IOException
{
final Configuration config = new Configuration();

final InputStream stream = Thread
.currentThread()
.getContextClassLoader()
.getResourceAsStream(
"META-INF/com.microsoft.windowsazure.properties");
if (stream != null)
{
final Properties properties = new Properties();
properties.load(stream);
for (Object key : properties.keySet()) {
config.setProperty(key.toString(), properties.get(key));
for (Map.Entry<Object, Object> key : properties.entrySet())
{
config.setProperty(key.getKey().toString(), key.getValue());
}
}

return config;
}

public <T> T create(Class<T> service) {
public <T> T create(Class<T> service)
{
return builder.build("", service, service, properties);
}

public <T> T create(String profile, Class<T> service) {
public <T> T create(String profile, Class<T> service)
{
return builder.build(profile, service, service, properties);
}

public Builder getBuilder() {
public Builder getBuilder()
{
return builder;
}

public Object getProperty(String name) {
public Object getProperty(String name)
{
return properties.get(name);
}

public void setProperty(String name, Object value) {
public void setProperty(String name, Object value)
{
properties.put(name, value);
}

public Map<String, Object> getProperties() {
public Map<String, Object> getProperties()
{
return properties;
}
}
Original file line number Diff line number Diff line change
@@ -15,22 +15,27 @@

package com.microsoft.windowsazure;

public class ConfigurationException extends RuntimeException {
public class ConfigurationException extends RuntimeException
{

private static final long serialVersionUID = -5570476914992165380L;

public ConfigurationException() {
public ConfigurationException()
{
}

public ConfigurationException(String message) {
public ConfigurationException(String message)
{
super(message);
}

public ConfigurationException(Throwable cause) {
public ConfigurationException(Throwable cause)
{
super(cause);
}

public ConfigurationException(String message, Throwable cause) {
public ConfigurationException(String message, Throwable cause)
{
super(message, cause);
}
}
27 changes: 18 additions & 9 deletions core/src/main/java/com/microsoft/windowsazure/core/Builder.java
Original file line number Diff line number Diff line change
@@ -16,29 +16,38 @@

import java.util.Map;

public interface Builder {
public interface Builder
{

public abstract <S, T> T build(String profile, Class<S> service, Class<T> instance, Map<String, Object> properties);
public abstract <S, T> T build(String profile, Class<S> service,
Class<T> instance, Map<String, Object> properties);

public interface Factory<T> {
<S> T create(String profile, Class<S> service, Builder builder, Map<String, Object> properties);
public interface Factory<T>
{
<S> T create(String profile, Class<S> service, Builder builder,
Map<String, Object> properties);
}

public interface Alteration<T> {
T alter(String profile, T instance, Builder builder, Map<String, Object> properties);
public interface Alteration<T>
{
T alter(String profile, T instance, Builder builder,
Map<String, Object> properties);
}

public interface Registry {
public interface Registry
{
<T> Registry add(Class<T> service);

<T, TImpl> Registry add(Class<T> service, Class<TImpl> implementation);

<T> Registry add(Factory<T> factory);

<S, T> void alter(Class<S> service, Class<T> instance, Alteration<T> alteration);
<S, T> void alter(Class<S> service, Class<T> instance,
Alteration<T> alteration);
}

public interface Exports {
public interface Exports
{
void register(Registry registry);
}
}
Loading

0 comments on commit 4333e05

Please sign in to comment.