From a8ff4677b357fbf51c4a4fbc8da8c73355c9a1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 1 Dec 2021 12:58:17 +0100 Subject: [PATCH] The jersey-gf-ejb was adopted by the GlassFish as jersey-ejb-component-provider - it was a circular dependency between jersey and glassfish - jersey limited usage of glassfish to versions 4-6, but now started gf7 development - see commit a8cfbe9fc7cd4e662ea044c111569804b5174c2f in glassfish --- containers/glassfish/jersey-gf-ejb/pom.xml | 130 ----- .../ejb/internal/EjbComponentInterceptor.java | 52 -- .../gf/ejb/internal/EjbComponentProvider.java | 471 ------------------ .../gf/ejb/internal/EjbExceptionMapper.java | 84 ---- .../jersey/gf/ejb/internal/package-info.java | 20 - ...ssfish.jersey.server.spi.ComponentProvider | 1 - .../gf/ejb/internal/localization.properties | 29 -- containers/glassfish/pom.xml | 40 -- containers/pom.xml | 1 - 9 files changed, 828 deletions(-) delete mode 100644 containers/glassfish/jersey-gf-ejb/pom.xml delete mode 100644 containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentInterceptor.java delete mode 100644 containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java delete mode 100644 containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbExceptionMapper.java delete mode 100644 containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/package-info.java delete mode 100644 containers/glassfish/jersey-gf-ejb/src/main/resources/META-INF/services/org.glassfish.jersey.server.spi.ComponentProvider delete mode 100644 containers/glassfish/jersey-gf-ejb/src/main/resources/org/glassfish/jersey/gf/ejb/internal/localization.properties delete mode 100644 containers/glassfish/pom.xml diff --git a/containers/glassfish/jersey-gf-ejb/pom.xml b/containers/glassfish/jersey-gf-ejb/pom.xml deleted file mode 100644 index d1174a4405e..00000000000 --- a/containers/glassfish/jersey-gf-ejb/pom.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - 4.0.0 - - - org.glassfish.jersey.containers.glassfish - project - 3.1.0-SNAPSHOT - - - jersey-gf-ejb - jar - jersey-gf-ejb - - Jersey EJB for GlassFish integration - - - - org.glassfish.jersey.ext.cdi - jersey-cdi1x - ${project.version} - provided - - - jakarta.ejb - jakarta.ejb-api - provided - - - jakarta.interceptor - jakarta.interceptor-api - ${jakarta.interceptor.version} - provided - - - jakarta.inject - jakarta.inject-api - provided - - - org.glassfish.jersey.core - jersey-server - ${project.version} - provided - - - org.glassfish.main.ejb - ejb-container - provided - - - org.glassfish.main.common - container-common - provided - - - org.glassfish.main.hk2 - hk2-config - true - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - *.tests.* - - - - - - - com.sun.istack - istack-commons-maven-plugin - true - - - org.codehaus.mojo - build-helper-maven-plugin - true - - - org.apache.felix - maven-bundle-plugin - true - true - - - - - com.sun.*;version="[4.0,7)", - ${jakarta.annotation.osgi.version}, - org.glassfish.ejb.*;version="[4.0,7)", - org.glassfish.internal.*;version="[4.0,7)", - ${hk2.osgi.version}, - * - - - - - - - - diff --git a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentInterceptor.java b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentInterceptor.java deleted file mode 100644 index 82474d15934..00000000000 --- a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentInterceptor.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package org.glassfish.jersey.gf.ejb.internal; - -import jakarta.annotation.PostConstruct; -import jakarta.interceptor.InvocationContext; - -import org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider; -import org.glassfish.jersey.internal.inject.InjectionManager; - -/** - * EJB interceptor to inject Jersey specific stuff into EJB beans. - * - * @author Jakub Podlesak - */ -public final class EjbComponentInterceptor { - - private final InjectionManager injectionManager; - - /** - * Create new EJB component injection manager. - * - * @param injectionManager injection manager. - */ - public EjbComponentInterceptor(final InjectionManager injectionManager) { - this.injectionManager = injectionManager; - } - - @PostConstruct - private void inject(final InvocationContext context) throws Exception { - - final Object beanInstance = context.getTarget(); - injectionManager.inject(beanInstance, CdiComponentProvider.CDI_CLASS_ANALYZER); - - // Invoke next interceptor in chain - context.proceed(); - } -} diff --git a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java deleted file mode 100644 index 6e7ffbde90a..00000000000 --- a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2019 Payara Foundation and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package org.glassfish.jersey.gf.ejb.internal; - -import java.io.Externalizable; -import java.io.Serializable; -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.function.Supplier; -import java.util.logging.Level; -import java.util.logging.Logger; - -import jakarta.ws.rs.ext.ExceptionMapper; - -import jakarta.annotation.Priority; -import jakarta.ejb.Local; -import jakarta.ejb.Remote; -import jakarta.ejb.Stateless; -import jakarta.inject.Singleton; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import org.glassfish.jersey.internal.inject.AbstractBinder; -import org.glassfish.jersey.internal.inject.Binding; -import org.glassfish.jersey.internal.inject.Bindings; -import org.glassfish.jersey.internal.inject.InjectionManager; -import org.glassfish.jersey.internal.inject.InstanceBinding; -import org.glassfish.jersey.server.ApplicationHandler; -import org.glassfish.jersey.server.model.Invocable; -import org.glassfish.jersey.server.spi.ComponentProvider; -import org.glassfish.jersey.server.spi.internal.ResourceMethodInvocationHandlerProvider; - -import org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl; -import org.glassfish.ejb.deployment.descriptor.EjbDescriptor; -import org.glassfish.internal.data.ApplicationInfo; -import org.glassfish.internal.data.ApplicationRegistry; -import org.glassfish.internal.data.ModuleInfo; - -import com.sun.ejb.containers.BaseContainer; -import com.sun.ejb.containers.EjbContainerUtil; -import com.sun.ejb.containers.EjbContainerUtilImpl; -import com.sun.enterprise.config.serverbeans.Application; -import com.sun.enterprise.config.serverbeans.Applications; - -/** - * EJB component provider. - * - * @author Paul Sandoz - * @author Jakub Podlesak - */ -@Priority(300) -@SuppressWarnings("UnusedDeclaration") -public final class EjbComponentProvider implements ComponentProvider, ResourceMethodInvocationHandlerProvider { - - private static final Logger LOGGER = Logger.getLogger(EjbComponentProvider.class.getName()); - - private InitialContext initialContext; - private final List libNames = new CopyOnWriteArrayList<>(); - - private boolean ejbInterceptorRegistered = false; - - /** - * HK2 factory to provide EJB components obtained via JNDI lookup. - */ - private static class EjbFactory implements Supplier { - - final InitialContext ctx; - final Class clazz; - final String beanName; - final EjbComponentProvider ejbProvider; - - @SuppressWarnings("unchecked") - @Override - public T get() { - try { - return (T) lookup(ctx, clazz, beanName, ejbProvider); - } catch (NamingException ex) { - Logger.getLogger(ApplicationHandler.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - private static String getBeanName(final Class clazz) { - final Stateless stateless = clazz.getAnnotation(Stateless.class); - if (stateless != null) { - if (stateless.name().isEmpty()) { - return clazz.getSimpleName(); - } - return stateless.name(); - } - final jakarta.ejb.Singleton singleton = clazz.getAnnotation(jakarta.ejb.Singleton.class); - if (singleton != null) { - if (singleton.name().isEmpty()) { - return clazz.getSimpleName(); - } - return singleton.name(); - } - return clazz.getSimpleName(); - } - - public EjbFactory(Class rawType, InitialContext ctx, EjbComponentProvider ejbProvider) { - this.clazz = rawType; - this.ctx = ctx; - this.ejbProvider = ejbProvider; - this.beanName = getBeanName(rawType); - } - } - - /** - * Annotations to determine EJB components. - */ - private static final Set EjbComponentAnnotations = Collections.unmodifiableSet(new HashSet() {{ - add("jakarta.ejb.Stateful"); - add("jakarta.ejb.Stateless"); - add("jakarta.ejb.Singleton"); - }}); - - private InjectionManager injectionManager = null; - - // ComponentProvider - @Override - public void initialize(final InjectionManager injectionManager) { - this.injectionManager = injectionManager; - - InstanceBinding descriptor = Bindings.service(EjbComponentProvider.this) - .to(ResourceMethodInvocationHandlerProvider.class); - this.injectionManager.register(descriptor); - } - - private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws NamingException { - ApplicationRegistry appRegistry = ejbUtil.getServices().getService(ApplicationRegistry.class); - Applications applications = ejbUtil.getServices().getService(Applications.class); - String appNamePrefix = (String) initialContext.lookup("java:app/AppName"); - Set appNames = appRegistry.getAllApplicationNames(); - Set disabledApps = new TreeSet<>(); - for (String appName : appNames) { - if (appName.startsWith(appNamePrefix)) { - Application appDesc = applications.getApplication(appName); - if (appDesc != null && !ejbUtil.getDeployment().isAppEnabled(appDesc)) { - // skip disabled version of the app - disabledApps.add(appName); - } else { - return ejbUtil.getDeployment().get(appName); - } - } - } - - // grab the latest one, there is no way to make - // sure which one the user is actually enabling, - // so use the best case, i.e. upgrade - Iterator it = disabledApps.iterator(); - String lastDisabledApp = null; - while (it.hasNext()) { - lastDisabledApp = it.next(); - } - if (lastDisabledApp != null) { - return ejbUtil.getDeployment().get(lastDisabledApp); - } - - throw new NamingException("Application Information Not Found"); - } - - private void registerEjbInterceptor(Class component) { - try { - final Object interceptor = new EjbComponentInterceptor(injectionManager); - initialContext = getInitialContext(); - final EjbContainerUtil ejbUtil = EjbContainerUtilImpl.getInstance(); - final ApplicationInfo appInfo = getApplicationInfo(ejbUtil); - for (ModuleInfo moduleInfo : appInfo.getModuleInfos()) { - final String jarName = moduleInfo.getName(); - if (jarName.endsWith(".jar") || jarName.endsWith(".war")) { - final String moduleName = jarName.substring(0, jarName.length() - 4); - final Object bundleDescriptor = moduleInfo.getMetaData(EjbBundleDescriptorImpl.class.getName()); - if (bundleDescriptor instanceof EjbBundleDescriptorImpl) { - final Collection ejbs = ((EjbBundleDescriptorImpl) bundleDescriptor).getEjbs(); - - for (final EjbDescriptor ejb : ejbs) { - final BaseContainer ejbContainer = EjbContainerUtilImpl.getInstance().getContainer(ejb.getUniqueId()); - if (ejbContainer.getEJBClass() != component) { - continue; - } - libNames.add(moduleName); - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Object run() throws Exception { - final Method registerInterceptorMethod = - BaseContainer.class - .getDeclaredMethod("registerSystemInterceptor", java.lang.Object.class); - registerInterceptorMethod.setAccessible(true); - - registerInterceptorMethod.invoke(ejbContainer, interceptor); - return null; - } - }); - } catch (PrivilegedActionException pae) { - final Throwable cause = pae.getCause(); - LOGGER.log(Level.WARNING, - LocalizationMessages.EJB_INTERCEPTOR_BINDING_WARNING(ejb.getEjbClassName()), cause); - } - } - } - } - } - - final Object interceptorBinder = initialContext.lookup("java:org.glassfish.ejb.container.interceptor_binding_spi"); - // Some implementations of InitialContext return null instead of - // throwing NamingException if there is no Object associated with - // the name - if (interceptorBinder == null) { - throw new IllegalStateException(LocalizationMessages.EJB_INTERCEPTOR_BIND_API_NOT_AVAILABLE()); - } - - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Object run() throws Exception { - Method interceptorBinderMethod = interceptorBinder.getClass() - .getMethod("registerInterceptor", java.lang.Object.class); - - interceptorBinderMethod.invoke(interceptorBinder, interceptor); - EjbComponentProvider.this.ejbInterceptorRegistered = true; - LOGGER.log(Level.CONFIG, LocalizationMessages.EJB_INTERCEPTOR_BOUND()); - return null; - } - }); - } catch (PrivilegedActionException pae) { - throw new IllegalStateException(LocalizationMessages.EJB_INTERCEPTOR_CONFIG_ERROR(), pae.getCause()); - } - - } catch (NamingException ex) { - throw new IllegalStateException(LocalizationMessages.EJB_INTERCEPTOR_BIND_API_NOT_AVAILABLE(), ex); - } catch (LinkageError ex) { - throw new IllegalStateException(LocalizationMessages.EJB_INTERCEPTOR_CONFIG_LINKAGE_ERROR(), ex); - } - } - - // ComponentProvider - @SuppressWarnings("unchecked") - @Override - public boolean bind(Class component, Set> providerContracts) { - - if (LOGGER.isLoggable(Level.FINE)) { - LOGGER.fine(LocalizationMessages.EJB_CLASS_BEING_CHECKED(component)); - } - - if (injectionManager == null) { - throw new IllegalStateException(LocalizationMessages.EJB_COMPONENT_PROVIDER_NOT_INITIALIZED_PROPERLY()); - } - - if (!isEjbComponent(component)) { - return false; - } - - if (!ejbInterceptorRegistered) { - registerEjbInterceptor(component); - } - - Binding binding = Bindings.supplier(new EjbFactory(component, initialContext, EjbComponentProvider.this)) - .to(component) - .to(providerContracts); - injectionManager.register(binding); - - if (LOGGER.isLoggable(Level.CONFIG)) { - LOGGER.config(LocalizationMessages.EJB_CLASS_BOUND_WITH_CDI(component)); - } - - return true; - } - - @Override - public void done() { - registerEjbExceptionMapper(); - } - - private void registerEjbExceptionMapper() { - injectionManager.register(new AbstractBinder() { - @Override - protected void configure() { - bind(EjbExceptionMapper.class).to(ExceptionMapper.class).in(Singleton.class); - } - }); - } - - private boolean isEjbComponent(Class component) { - for (Annotation a : component.getAnnotations()) { - if (EjbComponentAnnotations.contains(a.annotationType().getName())) { - return true; - } - } - return false; - } - - @Override - public InvocationHandler create(Invocable method) { - - final Class resourceClass = method.getHandler().getHandlerClass(); - - if (resourceClass == null || !isEjbComponent(resourceClass)) { - return null; - } - - final Method handlingMethod = method.getDefinitionMethod(); - - for (Class iFace : remoteAndLocalIfaces(resourceClass)) { - try { - final Method iFaceMethod = iFace.getDeclaredMethod(handlingMethod.getName(), handlingMethod.getParameterTypes()); - if (iFaceMethod != null) { - return new InvocationHandler() { - @Override - public Object invoke(Object target, Method ignored, Object[] args) - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - return iFaceMethod.invoke(target, args); - } - }; - } - } catch (NoSuchMethodException | SecurityException ex) { - logLookupException(handlingMethod, resourceClass, iFace, ex); - } - } - return null; - } - - private void logLookupException(final Method method, final Class component, Class iFace, Exception ex) { - LOGGER.log( - Level.WARNING, - LocalizationMessages.EJB_INTERFACE_HANDLING_METHOD_LOOKUP_EXCEPTION(method, component, iFace), ex); - } - - private static List remoteAndLocalIfaces(final Class resourceClass) { - final List allLocalOrRemoteIfaces = new LinkedList<>(); - if (resourceClass.isAnnotationPresent(Remote.class)) { - allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Remote.class).value())); - } - if (resourceClass.isAnnotationPresent(Local.class)) { - allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Local.class).value())); - } - for (Class i : resourceClass.getInterfaces()) { - if (i.isAnnotationPresent(Remote.class) || i.isAnnotationPresent(Local.class)) { - allLocalOrRemoteIfaces.add(i); - } - } - if (allLocalOrRemoteIfaces.isEmpty()) { - for (Class i : resourceClass.getInterfaces()) { - if (isAcceptableLocalInterface(i)) { - allLocalOrRemoteIfaces.add(i); - } - } - } - return allLocalOrRemoteIfaces; - } - - private static boolean isAcceptableLocalInterface(final Class iface) { - if ("jakarta.ejb".equals(iface.getPackage().getName())) { - return false; - } - return !Serializable.class.equals(iface) && !Externalizable.class.equals(iface); - } - - private static InitialContext getInitialContext() { - try { - // Deployment on Google App Engine will - // result in a LinkageError - return new InitialContext(); - } catch (Exception ex) { - throw new IllegalStateException(LocalizationMessages.INITIAL_CONTEXT_NOT_AVAILABLE(), ex); - } - } - - private static Object lookup(InitialContext ic, Class rawType, String name, EjbComponentProvider provider) - throws NamingException { - try { - return lookupSimpleForm(ic, rawType, name, provider); - } catch (NamingException ex) { - LOGGER.log(Level.WARNING, LocalizationMessages.EJB_CLASS_SIMPLE_LOOKUP_FAILED(rawType.getName()), ex); - - return lookupFullyQualifiedForm(ic, rawType, name, provider); - } - } - - private static Object lookupSimpleForm( - InitialContext ic, - Class rawType, - String name, - EjbComponentProvider provider) throws NamingException { - if (provider.libNames.isEmpty()) { - String jndiName = "java:module/" + name; - return ic.lookup(jndiName); - } else { - NamingException ne = null; - for (String moduleName : provider.libNames) { - String jndiName = "java:app/" + moduleName + "/" + name; - Object result; - try { - result = ic.lookup(jndiName); - if (result != null && isLookupInstanceValid(rawType, result)) { - return result; - } - } catch (NamingException e) { - ne = e; - } - } - throw (ne != null) ? ne : new NamingException(); - } - } - - private static Object lookupFullyQualifiedForm( - InitialContext ic, - Class rawType, - String name, - EjbComponentProvider provider) throws NamingException { - if (provider.libNames.isEmpty()) { - String jndiName = "java:module/" + name + "!" + rawType.getName(); - return ic.lookup(jndiName); - } else { - NamingException ne = null; - for (String moduleName : provider.libNames) { - String jndiName = "java:app/" + moduleName + "/" + name + "!" + rawType.getName(); - Object result; - try { - result = ic.lookup(jndiName); - if (result != null && isLookupInstanceValid(rawType, result)) { - return result; - } - } catch (NamingException e) { - ne = e; - } - } - throw (ne != null) ? ne : new NamingException(); - } - } - - private static boolean isLookupInstanceValid(Class rawType, Object result){ - return rawType.isInstance(result) - || remoteAndLocalIfaces(rawType) - .stream() - .filter(iface -> iface.isInstance(result)) - .findAny() - .isPresent(); - } -} diff --git a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbExceptionMapper.java b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbExceptionMapper.java deleted file mode 100644 index 175544851b8..00000000000 --- a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbExceptionMapper.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package org.glassfish.jersey.gf.ejb.internal; - -import jakarta.ws.rs.WebApplicationException; -import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.ext.ExceptionMapper; - -import jakarta.ejb.EJBException; -import jakarta.inject.Inject; -import jakarta.inject.Provider; - -import org.glassfish.jersey.spi.ExceptionMappers; -import org.glassfish.jersey.spi.ExtendedExceptionMapper; - -/** - * Helper class to handle exceptions wrapped by the EJB container with EJBException. - * If this mapper was not registered, no {@link WebApplicationException} - * would end up mapped to the corresponding response. - * - * @author Paul Sandoz - * @author Jakub Podlesak - */ -public class EjbExceptionMapper implements ExtendedExceptionMapper { - - private final Provider mappers; - - /** - * Create new EJB exception mapper. - * - * @param mappers utility to find mapper delegate. - */ - @Inject - public EjbExceptionMapper(Provider mappers) { - this.mappers = mappers; - } - - @Override - public Response toResponse(EJBException exception) { - return causeToResponse(exception); - } - - @Override - public boolean isMappable(EJBException exception) { - try { - return (causeToResponse(exception) != null); - } catch (Throwable ignored) { - return false; - } - } - - private Response causeToResponse(EJBException exception) { - - final Exception cause = exception.getCausedByException(); - - if (cause != null) { - - final ExceptionMapper mapper = mappers.get().findMapping(cause); - if (mapper != null && mapper != this) { - - return mapper.toResponse(cause); - - } else if (cause instanceof WebApplicationException) { - - return ((WebApplicationException) cause).getResponse(); - } - } - return null; - } -} diff --git a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/package-info.java b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/package-info.java deleted file mode 100644 index 700cfe753fb..00000000000 --- a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -/** - * Jersey internal package supporting Jersey EJB injections in Glassfish 4 environment. - */ -package org.glassfish.jersey.gf.ejb.internal; diff --git a/containers/glassfish/jersey-gf-ejb/src/main/resources/META-INF/services/org.glassfish.jersey.server.spi.ComponentProvider b/containers/glassfish/jersey-gf-ejb/src/main/resources/META-INF/services/org.glassfish.jersey.server.spi.ComponentProvider deleted file mode 100644 index 2db13b706ca..00000000000 --- a/containers/glassfish/jersey-gf-ejb/src/main/resources/META-INF/services/org.glassfish.jersey.server.spi.ComponentProvider +++ /dev/null @@ -1 +0,0 @@ -org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider diff --git a/containers/glassfish/jersey-gf-ejb/src/main/resources/org/glassfish/jersey/gf/ejb/internal/localization.properties b/containers/glassfish/jersey-gf-ejb/src/main/resources/org/glassfish/jersey/gf/ejb/internal/localization.properties deleted file mode 100644 index 95bbf1c4016..00000000000 --- a/containers/glassfish/jersey-gf-ejb/src/main/resources/org/glassfish/jersey/gf/ejb/internal/localization.properties +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. -# -# This program and the accompanying materials are made available under the -# terms of the Eclipse Public License v. 2.0, which is available at -# http://www.eclipse.org/legal/epl-2.0. -# -# This Source Code may also be made available under the following Secondary -# Licenses when the conditions for such availability set forth in the -# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, -# version 2 with the GNU Classpath Exception, which is available at -# https://www.gnu.org/software/classpath/license.html. -# -# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -# - -initial.context.not.available=InitialContext not found. JAX-RS EJB support is not available. -ejb.interceptor.bind.api.not.available=The EJB interceptor binding API is not available. JAX-RS EJB integration can not be supported. -ejb.interceptor.bind.api.non.conformant=The EJB interceptor binding API does not conform to what is expected. JAX-RS EJB integration can not be supported. -ejb.interceptor.binding.warning=Could not bind EJB intercetor for class, {0}. -ejb.interceptor.bound=The Jersey EJB interceptor is bound. JAX-RS EJB integration support is enabled. -ejb.interceptor.config.error=Error when configuring to use the EJB interceptor binding API. JAX-RS EJB integration can not be supported. -ejb.interceptor.config.security.error=Security issue when configuring to use the EJB interceptor binding API. JAX-RS EJB support is not available. -ejb.interceptor.config.linkage.error=Linkage error when configuring to use the EJB interceptor binding API. JAX-RS EJB integration can not be supported. -ejb.component.provider.not.initialized.properly=EJB component provider has not been initialized properly. -ejb.class.simple.lookup.failed=An instance of EJB class, {0}, could not be looked up using simple form name. Attempting to look up using the fully-qualified form name. -ejb.interface.handling.method.lookup.exception=Exception thrown when trying to lookup actual handling method, {0}, for EJB type, {1}, using interface {2}. -ejb.class.being.checked=Class, {0}, is being checked with Jersey EJB component provider. -ejb.class.bound.with.cdi=Class, {0}, has been bound by Jersey EJB component provider. diff --git a/containers/glassfish/pom.xml b/containers/glassfish/pom.xml deleted file mode 100644 index 031e637d854..00000000000 --- a/containers/glassfish/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - 4.0.0 - - - org.glassfish.jersey.containers - project - 3.1.0-SNAPSHOT - - - org.glassfish.jersey.containers.glassfish - project - pom - jersey-glassfish-support - - Jersey GlassFish container providers umbrella project module - - - jersey-gf-ejb - - - diff --git a/containers/pom.xml b/containers/pom.xml index c245bceea3a..564a4bff938 100644 --- a/containers/pom.xml +++ b/containers/pom.xml @@ -34,7 +34,6 @@ Jersey container providers umbrella project module - glassfish grizzly2-http grizzly2-servlet jdk-http