Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

OsgiUIProvider.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2000-2016 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.osgi.liferay;
  17. import org.osgi.framework.ServiceObjects;
  18. import com.vaadin.server.UIClassSelectionEvent;
  19. import com.vaadin.server.UIProvider;
  20. import com.vaadin.ui.UI;
  21. /**
  22. * Vaadin {@link com.vaadin.server.UIProvider} that provides a single {@link UI}
  23. * class provided through the registration of a {@link UI} as an OSGi service.
  24. * <p>
  25. * This only applies to Liferay Portal 7+ with OSGi support.
  26. *
  27. * @author Sampsa Sohlman
  28. *
  29. * @since 8.1
  30. */
  31. @SuppressWarnings("serial")
  32. public class OsgiUIProvider extends UIProvider {
  33. private Class<UI> uiClass;
  34. @SuppressWarnings("unchecked")
  35. public OsgiUIProvider(ServiceObjects<UI> serviceObjects) {
  36. super();
  37. UI ui = serviceObjects.getService();
  38. uiClass = (Class<UI>) ui.getClass();
  39. serviceObjects.ungetService(ui);
  40. }
  41. @Override
  42. public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
  43. return uiClass;
  44. }
  45. public String getDefaultPortletName() {
  46. return uiClass.getName();
  47. }
  48. public String getDefaultDisplayName() {
  49. return uiClass.getSimpleName();
  50. }
  51. }