Search in sources :

Example 26 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)

Example 27 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 28 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 29 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 30 with ORB

use of org.omg.CORBA.ORB in project ACS by ACS-Community.

the class T112Sampler method runTest.

/**
	 * Perform a single sample.
	 * Perform a single sample for each iteration.  This method
	 * returns a <code>SampleResult</code> object.
	 * <code>SampleResult</code> has many fields which can be
	 * used.  At a minimum, the test should use
	 * <code>SampleResult.sampleStart</code> and
	 * <code>SampleResult.sampleEnd</code>to set the time that
	 * the test required to execute.  It is also a good idea to
	 * set the sampleLabel and the successful flag.
	 * 
	 * @see org.apache.jmeter.samplers.SampleResult#sampleStart()
	 * @see org.apache.jmeter.samplers.SampleResult#sampleEnd()
	 * @see org.apache.jmeter.samplers.SampleResult#setSuccessful(boolean)
	 * @see org.apache.jmeter.samplers.SampleResult#setSampleLabel(String)
	 * 
	 * @param context  the context to run with. This provides access
	 *                 to initialization parameters.
	 * 
	 * @return         a SampleResult giving the results of this
	 *                 sample.
	 */
public SampleResult runTest(JavaSamplerContext context) {
    SampleResult results = new SampleResult();
    try {
        long time = System.currentTimeMillis();
        POA rootPOA = null;
        OrbConfigurator orbConf = OrbConfigurator.getOrbConfigurator();
        ORB orb = ORB.init(orbConf.getOptions(), orbConf.getProperties());
        rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        rootPOA.the_POAManager().activate();
        results.setTime(System.currentTimeMillis() - time);
        results.setSuccessful(true);
        results.setSampleLabel(m_testName + "() @" + m_instanceID);
        if (orb != null)
            orb.destroy();
    } catch (Exception e) {
        results.setSuccessful(false);
        results.setResponseCode(e.getMessage());
        results.setSampleLabel("ERROR: " + e.getMessage());
        getLogger().error(this.getClass().getName() + ": Error during sample", e);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(whoAmI() + "\trunTest()" + "\tTime:\t" + results.getTime());
        listParameters(context);
    }
    return results;
}
Also used : OrbConfigurator(alma.acs.container.corba.OrbConfigurator) POA(org.omg.PortableServer.POA) SampleResult(org.apache.jmeter.samplers.SampleResult) ORB(org.omg.CORBA.ORB)

Aggregations

ORB (org.omg.CORBA.ORB)51 POA (org.omg.PortableServer.POA)11 Properties (java.util.Properties)7 NamingException (javax.naming.NamingException)6 AcsProfilingORB (org.jacorb.orb.acs.AcsProfilingORB)6 Logger (java.util.logging.Logger)5 StartException (org.jboss.msc.service.StartException)5 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)3 IOException (java.io.IOException)3 Monitorlong (alma.ACS.Monitorlong)2 PostInitLoader (com.arjuna.orbportability.internal.utils.PostInitLoader)2 DAL (com.cosylab.CDB.DAL)2 HandleDataStore (com.cosylab.acs.maci.manager.HandleDataStore)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 CannotProceedException (javax.naming.CannotProceedException)2 ConfigurationException (javax.naming.ConfigurationException)2 InitialContext (javax.naming.InitialContext)2