Search in sources :

Example 36 with ORB

use of org.omg.CORBA.ORB in project wildfly by wildfly.

the class ArjunaTransactionManagerService method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    final CoordinatorEnvironmentBean coordinatorEnvironmentBean = arjPropertyManager.getCoordinatorEnvironmentBean();
    coordinatorEnvironmentBean.setEnableStatistics(coordinatorEnableStatistics);
    coordinatorEnvironmentBean.setDefaultTimeout(coordinatorDefaultTimeout);
    coordinatorEnvironmentBean.setTransactionStatusManagerEnable(transactionStatusManagerEnable);
    // Object Store Browser bean
    Map<String, String> objStoreBrowserTypes = new HashMap<String, String>();
    objStoreBrowser = new ObjStoreBrowser();
    objStoreBrowserTypes.put("StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");
    objStoreBrowserTypes.put("StateManager/AbstractRecord/ConnectableResourceRecord", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.ConnectableResourceRecordBean");
    if (!jts) {
        // No IIOP, stick with JTA mode.
        jtaEnvironmentBean.getValue().setTransactionManagerClassName(com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate.class.getName());
        final com.arjuna.ats.jbossatx.jta.TransactionManagerService service = new com.arjuna.ats.jbossatx.jta.TransactionManagerService();
        final LocalUserTransaction userTransaction = LocalUserTransaction.getInstance();
        jtaEnvironmentBean.getValue().setUserTransaction(userTransaction);
        service.setJbossXATerminator(xaTerminatorInjector.getValue());
        service.setTransactionSynchronizationRegistry(new TransactionSynchronizationRegistryWrapper(ContextTransactionSynchronizationRegistry.getInstance()));
        try {
            service.create();
        } catch (Exception e) {
            throw TransactionLogger.ROOT_LOGGER.managerStartFailure(e, "Transaction");
        }
        service.start();
        value = service;
    } else {
        final ORB orb = orbInjector.getValue();
        new PostInitLoader(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"), orb);
        // IIOP is enabled, so fire up JTS mode.
        jtaEnvironmentBean.getValue().setTransactionManagerClassName(com.arjuna.ats.jbossatx.jts.TransactionManagerDelegate.class.getName());
        final com.arjuna.ats.jbossatx.jts.TransactionManagerService service = new com.arjuna.ats.jbossatx.jts.TransactionManagerService();
        final LocalUserTransaction userTransaction = LocalUserTransaction.getInstance();
        jtaEnvironmentBean.getValue().setUserTransaction(userTransaction);
        service.setJbossXATerminator(xaTerminatorInjector.getValue());
        service.setTransactionSynchronizationRegistry(new TransactionSynchronizationRegistryWrapper(ContextTransactionSynchronizationRegistry.getInstance()));
        service.setPropagateFullContext(true);
        // this is not great, but it's the only way presently to influence the behavior of com.arjuna.ats.internal.jbossatx.jts.InboundTransactionCurrentImple
        try {
            final Field field = TransactionManagerLocator.class.getDeclaredField("tm");
            field.setAccessible(true);
            field.set(TransactionManagerLocator.getInstance(), jtaEnvironmentBean.getValue().getTransactionManager());
        } catch (IllegalAccessException e) {
            throw new IllegalAccessError(e.getMessage());
        } catch (NoSuchFieldException e) {
            throw new NoSuchFieldError(e.getMessage());
        }
        objStoreBrowserTypes.put("StateManager/BasicAction/TwoPhaseCoordinator/ArjunaTransactionImple", "com.arjuna.ats.arjuna.tools.osb.mbean.ActionBean");
        try {
            service.create();
        } catch (Exception e) {
            throw TransactionLogger.ROOT_LOGGER.createFailed(e);
        }
        try {
            service.start(orb);
        } catch (Exception e) {
            throw TransactionLogger.ROOT_LOGGER.startFailure(e);
        }
        value = service;
    }
    try {
        objStoreBrowser.start();
    } catch (Exception e) {
        throw TransactionLogger.ROOT_LOGGER.objectStoreStartFailure(e);
    }
}
Also used : HashMap(java.util.HashMap) ObjStoreBrowser(com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser) TransactionSynchronizationRegistryWrapper(org.jboss.as.txn.service.internal.tsr.TransactionSynchronizationRegistryWrapper) Field(java.lang.reflect.Field) LocalUserTransaction(org.wildfly.transaction.client.LocalUserTransaction) CoordinatorEnvironmentBean(com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean) PostInitLoader(com.arjuna.orbportability.internal.utils.PostInitLoader) StartException(org.jboss.msc.service.StartException) ORB(org.omg.CORBA.ORB)

Example 37 with ORB

use of org.omg.CORBA.ORB in project wildfly by wildfly.

the class CNCtx method initUsingIiopUrl.

/**
     * Handles "iiop" and "iiopname" URLs (INS 98-10-11)
     */
private String initUsingIiopUrl(ORB defOrb, String url, Hashtable env) throws NamingException {
    try {
        IiopUrl parsedUrl = new IiopUrl(url);
        Vector addrs = parsedUrl.getAddresses();
        IiopUrl.Address addr;
        NamingException savedException = null;
        for (int i = 0; i < addrs.size(); i++) {
            addr = (IiopUrl.Address) addrs.elementAt(i);
            try {
                if (defOrb != null) {
                    try {
                        String tmpUrl = "corbaloc:iiop:" + addr.host + ":" + addr.port + "/NameService";
                        org.omg.CORBA.Object rootCtx = defOrb.string_to_object(tmpUrl);
                        setOrbAndRootContext(defOrb, rootCtx);
                        return parsedUrl.getStringName();
                    } catch (Exception e) {
                    }
                // keep going
                }
                // Get ORB
                ORB orb = CorbaUtils.getOrb(addr.host, addr.port, env);
                // Assign to fields
                setOrbAndRootContext(orb, (String) null);
                return parsedUrl.getStringName();
            } catch (NamingException ne) {
                savedException = ne;
            }
        }
        if (savedException != null) {
            throw savedException;
        } else {
            throw IIOPLogger.ROOT_LOGGER.invalidURLOrIOR(url);
        }
    } catch (MalformedURLException e) {
        throw new ConfigurationException(e.getMessage());
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ConfigurationException(javax.naming.ConfigurationException) NamingException(javax.naming.NamingException) NameNotFoundException(javax.naming.NameNotFoundException) CannotProceedException(javax.naming.CannotProceedException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) NotContextException(javax.naming.NotContextException) ConfigurationException(javax.naming.ConfigurationException) NamingException(javax.naming.NamingException) Vector(java.util.Vector) ORB(org.omg.CORBA.ORB)

Example 38 with ORB

use of org.omg.CORBA.ORB in project wildfly by wildfly.

the class CNCtx method initOrbAndRootContext.

/**
     * Initializes the COS Naming Service.
     * This method initializes the three instance fields:
     * _nc : The root naming context.
     * _orb: The ORB to use for connecting RMI/IIOP stubs and for
     * getting the naming context (_nc) if one was not specified
     * explicitly via PROVIDER_URL.
     * _name: The name of the root naming context.
     * <p/>
     * _orb is obtained from java.naming.corba.orb if it has been set.
     * Otherwise, _orb is created using the host/port from PROVIDER_URL
     * (if it contains an "iiop" or "iiopname" URL), or from initialization
     * properties specified in env.
     * <p/>
     * _nc is obtained from the IOR stored in PROVIDER_URL if it has been
     * set and does not contain an "iiop" or "iiopname" URL. It can be
     * a stringified IOR, "corbaloc" URL, "corbaname" URL,
     * or a URL (such as file/http/ftp) to a location
     * containing a stringified IOR. If PROVIDER_URL has not been
     * set in this way, it is obtained from the result of
     * ORB.resolve_initial_reference("NameService");
     * <p/>
     * _name is obtained from the "iiop", "iiopname", or "corbaname" URL.
     * It is the empty name by default.
     *
     * @param env Environment The possibly null environment.
     * @throws NamingException When an error occurs while initializing the
     *                         ORB or the naming context.
     */
private void initOrbAndRootContext(Hashtable env) throws NamingException {
    org.omg.CORBA.ORB inOrb = null;
    String ncIor = null;
    if (env != null) {
        inOrb = (org.omg.CORBA.ORB) env.get("java.naming.corba.orb");
    }
    // Extract PROVIDER_URL from environment
    String provUrl = null;
    if (env != null) {
        provUrl = (String) env.get(javax.naming.Context.PROVIDER_URL);
    }
    if (provUrl != null && !isCorbaUrl(provUrl)) {
        // Initialize the root naming context by using the IOR supplied
        // in the PROVIDER_URL
        ncIor = getStringifiedIor(provUrl);
        if (inOrb == null) {
            // no ORB instance specified; create one using env and defaults
            inOrb = CorbaORBService.getCurrent();
        }
        setOrbAndRootContext(inOrb, ncIor);
    } else if (provUrl != null) {
        // Initialize the root naming context by using the URL supplied
        // in the PROVIDER_URL
        String insName = initUsingUrl(inOrb, provUrl, env);
        // If name supplied in URL, resolve it to a NamingContext
        if (insName.length() > 0) {
            _name = parser.nameToCosName(parser.parse(insName));
            try {
                org.omg.CORBA.Object obj = _nc.resolve(_name);
                _nc = NamingContextHelper.narrow(obj);
                if (_nc == null) {
                    throw IIOPLogger.ROOT_LOGGER.notANamingContext(insName);
                }
            } catch (org.omg.CORBA.BAD_PARAM e) {
                throw IIOPLogger.ROOT_LOGGER.notANamingContext(insName);
            } catch (Exception e) {
                throw org.wildfly.iiop.openjdk.naming.jndi.ExceptionMapper.mapException(e, this, _name);
            }
        }
    } else {
        // No PROVIDER_URL supplied; initialize using defaults
        if (inOrb == null) {
            // No ORB instance specified; create one using env and defaults
            inOrb = CorbaORBService.getCurrent();
            IIOPLogger.ROOT_LOGGER.debugf("Getting default ORB %s", inOrb);
        }
        setOrbAndRootContext(inOrb, (String) null);
    }
}
Also used : ORB(org.omg.CORBA.ORB) BAD_PARAM(org.omg.CORBA.BAD_PARAM) ConfigurationException(javax.naming.ConfigurationException) NamingException(javax.naming.NamingException) NameNotFoundException(javax.naming.NameNotFoundException) CannotProceedException(javax.naming.CannotProceedException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) NotContextException(javax.naming.NotContextException)

Example 39 with ORB

use of org.omg.CORBA.ORB in project wildfly by wildfly.

the class CheckORBBean method checkForORBInEnvironment.

public void checkForORBInEnvironment() {
    try {
        InitialContext ctx = new InitialContext();
        ORB orb = (ORB) ctx.lookup("java:comp/ORB");
        checkORB(orb);
    } catch (NamingException e) {
        throw new IllegalStateException("Can't lookup java:comp/ORB", e);
    }
}
Also used : NamingException(javax.naming.NamingException) InitialContext(javax.naming.InitialContext) ORB(org.omg.CORBA.ORB)

Example 40 with ORB

use of org.omg.CORBA.ORB in project wildfly by wildfly.

the class HandleDelegateImpl method reconnect.

protected void reconnect(Object object) throws IOException {
    if (object instanceof ObjectImpl) {
        try {
            // Check we are still connected
            ObjectImpl objectImpl = (ObjectImpl) object;
            objectImpl._get_delegate();
        } catch (BAD_OPERATION e) {
            try {
                // Reconnect
                final Stub stub = (Stub) object;
                final ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB");
                stub.connect(orb);
            } catch (NamingException ne) {
                throw EjbLogger.ROOT_LOGGER.failedToLookupORB();
            }
        }
    } else {
        throw EjbLogger.ROOT_LOGGER.notAnObjectImpl(object.getClass());
    }
}
Also used : Stub(javax.rmi.CORBA.Stub) NamingException(javax.naming.NamingException) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) ObjectImpl(org.omg.CORBA.portable.ObjectImpl) InitialContext(javax.naming.InitialContext) ORB(org.omg.CORBA.ORB)

Aggregations

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