summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-01-10 14:23:31 +0200
committerLeif Åstrand <leif@vaadin.com>2013-01-10 18:54:05 +0200
commitd9e9a7db654adb28f32cebac7b490cf8d2b2bcd1 (patch)
tree49b9b66751452115ee399a7fe72babd6f781b63c /client-compiler
parent4516d864b1790b5433bae6eb509371cc39fadd2c (diff)
downloadvaadin-framework-d9e9a7db654adb28f32cebac7b490cf8d2b2bcd1.tar.gz
vaadin-framework-d9e9a7db654adb28f32cebac7b490cf8d2b2bcd1.zip
Enable overriding which connectors are in the widgetset (#10710)
Change-Id: I98d09a1a9c1855e3385b6d48950a45c0388ba0bb
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
index 09aae5b662..f8aa586064 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
@@ -757,12 +757,9 @@ public class ConnectorBundleLoaderFactory extends Generator {
connectorsByLoadStyle.put(loadStyle, new ArrayList<JClassType>());
}
- JClassType connectorType = typeOracle.getType(ServerConnector.class
- .getName());
- JClassType[] subtypes = connectorType.getSubtypes();
-
// Find all types with a valid mapping
- Collection<JClassType> selectedTypes = getMappedTypes(logger, subtypes);
+ Collection<JClassType> selectedTypes = getConnectorsForWidgetset(
+ logger, typeOracle);
// Group by load style
for (JClassType connectorSubtype : selectedTypes) {
@@ -816,8 +813,40 @@ public class ConnectorBundleLoaderFactory extends Generator {
return bundles;
}
- private Collection<JClassType> getMappedTypes(TreeLogger logger,
- JClassType[] types) throws UnableToCompleteException {
+ /**
+ * Returns the connector types that should be included in the widgetset.
+ * This method can be overridden to create a widgetset only containing
+ * selected connectors.
+ * <p>
+ * The default implementation finds all type implementing
+ * {@link ServerConnector} that have a @{@link Connect} annotation. It also
+ * checks that multiple connectors aren't connected to the same server-side
+ * class.
+ *
+ * @param logger
+ * the logger to which information can be logged
+ * @param typeOracle
+ * the type oracle that can be used for finding types
+ * @return a collection of all the connector types that should be included
+ * in the widgetset
+ * @throws UnableToCompleteException
+ * if the operation fails
+ */
+ protected Collection<JClassType> getConnectorsForWidgetset(
+ TreeLogger logger, TypeOracle typeOracle)
+ throws UnableToCompleteException {
+ JClassType serverConnectorType;
+ try {
+ serverConnectorType = typeOracle.getType(ServerConnector.class
+ .getName());
+ } catch (NotFoundException e) {
+ logger.log(Type.ERROR,
+ "Can't find " + ServerConnector.class.getName());
+ throw new UnableToCompleteException();
+ }
+
+ JClassType[] types = serverConnectorType.getSubtypes();
+
Map<String, JClassType> mappings = new HashMap<String, JClassType>();
// Keep track of what has happened to avoid logging intermediate state