Skip to content

Commit

Permalink
Adds StreamClientConfiguration to createStreamClient (jupnp#134)
Browse files Browse the repository at this point in the history
Signed-off-by: morph166955 <[email protected]>
  • Loading branch information
morph166955 authored Mar 24, 2021
1 parent a1cd440 commit 146579c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.jupnp.transport.spi.NetworkAddressFactory;
import org.jupnp.transport.spi.SOAPActionProcessor;
import org.jupnp.transport.spi.StreamClient;
import org.jupnp.transport.spi.StreamClientConfiguration;
import org.jupnp.transport.spi.StreamServer;
import org.jupnp.util.Exceptions;

Expand Down Expand Up @@ -110,6 +111,7 @@ public class DefaultUpnpServiceConfiguration implements UpnpServiceConfiguration
final private ServiceDescriptorBinder serviceDescriptorBinderUDA10;

final private Namespace namespace;
private StreamClientConfiguration configuration;

@SuppressWarnings("rawtypes")
final private TransportConfiguration transportConfiguration;
Expand Down Expand Up @@ -173,7 +175,7 @@ public GENAEventProcessor getGenaEventProcessor() {
@Override
@SuppressWarnings("rawtypes")
public StreamClient createStreamClient() {
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService());
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService(), configuration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.jupnp.transport.spi.NetworkAddressFactory;
import org.jupnp.transport.spi.SOAPActionProcessor;
import org.jupnp.transport.spi.StreamClient;
import org.jupnp.transport.spi.StreamClientConfiguration;
import org.jupnp.transport.spi.StreamServer;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
Expand Down Expand Up @@ -90,6 +91,7 @@ public class OSGiUpnpServiceConfiguration implements UpnpServiceConfiguration {
private int httpProxyPort = -1;
private int streamListenPort = 8080;
private Namespace callbackURI = new Namespace("http://localhost/upnpcallback");
private StreamClientConfiguration configuration;

private ExecutorService mainExecutorService;
private ExecutorService asyncExecutorService;
Expand Down Expand Up @@ -193,7 +195,7 @@ public GENAEventProcessor getGenaEventProcessor() {
@Override
@SuppressWarnings("rawtypes")
public StreamClient createStreamClient() {
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService());
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService(), configuration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface TransportConfiguration<SCC extends StreamClientConfiguration, S
* @param executorService used to dispatch request/response processing.
* @return created {@link StreamClient}
*/
StreamClient<SCC> createStreamClient(final ExecutorService executorService);
StreamClient<SCC> createStreamClient(final ExecutorService executorService, final StreamClientConfiguration configuration);

/**
* Creates a {@link StreamServer} using the given {@code listenerPort}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jupnp.transport.impl.ServletStreamServerConfigurationImpl;
import org.jupnp.transport.impl.ServletStreamServerImpl;
import org.jupnp.transport.spi.StreamClient;
import org.jupnp.transport.spi.StreamClientConfiguration;
import org.jupnp.transport.spi.StreamServer;

/**
Expand All @@ -19,7 +20,7 @@ public class JettyTransportConfiguration
public static final TransportConfiguration INSTANCE = new JettyTransportConfiguration();

@Override
public StreamClient createStreamClient(final ExecutorService executorService) {
public StreamClient createStreamClient(final ExecutorService executorService, final StreamClientConfiguration configuration) {
return new JettyStreamClientImpl(
new StreamClientConfigurationImpl(
executorService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jupnp.transport.TransportConfiguration;
import org.jupnp.transport.impl.jetty.JettyTransportConfiguration;
import org.jupnp.transport.spi.StreamClient;
import org.jupnp.transport.spi.StreamClientConfiguration;
import org.jupnp.transport.spi.StreamServer;

/**
Expand All @@ -28,6 +29,7 @@
public class JettyServerJettyClientTest extends StreamServerClientTest {

private TransportConfiguration jettyTransportConfiguration = JettyTransportConfiguration.INSTANCE;
private StreamClientConfiguration sccConfiguration;

@Override
public StreamServer createStreamServer(final int port) {
Expand All @@ -37,7 +39,7 @@ public StreamServer createStreamServer(final int port) {
@Override
public StreamClient createStreamClient(UpnpServiceConfiguration configuration) {
return jettyTransportConfiguration.createStreamClient(
configuration.getSyncProtocolExecutorService()
configuration.getSyncProtocolExecutorService(), sccConfiguration
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jupnp.transport.impl.NetworkAddressFactoryImpl;
import org.jupnp.transport.spi.NetworkAddressFactory;
import org.jupnp.transport.spi.StreamClient;
import org.jupnp.transport.spi.StreamClientConfiguration;
import org.jupnp.transport.spi.StreamServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -70,6 +71,8 @@ public static void setMulticastResponsePort(Integer port) {

private TransportConfiguration transportConfiguration;

private StreamClientConfiguration configuration;

// instance methods

public CmdlineUPnPServiceConfiguration() {
Expand Down Expand Up @@ -149,7 +152,7 @@ protected void shutdownExecutorServices() {
@Override
public StreamClient createStreamClient() {
return transportConfiguration.createStreamClient(
getSyncProtocolExecutorService()
getSyncProtocolExecutorService(), configuration
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.jupnp.transport.TransportConfiguration;
import org.jupnp.transport.spi.StreamClient;
import org.jupnp.transport.spi.StreamClientConfiguration;
import org.jupnp.transport.spi.StreamServer;

/**
Expand All @@ -15,9 +16,10 @@ public class JDKTransportConfiguration
implements TransportConfiguration {

public static final TransportConfiguration INSTANCE = new JDKTransportConfiguration();
private StreamClientConfiguration configuration;

@Override
public StreamClient createStreamClient(final ExecutorService executorService) {
public StreamClient createStreamClient(final ExecutorService executorService, final StreamClientConfiguration configuration) {
return new StreamClientImpl(
new StreamClientConfigurationImpl(
executorService
Expand Down

0 comments on commit 146579c

Please sign in to comment.