private static BlobStorageAdapter getInstance() throws IOException { Delegate<?> apiProxyDelegate = ApiProxy.getDelegate(); if (instance == null || instance.apiProxyDelegate != apiProxyDelegate) { try { instance = new BlobStorageAdapter(apiProxyDelegate); } catch (Exception e) { throw new IOException(e); } } return instance; } }
/** * Install our hook in the delegate system. This happens automatically when this class is * loaded, which is typically what you want when working with Objectify. It gets a lot * more complicated when you're working with the RemoteApiInstaller. */ public static synchronized void install() { // Already installed if (ApiProxy.getDelegate() instanceof TriggerFutureHook) return; @SuppressWarnings("unchecked") TriggerFutureHook hook = new TriggerFutureHook(ApiProxy.getDelegate()); if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) ApiProxy.setDelegate(hook); else ApiProxy.setDelegate(wrapPartially(ApiProxy.getDelegate(), hook)); }
static RawGcsService createRawGcsService(Map<String, String> headers) { ImmutableSet.Builder<HTTPHeader> builder = ImmutableSet.builder(); if (headers != null) { for (Map.Entry<String, String> header : headers.entrySet()) { builder.add(new HTTPHeader(header.getKey(), header.getValue())); } } RawGcsService rawGcsService; Value location = SystemProperty.environment.value(); if (location == SystemProperty.Environment.Value.Production || hasCustomAccessTokenProvider()) { rawGcsService = OauthRawGcsServiceFactory.createOauthRawGcsService(builder.build()); } else if (location == SystemProperty.Environment.Value.Development) { rawGcsService = LocalRawGcsServiceFactory.createLocalRawGcsService(); } else { Delegate<?> delegate = ApiProxy.getDelegate(); if (delegate == null || delegate.getClass().getName().startsWith("com.google.appengine.tools.development")) { rawGcsService = LocalRawGcsServiceFactory.createLocalRawGcsService(); } else { rawGcsService = OauthRawGcsServiceFactory.createOauthRawGcsService(builder.build()); } } return rawGcsService; }
@Override protected void doStart() throws Exception { this.helper = createHelper(); this.environment = ApiProxy.getCurrentEnvironment(); getServletContext().setAttribute(API_PROXY_LOCAL, ApiProxy.getDelegate()); getServletContext().setAttribute(APPENGINE_WEB_XML, readAppengineWebXml()); getServletContext().setAttribute(WEB_XML, readWebXml()); SystemProperty.environment.set(SystemProperty.Environment.Value.Development); configureUserRealmAppengineHelper(); super.doStart(); }