Search in sources :

Example 61 with ORB

use of org.omg.CORBA.ORB in project jdk8u_jdk by JetBrains.

the class CorbaUtils method initAppletORB.

/**
     * This method returns a new ORB instance for the given applet
     * without creating a static dependency on java.applet.
     */
private static ORB initAppletORB(Object applet, Properties orbProp) {
    try {
        Class<?> appletClass = Class.forName("java.applet.Applet", true, null);
        if (!appletClass.isInstance(applet)) {
            throw new ClassCastException(applet.getClass().getName());
        }
        // invoke the static method ORB.init(applet, orbProp);
        Method method = ORB.class.getMethod("init", appletClass, Properties.class);
        return (ORB) method.invoke(null, applet, orbProp);
    } catch (ClassNotFoundException e) {
        // non-null; so throw CCE
        throw new ClassCastException(applet.getClass().getName());
    } catch (NoSuchMethodException e) {
        throw new AssertionError(e);
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        if (cause instanceof RuntimeException) {
            throw (RuntimeException) cause;
        } else if (cause instanceof Error) {
            throw (Error) cause;
        }
        throw new AssertionError(e);
    } catch (IllegalAccessException iae) {
        throw new AssertionError(iae);
    }
}
Also used : Method(java.lang.reflect.Method) ORB(org.omg.CORBA.ORB) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 62 with ORB

use of org.omg.CORBA.ORB in project cxf by apache.

the class Server method main.

public static void main(String[] args) {
    java.util.Properties props = new Properties();
    props.putAll(System.getProperties());
    props.put("org.omg.CORBA.ORBInitialHost", "localhost");
    props.put("org.omg.CORBA.ORBInitialPort", "1050");
    ORB orb = null;
    int status = 0;
    try {
        orb = ORB.init(args, props);
        status = run(orb, args);
    } catch (Exception ex) {
        ex.printStackTrace();
        status = 1;
    }
    if (orb != null) {
        try {
            orb.destroy();
        } catch (Exception ex) {
            ex.printStackTrace();
            status = 1;
        }
    }
    System.exit(status);
}
Also used : Properties(java.util.Properties) Properties(java.util.Properties) ORB(org.omg.CORBA.ORB) UserException(org.omg.CORBA.UserException)

Example 63 with ORB

use of org.omg.CORBA.ORB in project Payara by payara.

the class LocalSerialContextProviderImpl method lookup.

public Object lookup(String name) throws NamingException, RemoteException {
    Object obj = super.lookup(name);
    try {
        if (obj instanceof Reference) {
            Reference ref = (Reference) obj;
            if (ref.getFactoryClassName().equals(GlassfishNamingManagerImpl.IIOPOBJECT_FACTORY)) {
                ORB orb = ProviderManager.getProviderManager().getORB();
                Hashtable env = new Hashtable();
                if (orb != null) {
                    env.put("java.naming.corba.orb", orb);
                }
                obj = javax.naming.spi.NamingManager.getObjectInstance(obj, new CompositeName(name), null, env);
                // NOTE : No copy object performed in this case
                return obj;
            }
        }
    } catch (Exception e) {
        RemoteException re = new RemoteException("", e);
        throw re;
    }
    return namingUtils.makeCopyOfObject(obj);
}
Also used : Reference(javax.naming.Reference) Hashtable(java.util.Hashtable) CompositeName(javax.naming.CompositeName) RemoteException(java.rmi.RemoteException) ORB(org.omg.CORBA.ORB) NamingException(javax.naming.NamingException) RemoteException(java.rmi.RemoteException)

Example 64 with ORB

use of org.omg.CORBA.ORB in project Payara by payara.

the class EjbNamingReferenceManagerImpl method resolveEjbReference.

