Для своего проекта я пытаюсь расширить классы GWT, которые не унаследованы от клиентских модулей. Например, я хочу создать простую реализацию com.google.gwt.resources.ext.ResourceGenerator.
public class SimpleResourceGenerator implements ResourceGenerator
и используйте вместо ClientBundle по умолчанию @ResourceGeneratorType - BundleResourceGenerator
@ResourceGeneratorType(SimpleResourceGenerator.class)
public interface Resources extends ClientBundle {
но безуспешно.
Если я помещу свой класс SimpleResourceGenerator в пакет «клиент», компилятор GWT скажет:
[ERROR] Line 11: No source code is available for type com.google.gwt.resources.ext.ResourceGenerator; did you forget to inherit a required module?
[ERROR] Line 13: No source code is available for type com.google.gwt.core.ext.TreeLogger; did you forget to inherit a required module?
[ERROR] Line 13: No source code is available for type com.google.gwt.resources.ext.ResourceContext; did you forget to inherit a required module?
[ERROR] Line 13: No source code is available for type com.google.gwt.core.ext.typeinfo.JMethod; did you forget to inherit a required module?
[ERROR] Line 14: No source code is available for type com.google.gwt.core.ext.UnableToCompleteException; did you forget to inherit a required module?
[ERROR] Line 19: No source code is available for type com.google.gwt.resources.ext.ClientBundleFields; did you forget to inherit a required module?
[ERROR] Line 36: No source code is available for type com.google.gwt.resources.ext.ClientBundleRequirements; did you forget to inherit a required module?
Если я свяжу все источники gwt-user и gwt-dev с проектом, у меня будут другие неразрешенные зависимости.
Loading inherited module 'com.google.gwt.user.User'
Loading inherited module 'com.google.gwt.animation.Animation'
Loading inherited module 'com.google.gwt.core.Core'
Loading inherited module 'com.google.gwt.core.CrossSiteIframeLinker'
[ERROR] Unable to load class 'com.google.gwt.core.linker.DirectInstallLinker'
java.lang.ClassNotFoundException: com.google.gwt.core.linker.DirectInstallLinker
Я не могу понять компилятор GWT и то, как он разрешает типы во время компиляции. Почему он находит некоторые классы GWT и не может найти другие.
Единственный способ, который я вижу, - это скомпилировать переписывание модуля SimpleResourceGenerator.
<generate-with
class="com.google.gwt.resources.rebind.context.StaticClientBundleGenerator">
<!-- We have to specify on which types to execute the Generator -->
<when-type-assignable
class="com.google.gwt.resources.client.ClientBundle" />
</generate-with>
от унаследованного com.google.gwt.resources.Resources.gwt.xml с собственным генератором
<generate-with
class="com.example.gwt.SimpleBundleGenerator">
<when-type-assignable
class="com.google.gwt.resources.client.ClientBundle" />
</generate-with>
и расширьте com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.
Но мне он кажется слишком сложным. Есть ли более простой способ расширить классы GWT, чем отложенное связывание с помощью генераторов и замены кода?