Skip to content

Commit

Permalink
JNDI: orb vs. SimpleJndiName
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Nov 14, 2022
1 parent 2a35465 commit 7d4f90b
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 104 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 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 All @@ -16,37 +17,36 @@

package org.glassfish.enterprise.iiop.api;

import org.glassfish.api.naming.NamespacePrefixes;
import org.glassfish.api.naming.NamedNamingObjectProxy;

import org.jvnet.hk2.annotations.Service;
import jakarta.inject.Inject;

import jakarta.ejb.spi.HandleDelegate;

import jakarta.inject.Inject;
import jakarta.inject.Provider;

import javax.naming.NamingException;

import org.glassfish.api.naming.NamedNamingObjectProxy;
import org.glassfish.api.naming.NamespacePrefixes;
import org.jvnet.hk2.annotations.Service;

import static org.glassfish.api.naming.SimpleJndiName.JNDI_CTX_JAVA_COMPONENT;

/**
* Proxy for java:comp/ORB lookups
*
*
* @author Ken Saks
*/
@Service
@NamespacePrefixes(HandleDelegateNamingProxy.HANDLE_DELEGATE)
public class HandleDelegateNamingProxy implements NamedNamingObjectProxy {

static final String HANDLE_DELEGATE
= "java:comp/HandleDelegate";
static final String HANDLE_DELEGATE = JNDI_CTX_JAVA_COMPONENT + "HandleDelegate";

@Inject
private Provider<HandleDelegateFacade> handleDelegateFacadeProvider;

private volatile HandleDelegateFacade facade;

@Override
public Object handle(String name) throws NamingException {

HandleDelegate delegate = null;

if (HANDLE_DELEGATE.equals(name)) {
Expand All @@ -57,9 +57,8 @@ public Object handle(String name) throws NamingException {
}
delegate = facade.getHandleDelegate();

} catch(Throwable t) {
NamingException ne = new NamingException
("Error resolving java:comp/HandleDelegate lookup");
} catch (Throwable t) {
NamingException ne = new NamingException("Error resolving java:comp/HandleDelegate lookup");
ne.initCause(t);
throw ne;
}
Expand All @@ -68,5 +67,4 @@ public Object handle(String name) throws NamingException {
return delegate;
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 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 @@ -16,32 +17,32 @@

package org.glassfish.enterprise.iiop.api;

import org.glassfish.api.naming.NamespacePrefixes;
import org.glassfish.api.naming.NamedNamingObjectProxy;

import org.jvnet.hk2.annotations.Service;
import jakarta.inject.Inject;

import javax.naming.NamingException;

import org.glassfish.api.naming.NamedNamingObjectProxy;
import org.glassfish.api.naming.NamespacePrefixes;
import org.jvnet.hk2.annotations.Service;
import org.omg.CORBA.ORB;

import javax.naming.NamingException;
import static org.glassfish.api.naming.SimpleJndiName.JNDI_CTX_JAVA_COMPONENT;

/**
* Proxy for java:comp/ORB lookups
*
*
* @author Ken Saks
*/
@Service
@NamespacePrefixes(ORBNamingProxy.ORB_CONTEXT)
public class ORBNamingProxy implements NamedNamingObjectProxy {

static final String ORB_CONTEXT
= "java:comp/ORB";
static final String ORB_CONTEXT = JNDI_CTX_JAVA_COMPONENT + "ORB";

@Inject
private GlassFishORBHelper orbHelper;

@Override
public Object handle(String name) throws NamingException {

ORB orb = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 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 @@ -16,32 +17,32 @@

package org.glassfish.enterprise.iiop.impl;

import java.io.*;
import com.sun.corba.ee.spi.presentation.rmi.StubAdapter;

import jakarta.ejb.*;
import jakarta.ejb.EJBHome;
import jakarta.ejb.EJBObject;
import jakarta.ejb.spi.HandleDelegate;

import java.io.IOException;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import javax.rmi.PortableRemoteObject;

import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.ORB;
import com.sun.corba.ee.spi.presentation.rmi.StubAdapter;

import static org.glassfish.api.naming.SimpleJndiName.JNDI_CTX_JAVA_COMPONENT;

/**
* An implementation of HandleDelegate for the IIOP Protocol.
*
*/

public final class IIOPHandleDelegate
implements HandleDelegate
{
public final class IIOPHandleDelegate implements HandleDelegate {

public static HandleDelegate getHandleDelegate() {
HandleDelegate handleDelegate =
(HandleDelegate) java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
@Override
public Object run() {
try {
ClassLoader cl = new HandleDelegateClassLoader();
Expand All @@ -58,26 +59,30 @@ public Object run() {
}


@Override
public void writeEJBObject(jakarta.ejb.EJBObject ejbObject,
java.io.ObjectOutputStream ostream)
throws java.io.IOException
{
ostream.writeObject(ejbObject); // IIOP stubs are Serializable
}

@Override
public jakarta.ejb.EJBObject readEJBObject(java.io.ObjectInputStream istream)
throws java.io.IOException, ClassNotFoundException
{
return (EJBObject)getStub(istream, EJBObject.class);
}

@Override
public void writeEJBHome(jakarta.ejb.EJBHome ejbHome,
java.io.ObjectOutputStream ostream)
throws java.io.IOException
{
ostream.writeObject(ejbHome); // IIOP stubs are Serializable
}

@Override
public jakarta.ejb.EJBHome readEJBHome(java.io.ObjectInputStream istream)
throws java.io.IOException, ClassNotFoundException
{
Expand Down Expand Up @@ -107,7 +112,7 @@ private Object getStub(java.io.ObjectInputStream istream, Class stubClass)
ORB orb = null;
try {

orb = (ORB) new InitialContext().lookup("java:comp/ORB");
orb = (ORB) new InitialContext().lookup(JNDI_CTX_JAVA_COMPONENT + "ORB");

} catch(NamingException ne) {

Expand All @@ -116,7 +121,7 @@ private Object getStub(java.io.ObjectInputStream istream, Class stubClass)

// Stub is not connected. This can happen if istream is
// not an IIOP input stream (e.g. it's a File stream).
StubAdapter.connect(obj, (com.sun.corba.ee.spi.orb.ORB) orb);
StubAdapter.connect(obj, orb);
}

} else {
Expand All @@ -127,9 +132,7 @@ private Object getStub(java.io.ObjectInputStream istream, Class stubClass)
}

// narrow it
Object stub = PortableRemoteObject.narrow(obj, stubClass);

return stub;
return PortableRemoteObject.narrow(obj, stubClass);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 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 @@ -16,67 +17,54 @@

package org.glassfish.enterprise.iiop.impl;


import jakarta.ejb.NoSuchObjectLocalException;

import java.rmi.Remote;

import java.security.AccessController ;
import java.security.PrivilegedAction ;

import org.omg.CORBA.portable.Delegate;

import org.glassfish.enterprise.iiop.api.RemoteReferenceFactory;

import org.glassfish.enterprise.iiop.spi.EjbContainerFacade;
import org.glassfish.enterprise.iiop.util.S1ASThreadPoolManager;

import org.omg.PortableServer.POA ;
import org.omg.PortableServer.Servant ;
import org.omg.PortableServer.ServantLocator ;
import org.omg.PortableServer.ServantLocatorPackage.CookieHolder ;

import com.sun.logging.LogDomains;

import com.sun.enterprise.deployment.EjbDescriptor;

// TODO Only needed for checkpointing
// import com.sun.ejb.base.sfsb.util.EJBServerConfigLookup;

import com.sun.corba.ee.spi.extension.ServantCachingPolicy;
import com.sun.corba.ee.spi.extension.ZeroPortPolicy;
import com.sun.corba.ee.org.omg.CORBA.SUNVMCID;
import com.sun.corba.ee.spi.extension.CopyObjectPolicy;
import com.sun.corba.ee.spi.extension.RequestPartitioningPolicy;
import com.sun.corba.ee.spi.threadpool.ThreadPoolManager;

import com.sun.corba.ee.spi.presentation.rmi.PresentationManager ;

import com.sun.corba.ee.spi.presentation.rmi.StubAdapter;
import com.sun.corba.ee.spi.oa.rfm.ReferenceFactory ;
import com.sun.corba.ee.spi.oa.rfm.ReferenceFactoryManager ;

import com.sun.corba.ee.spi.misc.ORBConstants;
import com.sun.corba.ee.org.omg.CORBA.SUNVMCID;
import com.sun.corba.ee.spi.extension.ServantCachingPolicy;
import com.sun.corba.ee.spi.extension.ZeroPortPolicy;
import com.sun.corba.ee.spi.ior.IOR;
import com.sun.corba.ee.spi.ior.ObjectKey;
import com.sun.corba.ee.spi.ior.TaggedProfile;
import com.sun.corba.ee.spi.misc.ORBConstants;
import com.sun.corba.ee.spi.oa.rfm.ReferenceFactory;
import com.sun.corba.ee.spi.oa.rfm.ReferenceFactoryManager;
import com.sun.corba.ee.spi.orb.ORB;

import com.sun.corba.ee.spi.presentation.rmi.PresentationManager;
import com.sun.corba.ee.spi.presentation.rmi.StubAdapter;
import com.sun.corba.ee.spi.threadpool.ThreadPoolManager;
import com.sun.enterprise.deployment.EjbDescriptor;
import com.sun.enterprise.util.Utility;
import com.sun.logging.LogDomains;

import jakarta.ejb.NoSuchObjectLocalException;

import org.glassfish.pfl.dynamic.codegen.spi.Wrapper ;
import java.util.List;
import java.util.ArrayList;
import java.util.logging.Level;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.rmi.Remote;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;

import javax.rmi.CORBA.Tie;
import javax.rmi.CORBA.Util;

import org.glassfish.api.naming.SimpleJndiName;
import org.glassfish.enterprise.iiop.api.RemoteReferenceFactory;
import org.glassfish.enterprise.iiop.spi.EjbContainerFacade;
import org.glassfish.enterprise.iiop.util.S1ASThreadPoolManager;
import org.glassfish.pfl.dynamic.codegen.spi.Wrapper;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.OBJECT_NOT_EXIST;
import org.omg.CORBA.Policy;
import org.omg.CORBA.portable.Delegate;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;
import org.omg.PortableServer.ServantLocator;
import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;

/**
* This class implements the RemoteReferenceFactory interface for the
Expand Down Expand Up @@ -270,24 +258,8 @@ private ReferenceFactory createReferenceFactory(String poaId, String repoid ) th
}
}

/** TODO
logger.log(Level.INFO, "POARemoteRefFactory checking if SFSBVersionPolicy need to be added");
EJBServerConfigLookup ejbConfigLookup =
new EJBServerConfigLookup(ejbDescriptor);
boolean addSFSBVersionPolicy = EJBServerConfigLookup.needToAddSFSBVersionInterceptors();
logger.log(Level.INFO, "POARemoteRefFactory addSFSBVersionPolicy? " + addSFSBVersionPolicy);
if (addSFSBVersionPolicy) {
if (container instanceof StatefulSessionContainer) {
StatefulSessionContainer sfsbCon = (StatefulSessionContainer) container;
if (sfsbCon.isHAEnabled()) {
policies.add(new SFSBVersionPolicy(ejbDescriptor.getUniqueId()));
}
}
}
**/

if (logger.isLoggable(Level.FINE)) {
String jndiName = ejbDescriptor.getJndiName();
SimpleJndiName jndiName = ejbDescriptor.getJndiName();
logger.log(Level.FINE, "Using Thread-Pool: [{0} ==> {1}] for jndi name: {2}",
new Object[] {threadPoolName, threadPoolNumericID, jndiName});
logger.log(Level.FINE, "Pass by reference: [{0}] for jndi name: {1}",
Expand Down Expand Up @@ -467,9 +439,8 @@ public Tie run() {
}
}
} catch (NoSuchObjectLocalException e) {
logger.log(Level.SEVERE,"iiop.gettie_exception", e);
throw new OBJECT_NOT_EXIST( GET_TIE_EXCEPTION_CODE,
CompletionStatus.COMPLETED_NO);
logger.log(Level.SEVERE, "Target object not found", e);
throw new OBJECT_NOT_EXIST(GET_TIE_EXCEPTION_CODE, CompletionStatus.COMPLETED_NO);
} catch (RuntimeException e) {
logger.log(Level.SEVERE,"iiop.runtime_exception", e);
throw e;
Expand Down

0 comments on commit 7d4f90b

Please sign in to comment.