Skip to content

Commit

Permalink
[WFLY-5403] Adapt ejb3 subsystem to the new client library
Browse files Browse the repository at this point in the history
  • Loading branch information
tadamski committed Dec 1, 2016
1 parent e1088bd commit 5da9242
Show file tree
Hide file tree
Showing 63 changed files with 1,144 additions and 2,075 deletions.
Expand Up @@ -48,8 +48,6 @@
import org.jboss.as.server.deployment.SetupAction; import org.jboss.as.server.deployment.SetupAction;
import org.jboss.as.server.deployment.reflect.ClassReflectionIndex; import org.jboss.as.server.deployment.reflect.ClassReflectionIndex;
import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex; import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex;
import org.jboss.ejb.client.EJBClientConfiguration;
import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;
import org.jboss.metadata.appclient.spec.ApplicationClientMetaData; import org.jboss.metadata.appclient.spec.ApplicationClientMetaData;
import org.jboss.modules.Module; import org.jboss.modules.Module;
import org.wildfly.security.manager.WildFlySecurityManager; import org.wildfly.security.manager.WildFlySecurityManager;
Expand Down Expand Up @@ -122,7 +120,6 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
final List<SetupAction> setupActions = deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.OTHER_EE_SETUP_ACTIONS); final List<SetupAction> setupActions = deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.OTHER_EE_SETUP_ACTIONS);


