Skip to content

Commit

Permalink
Completed legacy configuration initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Jan 25, 2017
1 parent a23d13b commit f7fded6
Show file tree
Hide file tree
Showing 12 changed files with 1,331 additions and 986 deletions.
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

<properties>
<version.org.jboss.invocation>1.5.0.Beta3</version.org.jboss.invocation>
<version.org.jboss.logging.jboss-logging>3.1.4.GA</version.org.jboss.logging.jboss-logging>
<version.org.jboss.logging.jboss-logging-processor>1.1.0.Final</version.org.jboss.logging.jboss-logging-processor>
<version.org.jboss.logging.jboss-logging>3.3.0.Final</version.org.jboss.logging.jboss-logging>
<version.org.jboss.logging.jboss-logging-tools>2.0.1.Final</version.org.jboss.logging.jboss-logging-tools>
<version.org.jboss.logmanager>1.5.2.Final</version.org.jboss.logmanager>
<version.org.jboss.marshalling>2.0.0.Beta2</version.org.jboss.marshalling>
<version.org.jboss.modules>1.4.3.Final</version.org.jboss.modules>
Expand All @@ -49,7 +49,7 @@
<version.org.jboss.spec.javax.transaction>1.0.0.Final</version.org.jboss.spec.javax.transaction>
<version.org.jboss.xnio>3.4.2.Final</version.org.jboss.xnio>
<version.org.kohsuke.metainf-services>1.7</version.org.kohsuke.metainf-services>
<version.org.wildfly.common>1.2.0.Beta3</version.org.wildfly.common>
<version.org.wildfly.common>1.2.0.Beta4-SNAPSHOT</version.org.wildfly.common>
<version.org.wildfly.naming.client>1.0.0.Beta8</version.org.wildfly.naming.client>
<version.org.wildfly.discovery>1.0.0.Beta5</version.org.wildfly.discovery>
<version.org.wildfly.security.elytron>1.1.0.Beta17</version.org.wildfly.security.elytron>
Expand Down Expand Up @@ -151,7 +151,14 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<version>${version.org.jboss.logging.jboss-logging-processor}</version>
<version>${version.org.jboss.logging.jboss-logging-tools}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
<version>${version.org.jboss.logging.jboss-logging-tools}</version>
<scope>provided</scope>
</dependency>

Expand Down
31 changes: 30 additions & 1 deletion src/main/java/org/jboss/ejb/_private/Logs.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.Once;
import org.jboss.logging.annotations.Property;
import org.jboss.remoting3.Channel;

Expand Down Expand Up @@ -242,7 +243,9 @@ public interface Logs extends BasicLogger {
IllegalStateException cannotSpecifyBothPlainTextAndEncodedPassword();

// @Message(id = 57, value = "%s not of type org.jboss.ejb.client.DeploymentNodeSelector")
// @Message(id = 58, value = "Could not create the deployment node selector")

@Message(id = 58, value = "Failed to instantiate deployment node selector class \"%s\"")
IllegalArgumentException cannotInstantiateDeploymentNodeSelector(String name, @Cause ReflectiveOperationException e);

@LogMessage(level = WARN)
@Message(id = 59, value = "Could not send a message over remoting channel, to cancel invocation for invocation id %s")
Expand Down Expand Up @@ -274,6 +277,32 @@ public interface Logs extends BasicLogger {
@Message(id = 67, value = "Cannot convert %s to stateful")
IllegalArgumentException cannotConvertToStateful(EJBLocator<?> locator);

@Message(id = 68, value = "Failed to instantiate callback handler class \"%s\"")
IllegalArgumentException cannotInstantiateCallbackHandler(String name, @Cause ReflectiveOperationException e);

@Once
@LogMessage
@Message(id = 69, value = "Using legacy jboss-ejb-client.properties security configuration")
void legacyEJBPropertiesSecurityConfigurationInUse();

@Once
@LogMessage
@Message(id = 70, value = "Using legacy jboss-ejb-client.properties Remoting configuration")
void legacyEJBPropertiesRemotingConfigurationInUse();

@Once
@LogMessage
@Message(id = 71, value = "Using legacy jboss-ejb-client.properties discovery configuration")
void legacyEJBPropertiesDiscoveryConfigurationInUse();

@Once
@LogMessage
@Message(id = 72, value = "Using legacy jboss-ejb-client.properties EJB client configuration")
void legacyEJBPropertiesEJBConfigurationInUse();

@Message(id = 73, value = "Failed to construct Remoting endpoint")
IllegalStateException failedToConstructEndpoint(@Cause IOException e);

// Proxy API errors

@Message(id = 100, value = "Object '%s' is not a valid proxy object")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@

package org.jboss.ejb.client;

import static javax.xml.stream.XMLStreamConstants.*;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Iterator;
import java.util.Properties;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.function.Supplier;

import org.jboss.ejb._private.Logs;
import org.jboss.ejb.client.legacy.LegacyPropertiesConfiguration;
import org.jboss.ejb.client.legacy.LegacyPropertiesLoader;
import org.jboss.ejb.client.legacy.RemotingConnectionConfiguration;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
Expand All @@ -63,27 +60,15 @@ private static EJBClientContext loadConfiguration() {
final ClientConfiguration clientConfiguration = ClientConfiguration.getInstance();
final ClassLoader classLoader = ConfigurationBasedEJBClientContextSelector.class.getClassLoader();
final EJBClientContext.Builder builder = new EJBClientContext.Builder();
loadTransportProviders(builder, classLoader);
if (clientConfiguration != null) try {
try (final ConfigurationXMLStreamReader streamReader = clientConfiguration.readConfiguration(Collections.singleton(NS_EJB_CLIENT_3_0))) {
parseEJBClientConfiguration(streamReader, builder);
}
loadTransportProviders(builder, classLoader);
} catch (ConfigXMLParseException e) {
throw new IllegalStateException(e);
}
final Properties props = LegacyPropertiesLoader.loadEJBClientProperties();
final LegacyPropertiesConfiguration configuration = new LegacyPropertiesConfiguration(props);
for (RemotingConnectionConfiguration connectionConfiguration : configuration.getConnectionConfigurations()) {
final String uriString = connectionConfiguration.getProtocol() + "://" + connectionConfiguration.getHost() + ":" + connectionConfiguration.getPort();
try {
URI uri = new URI(uriString);
final EJBClientConnection.Builder connectionBuilder = new EJBClientConnection.Builder();
connectionBuilder.setDestination(uri);
builder.addClientConnection(connectionBuilder.build());
} catch (URISyntaxException e) {
new IllegalStateException(e);
}
}
LegacyPropertiesConfiguration.configure(builder);
return builder.build();
}

Expand Down
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;
}

}
}
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));
}
}
}
Loading

0 comments on commit f7fded6

Please sign in to comment.