@Override
public Object resolveEjbReference(EjbReferenceDescriptor ejbRefDesc, Context context) throws NamingException {
    Object jndiObj = null;
    boolean resolved = false;
    if (ejbRefDesc.isLocal()) {
        // Otherwise, the ejb will be resolved by EJBUtils.
        if (ejbRefDesc.hasLookupName()) {
            jndiObj = context.lookup(ejbRefDesc.getLookupName());
            resolved = true;
        }
    } else if (!ejbRefDesc.hasJndiName() && ejbRefDesc.hasLookupName()) {
        // loader to the thread.  Issue 17376.
        try {
            jndiObj = context.lookup(ejbRefDesc.getLookupName());
        } catch (NamingException e) {
            ClassLoader oldLoader = null;
            try {
                oldLoader = Utility.setContextClassLoader(ejbRefDesc.getReferringBundleDescriptor().getClassLoader());
                jndiObj = context.lookup(ejbRefDesc.getLookupName());
            } finally {
                Utility.setContextClassLoader(oldLoader);
            }
        }
        resolved = true;
    } else if (ejbRefDesc.hasJndiName() && ejbRefDesc.getJndiName().startsWith("java:app/") && !ejbRefDesc.getJndiName().startsWith("java:app/env/")) {
        // This could be an @EJB dependency in an appclient whose target name
        // is a portable java:app ejb name.  Try the global version.  If that
        // doesn't work, the javaURLContext logic should be able to figure it
        // out.
        String remoteJndiName = ejbRefDesc.getJndiName();
        String appName = (String) context.lookup("java:app/AppName");
        String newPrefix = "java:global/" + appName + "/";
        int javaAppLength = "java:app/".length();
        String globalLookup = newPrefix + remoteJndiName.substring(javaAppLength);
        jndiObj = context.lookup(globalLookup);
        resolved = true;
    } else {
        // Get actual jndi-name from ejb module.
        String remoteJndiName = EJBUtils.getRemoteEjbJndiName(ejbRefDesc);
        // We could be resolving an ejb-ref as part of a remote lookup thread.  In that
        // case the context class loader won't be set appropriately on the thread
        // being used to process the remote naming request.   We can't just always
        // set the context class loader to the class loader of the application module
        // that defined the ejb reference.  That would cause ClassCastExceptions
        // when the returned object is assigned within a cross-application intra-server
        // lookup. So, just try to lookup the interface associated with the ejb-ref
        // using the context class loader.  If that doesn't work, explicitly use the
        // defining application's class loader.
        ClassLoader origClassLoader = Utility.getClassLoader();
        boolean setCL = false;
        try {
            try {
                String refInterface = ejbRefDesc.isEJB30ClientView() ? ejbRefDesc.getEjbInterface() : ejbRefDesc.getHomeClassName();
                origClassLoader.loadClass(refInterface);
            } catch (ClassNotFoundException e) {
                ClassLoader referringBundleClassLoader = ejbRefDesc.getReferringBundleDescriptor().getClassLoader();
                Utility.setContextClassLoader(referringBundleClassLoader);
                setCL = true;
            }
            /* For remote ejb refs, first lookup the target remote object
                 * and pass it to the next stage of ejb ref resolution.
                 * If the string is a "corbaname:...." URL
                 * the lookup happens thru the corbanameURL context,
                 * else it happens thru the context provided by the NamingManager.
                 *
                 * NOTE : we might need some additional logic to handle cross-server
                 * MEJB resolution for cluster support post V3 FCS.
                 */
            if (remoteJndiName.startsWith(CORBANAME)) {
                GlassFishORBHelper orbHelper = glassFishORBHelperProvider.get();
                ORB orb = orbHelper.getORB();
                jndiObj = (Object) orb.string_to_object(remoteJndiName);
            } else {
                jndiObj = context.lookup(remoteJndiName);
            }
        } catch (Exception e) {
            // Important to make the real underlying lookup name part of the exception.
            NamingException ne = new NamingException("Exception resolving Ejb for '" + ejbRefDesc + "' .  Actual (possibly internal) Remote JNDI name used for lookup is '" + remoteJndiName + "'");
            ne.initCause(e);
            throw ne;
        } finally {
            if (setCL) {
                Utility.setContextClassLoader(origClassLoader);
            }
        }
    }
    return resolved ? jndiObj : EJBUtils.resolveEjbRefObject(ejbRefDesc, jndiObj);
}
Also used : NamingException(javax.naming.NamingException) GlassFishORBHelper(org.glassfish.enterprise.iiop.api.GlassFishORBHelper) ORB(org.omg.CORBA.ORB) NamingException(javax.naming.NamingException)

Example 65 with ORB

use of org.omg.CORBA.ORB in project tomee by apache.

the class Corbas method toStub.

public static Object toStub(final Object obj) throws IOException {
    final Tie tie = javax.rmi.CORBA.Util.getTie((Remote) obj);
    if (tie == null) {
        throw new IOException("Unable to serialize PortableRemoteObject; object has not been exported: " + obj);
    }
    final ORB orb = getORB();
    tie.orb(orb);
    return PortableRemoteObject.toStub((Remote) obj);
}
Also used : Tie(javax.rmi.CORBA.Tie) IOException(java.io.IOException) ORB(org.omg.CORBA.ORB)

Aggregations

ORB (org.omg.CORBA.ORB)73 POA (org.omg.PortableServer.POA)12 Properties (java.util.Properties)10 NamingException (javax.naming.NamingException)8 Test (org.junit.Test)7 AcsProfilingORB (org.jacorb.orb.acs.AcsProfilingORB)6 IOException (java.io.IOException)5 Logger (java.util.logging.Logger)5 HashMap (java.util.HashMap)4 StartException (org.jboss.msc.service.StartException)4 Any (org.omg.CORBA.Any)4 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)3 FileWriter (java.io.FileWriter)3 PrintWriter (java.io.PrintWriter)3 MessageImpl (org.apache.cxf.message.MessageImpl)3 Monitorlong (alma.ACS.Monitorlong)2 DAL (com.cosylab.CDB.DAL)2 HandleDataStore (com.cosylab.acs.maci.manager.HandleDataStore)2 OutputStream (java.io.OutputStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2