You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WidgetMap.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client;
  17. import java.util.HashMap;
  18. import java.util.Map;
  19. /**
  20. * Abstract class mapping between {@link ComponentConnector} instances and their
  21. * instances.
  22. *
  23. * A concrete implementation of this class is generated by WidgetMapGenerator or
  24. * one of its subclasses during widgetset compilation.
  25. */
  26. abstract class WidgetMap {
  27. protected static Map<Class<? extends ServerConnector>, WidgetInstantiator> instmap = new HashMap<>();
  28. /**
  29. * Create a new instance of a connector based on its type.
  30. *
  31. * @param classType
  32. * {@link ComponentConnector} class to instantiate
  33. * @return new instance of the connector
  34. */
  35. public ServerConnector instantiate(
  36. Class<? extends ServerConnector> classType) {
  37. return instmap.get(classType).get();
  38. }
  39. /**
  40. * Return the connector class to use for a fully qualified server side
  41. * component class name.
  42. *
  43. * @param fullyqualifiedName
  44. * fully qualified name of the server side component class
  45. * @return component connector class to use
  46. */
  47. public abstract Class<? extends ServerConnector> getConnectorClassForServerSideClassName(
  48. String fullyqualifiedName);
  49. /**
  50. * Return the connector classes to load after the initial widgetset load and
  51. * start.
  52. *
  53. * @return component connector class to load after the initial widgetset
  54. * loading
  55. */
  56. public abstract Class<? extends ServerConnector>[] getDeferredLoadedConnectors();
  57. /**
  58. * Make sure the code for a (deferred or lazy) component connector type has
  59. * been loaded, triggering the load and waiting for its completion if
  60. * necessary.
  61. *
  62. * @param classType
  63. * component connector class
  64. */
  65. public abstract void ensureInstantiator(
  66. Class<? extends ServerConnector> classType);
  67. }