-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use guice as apollo-client ioc mechanism
- Loading branch information
Showing
74 changed files
with
834 additions
and
985 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
apollo-client/src/main/java/com/ctrip/framework/apollo/build/ApolloInjector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.ctrip.framework.apollo.build; | ||
|
||
import com.ctrip.framework.apollo.exceptions.ApolloConfigException; | ||
import com.ctrip.framework.apollo.internals.Injector; | ||
import com.ctrip.framework.apollo.tracer.Tracer; | ||
import com.ctrip.framework.foundation.internals.ServiceBootstrap; | ||
|
||
/** | ||
* @author Jason Song([email protected]) | ||
*/ | ||
public class ApolloInjector { | ||
private static Injector s_injector; | ||
private static Object lock = new Object(); | ||
|
||
private static Injector getInjector() { | ||
if (s_injector == null) { | ||
synchronized (lock) { | ||
if (s_injector == null) { | ||
try { | ||
s_injector = ServiceBootstrap.loadFirst(Injector.class); | ||
} catch (Throwable ex) { | ||
ApolloConfigException exception = new ApolloConfigException("Unable to initialize Apollo Injector!", ex); | ||
Tracer.logError(exception); | ||
throw exception; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return s_injector; | ||
} | ||
|
||
public static <T> T getInstance(Class<T> clazz) { | ||
try { | ||
return getInjector().getInstance(clazz); | ||
} catch (Throwable ex) { | ||
Tracer.logError(ex); | ||
throw new ApolloConfigException(String.format("Unable to load instance for type %s!", clazz.getName()), ex); | ||
} | ||
} | ||
|
||
public static <T> T getInstance(Class<T> clazz, String name) { | ||
try { | ||
return getInjector().getInstance(clazz, name); | ||
} catch (Throwable ex) { | ||
Tracer.logError(ex); | ||
throw new ApolloConfigException( | ||
String.format("Unable to load instance for type %s and name %s !", clazz.getName(), name), ex); | ||
} | ||
} | ||
} |
41 changes: 0 additions & 41 deletions
41
apollo-client/src/main/java/com/ctrip/framework/apollo/build/ComponentConfigurator.java
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
apollo-client/src/main/java/com/ctrip/framework/apollo/ds/ApolloDataSourceProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.