}
if (value instanceof byte[]) {
if (providers == null) {
// try to get Providers from the TLS
RuntimeContext runtimeContext = RuntimeContextTLS.getRuntimeContext();
if (runtimeContext != null) {
providers = runtimeContext.getProviders();
}
if (providers == null) {
LifecycleManagersRegistry ofFactoryRegistry = new LifecycleManagersRegistry();
ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager<Object>());
ProvidersRegistry providersRegistry =
new ProvidersRegistry(ofFactoryRegistry, new ApplicationValidator());
final Set<Class<?>> classes = new ApplicationFileLoader(true).getClasses();
processApplication(providersRegistry, new WinkApplication() {
@Override
public Set<Class<?>> getClasses() {
return classes;
}
@Override
public double getPriority() {
return WinkApplication.SYSTEM_PRIORITY;
}
});
providers = new ProvidersImpl(providersRegistry, runtimeContext);
}
}
/*
* Need to set a temporary RuntimeContextTLS just in case we're
* already outside of the runtime context. This may occur when a
* client app is retrieving the AtomContent value, expecting it to
* be unmarshalled automatically, but we are already outside of the
* client-server thread, and thus no longer have a RuntimeContextTLS
* from which to retrieve or inject providers.
*/
RuntimeContext tempRuntimeContext = RuntimeContextTLS.getRuntimeContext();
if (tempRuntimeContext == null) {
final Providers p = providers;
RuntimeContextTLS.setRuntimeContext(new AbstractRuntimeContext() {
{
setAttribute(Providers.class, p);