org.cruxframework.crux.plugin.gadget.linker
Class GadgetLinker

java.lang.Object
  extended by com.google.gwt.core.ext.Linker
      extended by com.google.gwt.core.ext.linker.AbstractLinker
          extended by com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
              extended by com.google.gwt.core.linker.CrossSiteIframeLinker
                  extended by org.cruxframework.crux.plugin.gadget.linker.GadgetLinker

@LinkerOrder(value=PRIMARY)
@Shardable
public final class GadgetLinker
extends com.google.gwt.core.linker.CrossSiteIframeLinker

A Gadget does not use the .nocache.js file for the bootstrap. All bootstrap code is inserted inside the gadget manifest file (the .gadget.xml file).

The linker also needs to change some script templates to integrate the application with the gadget container. All requests for resources must be piped through the gadget proxy (using gadgets.io.getProxyUrl() method).

Author:
Thiago da Rosa de Bustamante

Field Summary
 
Fields inherited from class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
COMPUTE_SCRIPT_BASE_JS, FRAGMENT_EXTENSION, FRAGMENT_SUBDIR, permutationsUtil, PROCESS_METAS_JS, USE_SOURCE_MAPS_PROPERTY
 
Constructor Summary
GadgetLinker()
           
 
Method Summary
protected  com.google.gwt.core.ext.linker.EmittedArtifact emitSelectionScript(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.LinkerContext context, com.google.gwt.core.ext.linker.ArtifactSet artifacts)
          This method changes the gwt default behavior to emit the selection script into the manifest file.
protected  String fillSelectionScriptTemplate(StringBuffer selectionScript, com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.LinkerContext context, com.google.gwt.core.ext.linker.ArtifactSet artifacts, com.google.gwt.core.ext.linker.CompilationResult result)
          Locale handling is different for gadgets, so we need to insert a specific script for it.
 String getDescription()
           
protected  String getJsComputeScriptBase(com.google.gwt.core.ext.LinkerContext context)
           
protected  String getJsComputeUrlForResource(com.google.gwt.core.ext.LinkerContext context)
           
protected  String getJsInstallScript(com.google.gwt.core.ext.LinkerContext context)
           
protected  String getJsProcessMetas(com.google.gwt.core.ext.LinkerContext context)
           
protected  String getJsSetGadgetLocale(com.google.gwt.core.ext.LinkerContext context)
          Gets the setLocale template for gadgets
protected  String getJsWaitForBodyLoaded(com.google.gwt.core.ext.LinkerContext context)
           
protected  String getSelectionScriptTemplate(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.LinkerContext context)
           
 com.google.gwt.core.ext.linker.ArtifactSet link(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.LinkerContext context, com.google.gwt.core.ext.linker.ArtifactSet artifacts, boolean onePermutation)
          We need to save the original artifactSet received here to be able to re-emit the selection script when relink(TreeLogger, LinkerContext, ArtifactSet) method is called.
 com.google.gwt.core.ext.linker.ArtifactSet relink(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.LinkerContext context, com.google.gwt.core.ext.linker.ArtifactSet newArtifacts)
          We must re-emit the selection script here, once the script is placed on the gadget manifest file.
 
Methods inherited from class com.google.gwt.core.linker.CrossSiteIframeLinker
getBooleanConfigurationProperty, getCompilationExtension, getDeferredFragmentSuffix, getHostedFilename, getHostedFilenameFull, getJsDevModeRedirectHook, getJsInstallLocation, getJsIsBodyLoaded, getJsLoadExternalStylesheets, getJsModuleFunctionErrorCatch, getJsPermutations, getJsProperties, getJsRunAsync, getModulePrefix, getModuleSuffix, getScriptChunkSeparator, getStringConfigurationProperty, includeJs, maybeAddHostedModeFile, maybeOutputPropertyMap, shouldIncludeBootstrapInPrimaryFragment, shouldInstallCode, shouldUseSelfForWindowAndDocument, wrapDeferredFragment, wrapPrimaryFragment
 
Methods inherited from class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
charsPerChunk, doEmitCompilation, emitSelectionInformation, generateDeferredFragment, generatePrimaryFragment, generatePrimaryFragmentString, generateSelectionScript, generateSelectionScript, getDeferredFragmentPrefix, getFragmentSubdir, getModulePrefix, link, readFileToStringBuffer, replaceAll, splitPrimaryJavaScript, supportsDevModeInJunit
 
Methods inherited from class com.google.gwt.core.ext.linker.AbstractLinker
emitBytes, emitBytes, emitInputStream, emitInputStream, emitString, emitString, emitWithStrongName, emitWithStrongName
 
Methods inherited from class com.google.gwt.core.ext.Linker
isShardable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GadgetLinker

public GadgetLinker()
Method Detail

getDescription

public String getDescription()
Overrides:
getDescription in class com.google.gwt.core.linker.CrossSiteIframeLinker
See Also:
CrossSiteIframeLinker.getDescription()

link

public com.google.gwt.core.ext.linker.ArtifactSet link(com.google.gwt.core.ext.TreeLogger logger,
                                                       com.google.gwt.core.ext.LinkerContext context,
                                                       com.google.gwt.core.ext.linker.ArtifactSet artifacts,
                                                       boolean onePermutation)
                                                throws com.google.gwt.core.ext.UnableToCompleteException