if (connectionPropertiesUrl != null) { if (connectionPropertiesUrl != null) {
EJBClientConfiguration configuration;
try { try {
final File file = new File(connectionPropertiesUrl); final File file = new File(connectionPropertiesUrl);
final URL url; final URL url;
Expand All @@ -148,21 +145,8 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try { try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader()); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
configuration = new PropertiesBasedEJBClientConfiguration(properties);

//if there is no username or callback handler specified in the ejb-client properties file
//we override the default
if (!properties.contains("username") && !properties.contains("callback.handler.class")) {
//no security config so we wrap the configuration
configuration = new ForwardingEjbClientConfiguration(configuration) {
@Override
public CallbackHandler getCallbackHandler() {
return callbackHandler;
}
};
}


startService = new ApplicationClientStartService(mainMethod, parameters, moduleDescription.getNamespaceContextSelector(), module.getClassLoader(), setupActions, configuration); startService = new ApplicationClientStartService(mainMethod, parameters, moduleDescription.getNamespaceContextSelector(), module.getClassLoader(), setupActions);
} finally { } finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
} }
Expand Down

This file was deleted.

Expand Up @@ -21,9 +21,9 @@
*/ */
package org.jboss.as.appclient.service; package org.jboss.as.appclient.service;


import static org.jboss.as.appclient.logging.AppClientLogger.ROOT_LOGGER;

import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
Expand All @@ -35,10 +35,6 @@
import org.jboss.as.ee.naming.InjectedEENamespaceContextSelector; import org.jboss.as.ee.naming.InjectedEENamespaceContextSelector;
import org.jboss.as.naming.context.NamespaceContextSelector; import org.jboss.as.naming.context.NamespaceContextSelector;
import org.jboss.as.server.deployment.SetupAction; import org.jboss.as.server.deployment.SetupAction;
import org.jboss.ejb.client.ContextSelector;
import org.jboss.ejb.client.EJBClientConfiguration;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;
import org.jboss.msc.service.Service; import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceContainer; import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceName;
Expand All @@ -48,8 +44,6 @@
import org.jboss.msc.value.InjectedValue; import org.jboss.msc.value.InjectedValue;
import org.wildfly.security.manager.WildFlySecurityManager; import org.wildfly.security.manager.WildFlySecurityManager;


import static org.jboss.as.appclient.logging.AppClientLogger.ROOT_LOGGER;



/** /**
* Service that is responsible for running an application clients main method, and shutting down the server once it * Service that is responsible for running an application clients main method, and shutting down the server once it
Expand All @@ -69,7 +63,6 @@ public class ApplicationClientStartService implements Service<ApplicationClientS
private final Method mainMethod; private final Method mainMethod;
private final String[] parameters; private final String[] parameters;
private final ClassLoader classLoader; private final ClassLoader classLoader;
private final ContextSelector<EJBClientContext> contextSelector;


private Thread thread; private Thread thread;
private ComponentInstance instance; private ComponentInstance instance;
Expand All @@ -80,16 +73,14 @@ public ApplicationClientStartService(final Method mainMethod, final String[] par
this.namespaceContextSelectorInjectedValue = namespaceContextSelectorInjectedValue; this.namespaceContextSelectorInjectedValue = namespaceContextSelectorInjectedValue;
this.classLoader = classLoader; this.classLoader = classLoader;
this.setupActions = setupActions; this.setupActions = setupActions;
this.contextSelector = new LazyConnectionContextSelector(hostUrl, callbackHandler, classLoader);
} }


public ApplicationClientStartService(final Method mainMethod, final String[] parameters, final InjectedEENamespaceContextSelector namespaceContextSelectorInjectedValue, final ClassLoader classLoader, final List<SetupAction> setupActions, final EJBClientConfiguration configuration) { public ApplicationClientStartService(final Method mainMethod, final String[] parameters, final InjectedEENamespaceContextSelector namespaceContextSelectorInjectedValue, final ClassLoader classLoader, final List<SetupAction> setupActions) {
this.mainMethod = mainMethod; this.mainMethod = mainMethod;
this.parameters = parameters; this.parameters = parameters;
this.namespaceContextSelectorInjectedValue = namespaceContextSelectorInjectedValue; this.namespaceContextSelectorInjectedValue = namespaceContextSelectorInjectedValue;
this.classLoader = classLoader; this.classLoader = classLoader;
this.setupActions = setupActions; this.setupActions = setupActions;
this.contextSelector = new ConfigBasedEJBClientContextSelector(configuration);
} }
@Override @Override
public synchronized void start(final StartContext context) throws StartException { public synchronized void start(final StartContext context) throws StartException {
Expand All @@ -101,10 +92,8 @@ public synchronized void start(final StartContext context) throws StartException
public void run() { public void run() {
final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try { try {
try {
try { try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
AccessController.doPrivileged(new SetSelectorAction(contextSelector));
applicationClientDeploymentServiceInjectedValue.getValue().getDeploymentCompleteLatch().await(); applicationClientDeploymentServiceInjectedValue.getValue().getDeploymentCompleteLatch().await();
NamespaceContextSelector.setDefault(namespaceContextSelectorInjectedValue); NamespaceContextSelector.setDefault(namespaceContextSelectorInjectedValue);


Expand Down Expand Up @@ -138,11 +127,7 @@ public void run() {
} finally { } finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
} }
} finally {
if(contextSelector instanceof LazyConnectionContextSelector) {
((LazyConnectionContextSelector)contextSelector).close();
}
}
} finally { } finally {
serviceContainer.shutdown(); serviceContainer.shutdown();
} }
Expand Down Expand Up @@ -182,18 +167,4 @@ public InjectedValue<Component> getApplicationClientComponent() {
return applicationClientComponent; return applicationClientComponent;
} }



private static final class SetSelectorAction implements PrivilegedAction<ContextSelector<EJBClientContext>> {

private final ContextSelector<EJBClientContext> selector;

private SetSelectorAction(final ContextSelector<EJBClientContext> selector) {
this.selector = selector;
}

@Override
public ContextSelector<EJBClientContext> run() {
return EJBClientContext.setSelector(selector);
}
}
} }

This file was deleted.

5 changes: 5 additions & 0 deletions ejb3/pom.xml
Expand Up @@ -193,6 +193,11 @@ projects that depend on this project.-->
<groupId>org.jboss.spec.javax.xml.rpc</groupId> <groupId>org.jboss.spec.javax.xml.rpc</groupId>
<artifactId>jboss-jaxrpc-api_1.1_spec</artifactId> <artifactId>jboss-jaxrpc-api_1.1_spec</artifactId>
</dependency> </dependency>

<dependency>
<groupId>org.wildfly.discovery</groupId>
<artifactId>wildfly-discovery-client</artifactId>
</dependency>


<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
Expand Down
Expand Up @@ -38,12 +38,12 @@ public class EjbMetadataInterceptor implements Interceptor {


private final InjectedValue<ComponentView> homeView = new InjectedValue<ComponentView>(); private final InjectedValue<ComponentView> homeView = new InjectedValue<ComponentView>();
private final Class<?> remoteClass; private final Class<?> remoteClass;
private final Class<?> homeClass; private final Class<? extends EJBHome> homeClass;
private final Class<?> pkClass; private final Class<?> pkClass;
private final boolean session; private final boolean session;
private final boolean stateless; private final boolean stateless;


public EjbMetadataInterceptor(Class<?> remoteClass, Class<?> homeClass, Class<?> pkClass, boolean session, boolean stateless) { public EjbMetadataInterceptor(Class<?> remoteClass, Class<? extends EJBHome> homeClass, Class<?> pkClass, boolean session, boolean stateless) {
this.remoteClass = remoteClass; this.remoteClass = remoteClass;
this.homeClass = homeClass; this.homeClass = homeClass;
this.pkClass = pkClass; this.pkClass = pkClass;
Expand Down

0 comments on commit 5da9242

Please sign in to comment.