Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.glassfish.appclient.client.acc.config.TargetServer;
import org.glassfish.appclient.client.acc.config.util.XML;
import org.glassfish.embeddable.client.UserError;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.api.GlassFishORBLocator;
import org.xml.sax.SAXException;

import static java.util.logging.Level.CONFIG;
Expand Down Expand Up @@ -87,7 +87,7 @@ public class AppClientContainerBuilder implements AppClientContainer.Builder {

private boolean sendPassword = true;

private GlassFishORBHelper orbHelper;
private GlassFishORBLocator orbLocator;

/** caller-provided message security configurations */
private final List<MessageSecurityConfig> messageSecurityConfigs = new ArrayList<>();
Expand Down Expand Up @@ -183,7 +183,7 @@ private CallbackHandler getCallbackHandlerFromDescriptor(final String callbackHa

private void prepareHabitat() throws URISyntaxException {
ACCModulesManager.initialize(Thread.currentThread().getContextClassLoader());
orbHelper = ACCModulesManager.getService(GlassFishORBHelper.class);
orbLocator = ACCModulesManager.getService(GlassFishORBLocator.class);
}

/**
Expand Down Expand Up @@ -220,11 +220,10 @@ private void prepareIIOP(final TargetServer[] targetServers, Properties containe
}

if (isSSLRequired(targetServers, containerProperties)) {
orbHelper.setCSIv2Prop(ORB_SSL_CLIENT_REQUIRED, "true");
orbLocator.setCSIv2Prop(ORB_SSL_CLIENT_REQUIRED, "true");
}

logger.log(CONFIG, "Using endpoint address(es): {0}", sb.toString());

}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -24,7 +25,8 @@
import org.glassfish.appclient.client.acc.config.Security;
import org.glassfish.appclient.client.acc.config.TargetServer;
import org.glassfish.embeddable.client.UserError;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;

import static org.glassfish.internal.api.ORBLocator.DEFAULT_ORB_INIT_PORT;

/**
* Encapsulates the logic for deciding what TargetServer objects to use for
Expand All @@ -34,7 +36,7 @@
*/
public class TargetServerHelper {

private static int DEFAULT_ENDPOINT_PORT = Integer.parseInt(GlassFishORBHelper.DEFAULT_ORB_INIT_PORT);
private static int DEFAULT_ENDPOINT_PORT = Integer.parseInt(DEFAULT_ORB_INIT_PORT);
private static final String SSL_PROPERTY_NAME = "ssl";


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -33,7 +33,7 @@
import org.glassfish.api.invocation.ComponentInvocation;
import org.glassfish.api.invocation.InvocationManager;
import org.glassfish.api.naming.SimpleJndiName;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.internal.api.ORBLocator;
import org.jvnet.hk2.annotations.Service;
import org.omg.CORBA.ORB;

Expand All @@ -48,10 +48,10 @@
public class EjbNamingReferenceManagerImpl implements EjbNamingReferenceManager {

@Inject
InvocationManager invMgr;
private InvocationManager invMgr;

@Inject
Provider<GlassFishORBHelper> glassFishORBHelperProvider;
private Provider<ORBLocator> orbLocatorProvider;

@Override
public Object resolveEjbReference(EjbReferenceDescriptor ejbRefDesc, Context context)
Expand Down Expand Up @@ -119,22 +119,17 @@ public Object resolveEjbReference(EjbReferenceDescriptor ejbRefDesc, Context con

ClassLoader origClassLoader = Utility.getClassLoader();
boolean setCL = false;

try {

try {

String refInterface = ejbRefDesc.isEJB30ClientView() ?
ejbRefDesc.getEjbInterface() : ejbRefDesc.getHomeClassName();
String refInterface = ejbRefDesc.isEJB30ClientView()
? ejbRefDesc.getEjbInterface()
: ejbRefDesc.getHomeClassName();
origClassLoader.loadClass(refInterface);

} catch(ClassNotFoundException e) {

ClassLoader referringBundleClassLoader =
ejbRefDesc.getReferringBundleDescriptor().getClassLoader();
Utility.setContextClassLoader(referringBundleClassLoader);
setCL = true;

} catch (ClassNotFoundException e) {
ClassLoader referringBundleClassLoader = ejbRefDesc.getReferringBundleDescriptor().getClassLoader();
Utility.setContextClassLoader(referringBundleClassLoader);
setCL = true;
}

/* For remote ejb refs, first lookup the target remote object
Expand All @@ -147,8 +142,7 @@ public Object resolveEjbReference(EjbReferenceDescriptor ejbRefDesc, Context con
* MEJB resolution for cluster support post V3 FCS.
*/
if (remoteJndiName.hasCorbaPrefix()) {
GlassFishORBHelper orbHelper = glassFishORBHelperProvider.get();
ORB orb = orbHelper.getORB();
ORB orb = orbLocatorProvider.get().getORB();
jndiObj = orb.string_to_object(remoteJndiName.toString());
} else {
jndiObj = context.lookup(remoteJndiName.toString());
Expand Down Expand Up @@ -190,17 +184,13 @@ public Object getEJBContextObject(String contextType) {

if(currentInv == null) {
throw new IllegalStateException("no current invocation");
} else if (currentInv.getInvocationType() !=
ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) {
throw new IllegalStateException
("Illegal invocation type for EJB Context : "
+ currentInv.getInvocationType());
} else if (currentInv.getInvocationType() != ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) {
throw new IllegalStateException(
"Illegal invocation type for EJB Context : " + currentInv.getInvocationType());
}

EjbInvocation ejbInv = (EjbInvocation) currentInv;

Object returnObject = ejbInv.context;

if (contextType.equals("jakarta.ejb.TimerService")) {
if (EJBTimerService.getEJBTimerService() == null) {
throw new IllegalStateException("EJB Timer Service not available");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -25,7 +26,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.api.GlassFishORBLocator;
import org.glassfish.enterprise.iiop.api.ProtocolManager;
import org.glassfish.internal.api.Globals;

Expand Down Expand Up @@ -69,14 +70,8 @@ public Object resolveObject(Object obj)
}
}

/**
* Do all ProtocolManager access lazily and only request orb if it has already been
* initialized so that code doesn't make the assumption that an orb is available in
* this runtime.
*/
private ProtocolManager getProtocolManager() {
GlassFishORBHelper orbHelper = Globals.getDefaultHabitat().getService(GlassFishORBHelper.class);
return orbHelper.isORBInitialized() ? orbHelper.getProtocolManager() : null;
GlassFishORBLocator orbLocator = Globals.getDefaultHabitat().getService(GlassFishORBLocator.class);
return orbLocator.getProtocolManager();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -40,7 +40,7 @@

import org.glassfish.api.naming.GlassfishNamingManager;
import org.glassfish.api.naming.SimpleJndiName;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.api.GlassFishORBLocator;
import org.glassfish.enterprise.iiop.api.ProtocolManager;
import org.glassfish.internal.api.Globals;

Expand Down Expand Up @@ -92,14 +92,9 @@ public Object replaceObject(Object obj) throws IOException {
}


/**
* Do all ProtocolManager access lazily and only request orb if it has already been
* initialized so that code doesn't make the assumption that an orb is available in
* this runtime.
*/
private ProtocolManager getProtocolManager() {
GlassFishORBHelper orbHelper = Globals.getDefaultHabitat().getService(GlassFishORBHelper.class);
return orbHelper.isORBInitialized() ? orbHelper.getProtocolManager() : null;
GlassFishORBLocator orbLocator = Globals.getDefaultHabitat().getService(GlassFishORBLocator.class);
return orbLocator.getProtocolManager();
}


Expand Down Expand Up @@ -199,7 +194,7 @@ protected static java.rmi.Remote doRemoteRefClassLoaderConversion(final java.rmi
byte[] serializedRef = EJBObjectOutputStreamHandler._javaEEIOUtils.serializeObject(reference, false);
Remote returnReference = (java.rmi.Remote) EJBObjectOutputStreamHandler._javaEEIOUtils
.deserializeObject(serializedRef, false, contextClassLoader);
GlassFishORBHelper orbHelper = EjbContainerUtilImpl.getInstance().getORBHelper();
GlassFishORBLocator orbHelper = EjbContainerUtilImpl.getInstance().getOrbLocator();
ProtocolManager protocolMgr = orbHelper.getProtocolManager();
protocolMgr.connectObject(returnReference);
return returnReference;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2025 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -142,7 +142,6 @@
import org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor;
import org.glassfish.ejb.spi.EjbContainerInterceptor;
import org.glassfish.ejb.spi.WSEjbEndpointRegistry;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.api.ProtocolManager;
import org.glassfish.enterprise.iiop.api.RemoteReferenceFactory;
import org.glassfish.enterprise.iiop.spi.EjbContainerFacade;
Expand Down Expand Up @@ -765,9 +764,7 @@ private void addToGeneratedMonitoredMethodInfo(Class generatedClass) {

protected void initializeProtocolManager() {
try {
GlassFishORBHelper orbHelper = ejbContainerUtilImpl.getORBHelper();
protocolMgr = orbHelper.getProtocolManager();

protocolMgr = ejbContainerUtilImpl.getOrbLocator().getProtocolManager();
} catch (Throwable t) {
throw new RuntimeException(
"IIOP Protocol Manager initialization failed. " + "Possible cause is that ORB is not available in this "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -38,7 +38,7 @@
import org.glassfish.api.naming.GlassfishNamingManager;
import org.glassfish.ejb.config.EjbContainer;
import org.glassfish.ejb.config.EjbTimerService;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.api.GlassFishORBLocator;
import org.glassfish.flashlight.provider.ProbeProviderFactory;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.internal.api.ServerContext;
Expand All @@ -64,7 +64,7 @@ public interface EjbContainerUtil {
// Used by the TimerService upgrade
String TIMER_SERVICE_UPGRADED = "ejb-timer-service-upgraded";

GlassFishORBHelper getORBHelper();
GlassFishORBLocator getOrbLocator();

ServiceLocator getServices();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -63,7 +63,7 @@
import org.glassfish.ejb.config.EjbContainer;
import org.glassfish.ejb.config.EjbTimerService;
import org.glassfish.ejb.spi.CMPDeployer;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.api.GlassFishORBLocator;
import org.glassfish.flashlight.provider.ProbeProviderFactory;
import org.glassfish.hk2.api.PostConstruct;
import org.glassfish.hk2.api.PreDestroy;
Expand Down Expand Up @@ -93,7 +93,7 @@ public class EjbContainerUtilImpl implements PostConstruct, PreDestroy, EjbConta
private ServerContext serverContext;

@Inject
JavaEEIOUtils javaEEIOUtils;
private JavaEEIOUtils javaEEIOUtils;

private final Map<Long, BaseContainer> id2Container = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -123,7 +123,7 @@ public class EjbContainerUtilImpl implements PostConstruct, PreDestroy, EjbConta
private EjbContainer ejbContainer;

@Inject
private GlassFishORBHelper orbHelper;
private GlassFishORBLocator orbLocator;

@Inject
private ServerEnvironmentImpl env;
Expand All @@ -138,13 +138,13 @@ public class EjbContainerUtilImpl implements PostConstruct, PreDestroy, EjbConta
private EjbAsyncInvocationManager ejbAsyncInvocationManager;

@Inject
ProbeProviderFactory probeProviderFactory;
private ProbeProviderFactory probeProviderFactory;

@Inject
Domain domain;
private Domain domain;

@Inject
Provider<Deployment> deploymentProvider;
private Provider<Deployment> deploymentProvider;

@Inject
private Provider<CMPDeployer> cmpDeployerProvider;
Expand Down Expand Up @@ -199,8 +199,8 @@ public void preDestroy() {
}

@Override
public GlassFishORBHelper getORBHelper() {
return orbHelper;
public GlassFishORBLocator getOrbLocator() {
return orbLocator;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ public HttpURLConnection get(String relativePath) throws IOException {

private HttpCookie createSession(String relativePath) throws IOException {
final HttpURLConnection connection = openConnection(baseUrl.getPort(), baseUrl.getPath() + "/" + relativePath);
connection.setRequestMethod("GET");
assertThat(connection.getResponseCode(), equalTo(200));
try (InputStream is = connection.getInputStream()) {
final String text = new String(is.readAllBytes(), UTF_8);
assertThat(text,
stringContainsInOrder("<title>Login Page</title>", "Please login", "j_username", "j_password"));
final HttpCookie sessionId = cookieManager.getCookieStore().getCookies().stream()
.filter(c -> c.getName().equals("JSESSIONID")).findFirst().get();
is.readAllBytes();
return sessionId;
try {
connection.setRequestMethod("GET");
assertThat(connection.getResponseCode(), equalTo(200));
try (InputStream is = connection.getInputStream()) {
final String text = new String(is.readAllBytes(), UTF_8);
assertThat(text,
stringContainsInOrder("<title>Login Page</title>", "Please login", "j_username", "j_password"));
final HttpCookie sessionId = cookieManager.getCookieStore().getCookies().stream()
.filter(c -> c.getName().equals("JSESSIONID")).findFirst().get();
is.readAllBytes();
return sessionId;
}
} finally {
connection.disconnect();
}
Expand Down
Loading
Loading