Search in sources :

Example 1 with GlassfishNamingManager

use of org.glassfish.api.naming.GlassfishNamingManager in project Payara by payara.

the class GlassFishORBHelper method getORB.

/**
 * Get or create the default orb.  This can be called for any process type.  However,
 * protocol manager and CosNaming initialization only take place for the Server.
 */
public ORB getORB() {
    // and allow an invocation to the transport to complete.
    if (orb == null) {
        synchronized (this) {
            if (orb == null) {
                try {
                    final boolean isServer = processEnv.getProcessType().isServer();
                    Properties props = new Properties();
                    props.setProperty(GlassFishORBFactory.ENV_IS_SERVER_PROPERTY, Boolean.valueOf(isServer).toString());
                    // Create orb and make it visible.  This will allow
                    // loopback calls to getORB() from
                    // portable interceptors activated as a side-effect of the
                    // remaining initialization. If it's a
                    // server, there's a small time window during which the
                    // ProtocolManager won't be available.  Any callbacks that
                    // result from the protocol manager initialization itself
                    // cannot depend on having access to the protocol manager.
                    orb = getORBFactory().createORB(props);
                    if (isServer) {
                        if (protocolManager == null) {
                            ProtocolManager tempProtocolManager = protocolManagerProvider.get();
                            tempProtocolManager.initialize(orb);
                            // Move startup of naming to PEORBConfigurator so it runs
                            // before interceptors.
                            // tempProtocolManager.initializeNaming();
                            tempProtocolManager.initializePOAs();
                            // Now make protocol manager visible.
                            protocolManager = tempProtocolManager;
                            GlassfishNamingManager namingManager = glassfishNamingManagerProvider.get();
                            Remote remoteSerialProvider = namingManager.initializeRemoteNamingSupport(orb);
                            protocolManager.initializeRemoteNaming(remoteSerialProvider);
                        }
                    }
                } catch (Exception e) {
                    orb = null;
                    protocolManager = null;
                    throw new RuntimeException("Orb initialization erorr", e);
                }
            }
        }
    }
    return orb;
}
Also used : Remote(java.rmi.Remote) Properties(java.util.Properties) GlassfishNamingManager(org.glassfish.api.naming.GlassfishNamingManager)

Example 2 with GlassfishNamingManager

use of org.glassfish.api.naming.GlassfishNamingManager in project Payara by payara.

the class AppTest method testBind.

@Test
public void testBind() {
    GlassfishNamingManager nm = null;
    try {
        InvocationManager im = new InvocationManagerImpl();
        InitialContext ic = newInitialContext();
        nm = new GlassfishNamingManagerImpl(ic);
        nm.publishObject("foo", "Hello: foo", false);
        System.out.println("**lookup() ==> " + ic.lookup("foo"));
        assert (true);
    } catch (Exception ex) {
        ex.printStackTrace();
        assert (false);
    } finally {
        try {
            nm.unpublishObject("foo");
        } catch (Exception ex) {
        }
    }
}
Also used : InvocationManagerImpl(org.glassfish.api.invocation.InvocationManagerImpl) InvocationManager(org.glassfish.api.invocation.InvocationManager) GlassfishNamingManager(org.glassfish.api.naming.GlassfishNamingManager) InitialContext(javax.naming.InitialContext) NamingException(javax.naming.NamingException) InvocationException(org.glassfish.api.invocation.InvocationException)

Example 3 with GlassfishNamingManager

use of org.glassfish.api.naming.GlassfishNamingManager in project Payara by payara.

the class MEJBService method postConstruct.

public void postConstruct() {
    GlassfishNamingManager gfNamingManager = gfNamingManagerProvider.get();
    MEJBNamingObjectProxy mejbProxy = new MEJBNamingObjectProxy(habitat);
    for (String next : MEJBNamingObjectProxy.getJndiNames()) {
        try {
            gfNamingManager.publishObject(next, mejbProxy, true);
        } catch (Exception e) {
            _logger.log(Level.WARNING, "Problem in publishing temp proxy for MEJB: " + e.getMessage(), e);
        }
    }
}
Also used : GlassfishNamingManager(org.glassfish.api.naming.GlassfishNamingManager)

Aggregations

GlassfishNamingManager (org.glassfish.api.naming.GlassfishNamingManager)3 Remote (java.rmi.Remote)1 Properties (java.util.Properties)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1 InvocationException (org.glassfish.api.invocation.InvocationException)1 InvocationManager (org.glassfish.api.invocation.InvocationManager)1 InvocationManagerImpl (org.glassfish.api.invocation.InvocationManagerImpl)1