-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completed legacy configuration initial implementation
- Loading branch information
Showing
12 changed files
with
1,331 additions
and
986 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/org/jboss/ejb/client/legacy/CommonLegacyConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* 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 org.jboss.ejb.client.legacy; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.xnio.OptionMap; | ||
import org.xnio.Options; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">David M. Lloyd</a> | ||
*/ | ||
final class CommonLegacyConfiguration { | ||
private CommonLegacyConfiguration() { | ||
} | ||
|
||
static URI getUri(final JBossEJBProperties.ConnectionConfiguration connectionConfiguration, final OptionMap connectionOptions) { | ||
final String host = connectionConfiguration.getHost(); | ||
if (host == null) { | ||
return null; | ||
} | ||
final int port = connectionConfiguration.getPort(); | ||
if (port == -1) { | ||
return null; | ||
} | ||
final String protocol; | ||
if (connectionOptions.get(Options.SECURE, false) && connectionOptions.get(Options.SSL_ENABLED, false)) { | ||
protocol = "remote+https"; | ||
} else { | ||
protocol = "remote+http"; | ||
} | ||
try { | ||
return new URI(protocol, null, host, port, null, null, null); | ||
} catch (URISyntaxException e) { | ||
return null; | ||
} | ||
|
||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/org/jboss/ejb/client/legacy/DiscoveryLegacyConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* 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 org.jboss.ejb.client.legacy; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
import org.jboss.ejb._private.Logs; | ||
import org.kohsuke.MetaInfServices; | ||
import org.wildfly.discovery.ServiceURL; | ||
import org.wildfly.discovery.impl.StaticDiscoveryProvider; | ||
import org.wildfly.discovery.spi.DiscoveryProvider; | ||
import org.wildfly.discovery.spi.ExternalDiscoveryConfigurator; | ||
import org.wildfly.discovery.spi.RegistryProvider; | ||
|
||
/** | ||
* The interface to merge EJB properties into the discovery configuration. | ||
* | ||
* @author <a href="mailto:[email protected]">David M. Lloyd</a> | ||
*/ | ||
@MetaInfServices | ||
public final class DiscoveryLegacyConfiguration implements ExternalDiscoveryConfigurator { | ||
public void configure(final Consumer<DiscoveryProvider> discoveryProviderConsumer, final Consumer<RegistryProvider> registryProviderConsumer) { | ||
final JBossEJBProperties ejbProperties = JBossEJBProperties.getCurrent(); | ||
if (ejbProperties == null) { | ||
return; | ||
} | ||
|
||
final List<ServiceURL> list = new ArrayList<>(); | ||
|
||
for (Map.Entry<String, JBossEJBProperties.ClusterConfiguration> entry : ejbProperties.getClusterConfigurations().entrySet()) { | ||
final String name = entry.getKey(); | ||
final JBossEJBProperties.ClusterConfiguration configuration = entry.getValue(); | ||
|
||
// todo: construct URI and map cluster:name to it | ||
} | ||
|
||
if (! list.isEmpty()) { | ||
Logs.MAIN.legacyEJBPropertiesDiscoveryConfigurationInUse(); | ||
discoveryProviderConsumer.accept(new StaticDiscoveryProvider(list)); | ||
} | ||
} | ||
} |
Oops, something went wrong.