|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Reference(cardinality = ReferenceCardinality.MULTIPLE, service = OsgiVaadinTheme.class, policy = ReferencePolicy.DYNAMIC) |
|
|
@Reference(cardinality = ReferenceCardinality.MULTIPLE, service = OsgiVaadinTheme.class, policy = ReferencePolicy.DYNAMIC) |
|
|
void bindTheme(ServiceReference<OsgiVaadinTheme> themeRef) |
|
|
void bindTheme(ServiceReference<OsgiVaadinTheme> themeRef) |
|
|
throws ResourceBundleInactiveException { |
|
|
|
|
|
|
|
|
throws ResourceBundleInactiveException, NamespaceException { |
|
|
|
|
|
|
|
|
Bundle bundle = themeRef.getBundle(); |
|
|
Bundle bundle = themeRef.getBundle(); |
|
|
BundleContext context = bundle.getBundleContext(); |
|
|
BundleContext context = bundle.getBundleContext(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Reference(cardinality = ReferenceCardinality.MULTIPLE, service = OsgiVaadinWidgetset.class, policy = ReferencePolicy.DYNAMIC) |
|
|
@Reference(cardinality = ReferenceCardinality.MULTIPLE, service = OsgiVaadinWidgetset.class, policy = ReferencePolicy.DYNAMIC) |
|
|
void bindWidgetset(ServiceReference<OsgiVaadinWidgetset> widgetsetRef) |
|
|
void bindWidgetset(ServiceReference<OsgiVaadinWidgetset> widgetsetRef) |
|
|
throws ResourceBundleInactiveException { |
|
|
|
|
|
|
|
|
throws ResourceBundleInactiveException, NamespaceException { |
|
|
Bundle bundle = widgetsetRef.getBundle(); |
|
|
Bundle bundle = widgetsetRef.getBundle(); |
|
|
BundleContext context = bundle.getBundleContext(); |
|
|
BundleContext context = bundle.getBundleContext(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Reference(cardinality = ReferenceCardinality.MULTIPLE, service = OsgiVaadinResource.class, policy = ReferencePolicy.DYNAMIC) |
|
|
@Reference(cardinality = ReferenceCardinality.MULTIPLE, service = OsgiVaadinResource.class, policy = ReferencePolicy.DYNAMIC) |
|
|
void bindResource(ServiceReference<OsgiVaadinResource> resourceRef) |
|
|
void bindResource(ServiceReference<OsgiVaadinResource> resourceRef) |
|
|
throws ResourceBundleInactiveException { |
|
|
|
|
|
|
|
|
throws ResourceBundleInactiveException, NamespaceException { |
|
|
Bundle bundle = resourceRef.getBundle(); |
|
|
Bundle bundle = resourceRef.getBundle(); |
|
|
BundleContext context = bundle.getBundleContext(); |
|
|
BundleContext context = bundle.getBundleContext(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long serviceId = (Long) contributorRef |
|
|
Long serviceId = (Long) contributorRef |
|
|
.getProperty(Constants.SERVICE_ID); |
|
|
.getProperty(Constants.SERVICE_ID); |
|
|
List<ServiceRegistration<? extends OsgiVaadinResource>> registrations = contributorToRegistrations |
|
|
List<ServiceRegistration<? extends OsgiVaadinResource>> registrations = contributorToRegistrations |
|
|
.get(serviceId); |
|
|
|
|
|
|
|
|
.remove(serviceId); |
|
|
if (registrations != null) { |
|
|
if (registrations != null) { |
|
|
for (ServiceRegistration<? extends OsgiVaadinResource> reg : registrations) { |
|
|
for (ServiceRegistration<? extends OsgiVaadinResource> reg : registrations) { |
|
|
reg.unregister(); |
|
|
reg.unregister(); |
|
|
|
|
|
|
|
|
@Activate |
|
|
@Activate |
|
|
protected void activate() throws NamespaceException { |
|
|
protected void activate() throws NamespaceException { |
|
|
for (Delegate registration : resourceToRegistration.values()) { |
|
|
for (Delegate registration : resourceToRegistration.values()) { |
|
|
registration.init(httpService); |
|
|
|
|
|
httpService.registerResources(registration.alias, registration.path, |
|
|
|
|
|
registration); |
|
|
|
|
|
|
|
|
registerResource(registration); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void registerTheme(VaadinResourceService resourceService, |
|
|
private void registerTheme(VaadinResourceService resourceService, |
|
|
Bundle bundle, Long serviceId, OsgiVaadinTheme theme) { |
|
|
|
|
|
|
|
|
Bundle bundle, Long serviceId, OsgiVaadinTheme theme) |
|
|
|
|
|
throws NamespaceException { |
|
|
String pathPrefix = resourceService.getResourcePathPrefix(); |
|
|
String pathPrefix = resourceService.getResourcePathPrefix(); |
|
|
|
|
|
|
|
|
String alias = PathFormatHelper.getThemeAlias(theme.getName(), |
|
|
String alias = PathFormatHelper.getThemeAlias(theme.getName(), |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void registerWidget(VaadinResourceService resourceService, |
|
|
private void registerWidget(VaadinResourceService resourceService, |
|
|
Bundle bundle, Long serviceId, OsgiVaadinWidgetset widgetset) { |
|
|
|
|
|
|
|
|
Bundle bundle, Long serviceId, OsgiVaadinWidgetset widgetset) |
|
|
|
|
|
throws NamespaceException { |
|
|
String pathPrefix = resourceService.getResourcePathPrefix(); |
|
|
String pathPrefix = resourceService.getResourcePathPrefix(); |
|
|
|
|
|
|
|
|
String alias = PathFormatHelper.getWidgetsetAlias(widgetset.getName(), |
|
|
String alias = PathFormatHelper.getWidgetsetAlias(widgetset.getName(), |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void registerResource(VaadinResourceService resourceService, |
|
|
private void registerResource(VaadinResourceService resourceService, |
|
|
Bundle bundle, Long serviceId, OsgiVaadinResource resource) { |
|
|
|
|
|
|
|
|
Bundle bundle, Long serviceId, OsgiVaadinResource resource) |
|
|
|
|
|
throws NamespaceException { |
|
|
String pathPrefix = resourceService.getResourcePathPrefix(); |
|
|
String pathPrefix = resourceService.getResourcePathPrefix(); |
|
|
|
|
|
|
|
|
String alias = PathFormatHelper.getRootResourceAlias(resource.getName(), |
|
|
String alias = PathFormatHelper.getRootResourceAlias(resource.getName(), |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void registerResource(String alias, String path, Bundle bundle, |
|
|
private void registerResource(String alias, String path, Bundle bundle, |
|
|
Long serviceId) { |
|
|
|
|
|
resourceToRegistration.put(serviceId, |
|
|
|
|
|
new Delegate(alias, path, bundle)); |
|
|
|
|
|
|
|
|
Long serviceId) throws NamespaceException { |
|
|
|
|
|
Delegate registration = new Delegate(alias, path, bundle); |
|
|
|
|
|
resourceToRegistration.put(serviceId, registration); |
|
|
|
|
|
registerResource(registration); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void registerResource(Delegate registration) |
|
|
|
|
|
throws NamespaceException { |
|
|
|
|
|
if (this.httpService != null && !registration.isInitialized()) { |
|
|
|
|
|
registration.init(httpService); |
|
|
|
|
|
httpService.registerResources(registration.alias, registration.path, |
|
|
|
|
|
registration); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void unregisterResource(Long serviceId) { |
|
|
private void unregisterResource(Long serviceId) { |
|
|
|
|
|
|
|
|
context = service.createDefaultHttpContext(); |
|
|
context = service.createDefaultHttpContext(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isInitialized() { |
|
|
|
|
|
return context != null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean handleSecurity(HttpServletRequest request, |
|
|
public boolean handleSecurity(HttpServletRequest request, |
|
|
HttpServletResponse response) throws IOException { |
|
|
HttpServletResponse response) throws IOException { |