Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSGi support for Flow 2.x in npm mode #9187

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions flow-osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-server</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.osgi</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2000-2020 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.flow.osgi.support;

import java.util.stream.Stream;

import org.osgi.service.component.annotations.Component;

import com.vaadin.flow.di.DefaultInstantiator;
import com.vaadin.flow.di.Instantiator;
import com.vaadin.flow.di.InstantiatorFactory;
import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.i18n.I18NProvider;
import com.vaadin.flow.server.VaadinService;
import com.vaadin.flow.server.VaadinServiceInitListener;

/**
denis-anisimov marked this conversation as resolved.
Show resolved Hide resolved
* @author Vaadin Ltd
* @since
*
*/
@Component(immediate = true, service = InstantiatorFactory.class)
public class OSGiInstantiatorFactory implements InstantiatorFactory {

private static final class OsgiInstantiator extends DefaultInstantiator
implements Instantiator {

private final Lookup lookup;
denis-anisimov marked this conversation as resolved.
Show resolved Hide resolved

private OsgiInstantiator(VaadinService service) {
super(service);

lookup = service.getContext().getAttribute(Lookup.class);
}

@Override
public Stream<VaadinServiceInitListener> getServiceInitListeners() {
return lookup.lookupAll(VaadinServiceInitListener.class).stream();
}

@Override
public I18NProvider getI18NProvider() {
I18NProvider provider = super.getI18NProvider();
if (provider == null) {
provider = lookup.lookup(I18NProvider.class);
}
return provider;
}
}

@Override
public Instantiator createInstantitor(VaadinService service) {
return new OsgiInstantiator(service);
}

}
12 changes: 0 additions & 12 deletions flow-push/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,13 @@
<artifactId>atmosphere-runtime</artifactId>
<version>${atmosphere.runtime.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-osgi</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.core.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>${osgi.compendium.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions flow-server/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Bundle-Version: ${osgi.bundle.version}
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
Import-Package: org.atmosphere*;resolution:=optional;version='${atmosphere.runtime.version}',\
org.apache.http*;resolution:=optional;,\
*
Export-Package: com.vaadin.flow.client,\
!com.vaadin.flow.push*, com.vaadin.flow*;-noimport:=true
Expand Down
6 changes: 6 additions & 0 deletions flow-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@
<version>${osgi.core.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
denis-anisimov marked this conversation as resolved.
Show resolved Hide resolved
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>${osgi.compendium.version}</version>
<scope>provided</scope>
</dependency>

</dependencies>

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public Stream<VaadinServiceInitListener> getServiceInitListeners() {

@Override
public <T> T getOrCreate(Class<T> type) {
return create(type);
Lookup lookup = service.getContext().getAttribute(Lookup.class);
T result = lookup == null ? null : lookup.lookup(type);
return result == null ? create(type) : result;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ public interface Instantiator extends Serializable {
* @return <code>true</code> if this instance should be considered as a
* candidate for usage for the provided service; <code>false</code>
* to opt-out from the selection process
* @deprecated The {@link Instantiator} instance should be created by an
* {@link InstantiatorFactory} which should just return
* {@code null} if the provided {@code service} can't be handled
* by it
*/
@Deprecated
boolean init(VaadinService service);

/**
Expand Down
Loading