We need to save the original artifactSet received here to be able to re-emit the selection script when relink(TreeLogger, LinkerContext, ArtifactSet) method is called.

Overrides:
link in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
Throws:
com.google.gwt.core.ext.UnableToCompleteException
See Also:
SelectionScriptLinker.link(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, com.google.gwt.core.ext.linker.ArtifactSet, boolean)

relink

public com.google.gwt.core.ext.linker.ArtifactSet relink(com.google.gwt.core.ext.TreeLogger logger,
                                                         com.google.gwt.core.ext.LinkerContext context,
                                                         com.google.gwt.core.ext.linker.ArtifactSet newArtifacts)
                                                  throws com.google.gwt.core.ext.UnableToCompleteException
We must re-emit the selection script here, once the script is placed on the gadget manifest file.

It is necessary because the HTML code for the page is also placed on this same file. If we do not re-generate the manifest file, hot deployment would not work for .crux.xml files.

Overrides:
relink in class com.google.gwt.core.ext.Linker
Throws:
com.google.gwt.core.ext.UnableToCompleteException
See Also:
Linker.relink(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, com.google.gwt.core.ext.linker.ArtifactSet)

emitSelectionScript

protected com.google.gwt.core.ext.linker.EmittedArtifact emitSelectionScript(com.google.gwt.core.ext.TreeLogger logger,
                                                                             com.google.gwt.core.ext.LinkerContext context,
                                                                             com.google.gwt.core.ext.linker.ArtifactSet artifacts)
                                                                      throws com.google.gwt.core.ext.UnableToCompleteException
This method changes the gwt default behavior to emit the selection script into the manifest file.

Overrides:
emitSelectionScript in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
Throws:
com.google.gwt.core.ext.UnableToCompleteException
See Also:
SelectionScriptLinker.emitSelectionScript(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, com.google.gwt.core.ext.linker.ArtifactSet)

fillSelectionScriptTemplate

protected String fillSelectionScriptTemplate(StringBuffer selectionScript,
                                             com.google.gwt.core.ext.TreeLogger logger,
                                             com.google.gwt.core.ext.LinkerContext context,
                                             com.google.gwt.core.ext.linker.ArtifactSet artifacts,
                                             com.google.gwt.core.ext.linker.CompilationResult result)
                                      throws com.google.gwt.core.ext.UnableToCompleteException
Locale handling is different for gadgets, so we need to insert a specific script for it.

Overrides:
fillSelectionScriptTemplate in class com.google.gwt.core.linker.CrossSiteIframeLinker
Throws:
com.google.gwt.core.ext.UnableToCompleteException
See Also:
CrossSiteIframeLinker.fillSelectionScriptTemplate(java.lang.StringBuffer, com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, com.google.gwt.core.ext.linker.ArtifactSet, com.google.gwt.core.ext.linker.CompilationResult)

getJsComputeUrlForResource

protected String getJsComputeUrlForResource(com.google.gwt.core.ext.LinkerContext context)
Overrides:
getJsComputeUrlForResource in class com.google.gwt.core.linker.CrossSiteIframeLinker

getJsSetGadgetLocale

protected String getJsSetGadgetLocale(com.google.gwt.core.ext.LinkerContext context)
Gets the setLocale template for gadgets


getJsComputeScriptBase

protected String getJsComputeScriptBase(com.google.gwt.core.ext.LinkerContext context)
Overrides:
getJsComputeScriptBase in class com.google.gwt.core.linker.CrossSiteIframeLinker
See Also:
CrossSiteIframeLinker.getJsComputeScriptBase(com.google.gwt.core.ext.LinkerContext)

getJsInstallScript

protected String getJsInstallScript(com.google.gwt.core.ext.LinkerContext context)
Overrides:
getJsInstallScript in class com.google.gwt.core.linker.CrossSiteIframeLinker
See Also:
CrossSiteIframeLinker.getJsInstallScript(com.google.gwt.core.ext.LinkerContext)

getJsProcessMetas

protected String getJsProcessMetas(com.google.gwt.core.ext.LinkerContext context)
Overrides:
getJsProcessMetas in class com.google.gwt.core.linker.CrossSiteIframeLinker
See Also:
CrossSiteIframeLinker.getJsProcessMetas(com.google.gwt.core.ext.LinkerContext)

getJsWaitForBodyLoaded

protected String getJsWaitForBodyLoaded(com.google.gwt.core.ext.LinkerContext context)
Overrides:
getJsWaitForBodyLoaded in class com.google.gwt.core.linker.CrossSiteIframeLinker
See Also:
CrossSiteIframeLinker.getJsWaitForBodyLoaded(com.google.gwt.core.ext.LinkerContext)

getSelectionScriptTemplate

protected String getSelectionScriptTemplate(com.google.gwt.core.ext.TreeLogger logger,
                                            com.google.gwt.core.ext.LinkerContext context)
Overrides:
getSelectionScriptTemplate in class com.google.gwt.core.linker.CrossSiteIframeLinker
See Also:
CrossSiteIframeLinker.getSelectionScriptTemplate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext)


Copyright © 2014. All rights reserved.