mirror of https://github.com/apache/jclouds.git
centralize TypeToken creation
This commit is contained in:
parent
63d203325f
commit
22a301b640
|
@ -23,6 +23,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
|||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX;
|
||||
import static org.jclouds.chef.config.ChefProperties.CHEF_BOOTSTRAP_DATABAG;
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
@ -34,7 +35,6 @@ import org.jclouds.ohai.config.JMXOhaiModule;
|
|||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -87,7 +87,7 @@ public class ChefApiMetadata extends BaseRestApiMetadata {
|
|||
.documentation(URI.create("http://wiki.opscode.com/display/chef/Server+API"))
|
||||
.defaultEndpoint("http://localhost:4000")
|
||||
.defaultProperties(ChefApiMetadata.defaultProperties())
|
||||
.context(TypeToken.of(ChefContext.class))
|
||||
.context(typeTokenOf(ChefContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(ChefRestClientModule.class, ChefParserModule.class, JMXOhaiModule.class));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.chef;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -29,7 +31,6 @@ import org.jclouds.providers.ProviderMetadata;
|
|||
import org.jclouds.providers.Providers;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -124,7 +125,7 @@ public class ChefContextFactory {
|
|||
return ChefContext.class.cast(context);
|
||||
} else if (context instanceof View) {
|
||||
View tctx = View.class.cast(context);
|
||||
return tctx.unwrap(TypeToken.of(ChefContext.class));
|
||||
return tctx.unwrap(typeTokenOf(ChefContext.class));
|
||||
} else {
|
||||
throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: "
|
||||
+ context.getClass().getSimpleName());
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.chef.config;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
@ -32,7 +34,6 @@ import org.jclouds.scriptbuilder.domain.Statement;
|
|||
import org.jclouds.scriptbuilder.statements.chef.InstallChefGems;
|
||||
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
|
@ -45,7 +46,7 @@ import com.google.inject.name.Names;
|
|||
public class ChefRestClientModule extends BaseChefRestClientModule<ChefApi, ChefAsyncApi> {
|
||||
|
||||
public ChefRestClientModule() {
|
||||
super(TypeToken.of(ChefApi.class), TypeToken.of(ChefAsyncApi.class));
|
||||
super(typeTokenOf(ChefApi.class), typeTokenOf(ChefAsyncApi.class));
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.chef;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
|
@ -49,7 +50,7 @@ public class ChefApiLiveTest extends BaseChefApiLiveTest<ChefContext> {
|
|||
@Override
|
||||
protected TypeToken<ChefContext> contextType()
|
||||
{
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.chef.internal;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.config.ChefRestClientModule;
|
||||
|
@ -71,6 +73,6 @@ public class BaseStubbedOhaiLiveTest extends BaseChefContextLiveTest<ChefContext
|
|||
@Override
|
||||
protected TypeToken<ChefContext> contextType()
|
||||
{
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
|
@ -72,7 +74,7 @@ public class CleanupStaleNodesAndClientsImplLiveTest extends BaseChefContextLive
|
|||
@Override
|
||||
protected TypeToken<ChefContext> contextType()
|
||||
{
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -74,7 +75,7 @@ public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseCh
|
|||
@Override
|
||||
protected TypeToken<ChefContext> contextType()
|
||||
{
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
|
@ -77,6 +79,6 @@ public class DeleteAllApisAndNodesInListImplLiveTest extends BaseChefContextLive
|
|||
@Override
|
||||
protected TypeToken<ChefContext> contextType()
|
||||
{
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
|
@ -94,7 +95,7 @@ public class GetNodesImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
|
|||
@Override
|
||||
protected TypeToken<ChefContext> contextType()
|
||||
{
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -73,6 +74,6 @@ public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefContext
|
|||
@Override
|
||||
protected TypeToken<ChefContext> contextType()
|
||||
{
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.chef.test;
|
||||
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static org.jclouds.reflect.Reflection2.typeTokenOf;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
|
@ -105,6 +106,6 @@ public class TransientChefApiIntegrationTest extends BaseChefContextLiveTest<Che
|
|||
|
||||
@Override
|
||||
protected TypeToken<ChefContext> contextType() {
|
||||
return TypeToken.of(ChefContext.class);
|
||||
return typeTokenOf(ChefContext.class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue