Search in sources :

Example 16 with ORB

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

the class IIOPJndiBindingProcessor method bindService.

/**
     * Binds java:comp/ORB
     *
     * @param serviceTarget      The service target
     * @param contextServiceName The service name of the context to bind to
     */
private void bindService(final ServiceTarget serviceTarget, final ServiceName contextServiceName, final Module module) {
    final ServiceName orbServiceName = contextServiceName.append("ORB");
    final BinderService orbService = new BinderService("ORB");
    serviceTarget.addService(orbServiceName, orbService).addDependency(CorbaORBService.SERVICE_NAME, ORB.class, new ManagedReferenceInjector<ORB>(orbService.getManagedObjectInjector())).addDependency(contextServiceName, ServiceBasedNamingStore.class, orbService.getNamingStoreInjector()).install();
    final ServiceName handleDelegateServiceName = contextServiceName.append("HandleDelegate");
    final BinderService handleDelegateBindingService = new BinderService("HandleDelegate");
    handleDelegateBindingService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue(new HandleDelegateImpl(module.getClassLoader()))));
    serviceTarget.addService(handleDelegateServiceName, handleDelegateBindingService).addDependency(contextServiceName, ServiceBasedNamingStore.class, handleDelegateBindingService.getNamingStoreInjector()).install();
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) HandleDelegateImpl(org.jboss.as.ejb3.iiop.handle.HandleDelegateImpl) ServiceName(org.jboss.msc.service.ServiceName) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ORB(org.omg.CORBA.ORB) ImmediateValue(org.jboss.msc.value.ImmediateValue)

Example 17 with ORB

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

the class CorbaPOAService method start.

@Override
public void start(StartContext context) throws StartException {
    if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) {
        IIOPLogger.ROOT_LOGGER.debugf("Starting service %s", context.getController().getName().getCanonicalName());
    }
    ORB orb = this.orbInjector.getOptionalValue();
    POA parentPOA = this.parentPOAInjector.getOptionalValue();
    // if an ORB has been injected, we will use the ORB.resolve_initial_references method to instantiate the POA.
    if (orb != null) {
        try {
            this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName));
        } catch (Exception e) {
            throw IIOPLogger.ROOT_LOGGER.errorResolvingInitRef(this.poaName, e);
        }
    } else // if a parent POA has been injected, we use it to create the policies and then the POA itself.
    if (parentPOA != null) {
        try {
            Policy[] poaPolicies = this.createPolicies(parentPOA);
            this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies);
        } catch (Exception e) {
            throw IIOPLogger.ROOT_LOGGER.errorCreatingPOAFromParent(e);
        }
    } else {
        throw IIOPLogger.ROOT_LOGGER.invalidPOACreationArgs();
    }
    // check if the POA should be bound to JNDI under java:/jboss.
    if (this.bindingName != null) {
        CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa);
    }
    // activate the created POA.
    try {
        this.poa.the_POAManager().activate();
    } catch (Exception e) {
        throw IIOPLogger.ROOT_LOGGER.errorActivatingPOA(e);
    }
}
Also used : POA(org.omg.PortableServer.POA) ORB(org.omg.CORBA.ORB) StartException(org.jboss.msc.service.StartException)

Example 18 with ORB

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

the class CorbaNamingService method start.

@Override
public void start(StartContext context) throws StartException {
    IIOPLogger.ROOT_LOGGER.debugf("Starting service %s", context.getController().getName().getCanonicalName());
    ORB orb = orbInjector.getValue();
    POA rootPOA = rootPOAInjector.getValue();
    POA namingPOA = namingPOAInjector.getValue();
    try {
        // initialize the static naming service variables.
        CorbaNamingContext.init(orb, rootPOA);
        // create and initialize the root context instance according to the configuration.
        CorbaNamingContext ns = new CorbaNamingContext();
        ns.init(namingPOA, false, false);
        // create and activate the root context.
        byte[] rootContextId = "root".getBytes();
        namingPOA.activate_object_with_id(rootContextId, ns);
        namingService = NamingContextExtHelper.narrow(namingPOA.create_reference_with_id(rootContextId, "IDL:omg.org/CosNaming/NamingContextExt:1.0"));
        // exporting the NameService initial reference
        ((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(Constants.NAME_SERVICE_INIT_REF, namingPOA.servant_to_reference(ns));
        // exporting root-context initial reference
        final boolean exportCorbaloc = properties.getProperty(Constants.NAMING_EXPORT_CORBALOC).equals("true");
        if (exportCorbaloc) {
            final String rootContext = properties.getProperty(Constants.NAMING_ROOT_CONTEXT);
            ((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(rootContext, namingPOA.servant_to_reference(ns));
        }
    } catch (Exception e) {
        throw IIOPLogger.ROOT_LOGGER.failedToStartJBossCOSNaming(e);
    }
    // bind the corba naming service to JNDI.
    CorbaServiceUtil.bindObject(context.getChildTarget(), "corbanaming", namingService);
    if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) {
        IIOPLogger.ROOT_LOGGER.corbaNamingServiceStarted();
        IIOPLogger.ROOT_LOGGER.debugf("Naming: [%s]", orb.object_to_string(namingService));
    }
}
Also used : POA(org.omg.PortableServer.POA) CorbaNamingContext(org.wildfly.iiop.openjdk.naming.CorbaNamingContext) ORB(org.omg.CORBA.ORB) StartException(org.jboss.msc.service.StartException)

Example 19 with ORB

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

the class ArjunaRecoveryManagerService method start.

public synchronized void start(StartContext context) throws StartException {
    // Recovery env bean
    final RecoveryEnvironmentBean recoveryEnvironmentBean = recoveryPropertyManager.getRecoveryEnvironmentBean();
    final SocketBinding recoveryBinding = recoveryBindingInjector.getValue();
    recoveryEnvironmentBean.setRecoveryInetAddress(recoveryBinding.getSocketAddress().getAddress());
    recoveryEnvironmentBean.setRecoveryPort(recoveryBinding.getSocketAddress().getPort());
    final SocketBinding statusBinding = statusBindingInjector.getValue();
    recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(statusBinding.getSocketAddress().getAddress());
    recoveryEnvironmentBean.setTransactionStatusManagerPort(statusBinding.getSocketAddress().getPort());
    recoveryEnvironmentBean.setRecoveryListener(recoveryListener);
    if (recoveryListener) {
        ManagedBinding binding = ManagedBinding.Factory.createSimpleManagedBinding(recoveryBinding);
        bindingManager.getValue().getNamedRegistry().registerBinding(binding);
    }
    final List<String> recoveryExtensions = new ArrayList<String>();
    // must be first
    recoveryExtensions.add(CommitMarkableResourceRecordRecoveryModule.class.getName());
    recoveryExtensions.add(AtomicActionRecoveryModule.class.getName());
    recoveryExtensions.add(TORecoveryModule.class.getName());
    final List<String> expiryScanners;
    if (System.getProperty("RecoveryEnvironmentBean.expiryScannerClassNames") != null) {
        expiryScanners = recoveryEnvironmentBean.getExpiryScannerClassNames();
    } else {
        expiryScanners = new ArrayList<String>();
        expiryScanners.add(ExpiredTransactionStatusManagerScanner.class.getName());
    }
    if (!jts) {
        recoveryExtensions.add(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.class.getName());
        recoveryEnvironmentBean.setRecoveryModuleClassNames(recoveryExtensions);
        recoveryEnvironmentBean.setExpiryScannerClassNames(expiryScanners);
        recoveryEnvironmentBean.setRecoveryActivators(null);
        final RecoveryManagerService recoveryManagerService = new RecoveryManagerService();
        try {
            recoveryManagerService.create();
        } catch (Exception e) {
            throw TransactionLogger.ROOT_LOGGER.managerStartFailure(e, "Recovery");
        }
        recoveryManagerService.start();
        this.recoveryManagerService = recoveryManagerService;
    } else {
        final ORB orb = orbInjector.getValue();
        new PostInitLoader(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"), orb);
        recoveryExtensions.add(TopLevelTransactionRecoveryModule.class.getName());
        recoveryExtensions.add(ServerTransactionRecoveryModule.class.getName());
        recoveryExtensions.add(JCAServerTransactionRecoveryModule.class.getName());
        recoveryExtensions.add(com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule.class.getName());
        expiryScanners.add(ExpiredContactScanner.class.getName());
        expiryScanners.add(ExpiredToplevelScanner.class.getName());
        expiryScanners.add(ExpiredServerScanner.class.getName());
        recoveryEnvironmentBean.setRecoveryModuleClassNames(recoveryExtensions);
        recoveryEnvironmentBean.setExpiryScannerClassNames(expiryScanners);
        recoveryEnvironmentBean.setRecoveryActivatorClassNames(Collections.singletonList(com.arjuna.ats.internal.jts.orbspecific.recovery.RecoveryEnablement.class.getName()));
        try {
            final RecoveryManagerService recoveryManagerService = new com.arjuna.ats.jbossatx.jts.RecoveryManagerService(orb);
            recoveryManagerService.create();
            recoveryManagerService.start();
            this.recoveryManagerService = recoveryManagerService;
        } catch (Exception e) {
            throw TransactionLogger.ROOT_LOGGER.managerStartFailure(e, "Recovery");
        }
    }
    recoverySuspendController = new RecoverySuspendController(recoveryManagerService);
    suspendControllerInjector.getValue().registerActivity(recoverySuspendController);
}
Also used : SocketBinding(org.jboss.as.network.SocketBinding) ExpiredContactScanner(com.arjuna.ats.internal.jts.recovery.contact.ExpiredContactScanner) AtomicActionRecoveryModule(com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule) ExpiredTransactionStatusManagerScanner(com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner) ArrayList(java.util.ArrayList) TopLevelTransactionRecoveryModule(com.arjuna.ats.internal.jts.recovery.transactions.TopLevelTransactionRecoveryModule) ManagedBinding(org.jboss.as.network.ManagedBinding) CommitMarkableResourceRecordRecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.CommitMarkableResourceRecordRecoveryModule) RecoveryManagerService(com.arjuna.ats.jbossatx.jta.RecoveryManagerService) PostInitLoader(com.arjuna.orbportability.internal.utils.PostInitLoader) StartException(org.jboss.msc.service.StartException) ExpiredToplevelScanner(com.arjuna.ats.internal.jts.recovery.transactions.ExpiredToplevelScanner) TORecoveryModule(com.arjuna.ats.internal.txoj.recovery.TORecoveryModule) RecoveryEnvironmentBean(com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean) RecoverySuspendController(org.jboss.as.txn.suspend.RecoverySuspendController) JCAServerTransactionRecoveryModule(com.arjuna.ats.internal.jta.recovery.jts.JCAServerTransactionRecoveryModule) ServerTransactionRecoveryModule(com.arjuna.ats.internal.jts.recovery.transactions.ServerTransactionRecoveryModule) JCAServerTransactionRecoveryModule(com.arjuna.ats.internal.jta.recovery.jts.JCAServerTransactionRecoveryModule) ExpiredServerScanner(com.arjuna.ats.internal.jts.recovery.transactions.ExpiredServerScanner) ORB(org.omg.CORBA.ORB)

Example 20 with ORB

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

the class EjbIIOPService method start.

public synchronized void start(final StartContext startContext) throws StartException {
    try {
        final RiverMarshallerFactory factory = new RiverMarshallerFactory();
        final MarshallingConfiguration configuration = new MarshallingConfiguration();
        configuration.setClassResolver(ModularClassResolver.getInstance(serviceModuleLoaderInjectedValue.getValue()));
        this.configuration = configuration;
        this.factory = factory;
        final TransactionManager jtsTransactionManager = transactionManagerInjectedValue.getValue().getTransactionManager();
        assert !(jtsTransactionManager instanceof ContextTransactionManager);
        // Should create a CORBA interface repository?
        final boolean interfaceRepositorySupported = false;
        // Build binding name of the bean.
        final EJBComponent component = ejbComponentInjectedValue.getValue();
        final String earApplicationName = component.getEarApplicationName();
        if (iiopMetaData != null && iiopMetaData.getBindingName() != null) {
            name = iiopMetaData.getBindingName();
        } else if (useQualifiedName) {
            if (component.getDistinctName() == null || component.getDistinctName().isEmpty()) {
                name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                name = name + component.getModuleName() + "/" + component.getComponentName();
            } else {
                name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                name = name + component.getModuleName() + "/" + component.getDistinctName() + "/" + component.getComponentName();
            }
        } else {
            name = component.getComponentName();
        }
        name = name.replace(".", "_");
        final ORB orb = this.orb.getValue();
        if (interfaceRepositorySupported) {
            // Create a CORBA interface repository for the enterprise bean
            iri = new InterfaceRepository(orb, irPoa.getValue(), name);
            // Add bean interface info to the interface repository
            iri.mapClass(remoteView.getValue().getViewClass());
            iri.mapClass(homeView.getValue().getViewClass());
            iri.finishBuild();
            EjbLogger.ROOT_LOGGER.cobraInterfaceRepository(name, orb.object_to_string(iri.getReference()));
        }
        IORSecurityConfigMetaData iorSecurityConfigMetaData = this.iorSecConfigMetaData.getOptionalValue();
        if (this.iiopMetaData != null && this.iiopMetaData.getIorSecurityConfigMetaData() != null)
            iorSecurityConfigMetaData = this.iiopMetaData.getIorSecurityConfigMetaData();
        // Create security policies if security metadata has been provided.
        List<Policy> policyList = new ArrayList<Policy>();
        if (iorSecurityConfigMetaData != null) {
            // Create csiv2Policy for both home and remote containing IorSecurityConfigMetadata.
            final Any secPolicy = orb.create_any();
            secPolicy.insert_Value(iorSecurityConfigMetaData);
            Policy csiv2Policy = orb.create_policy(CSIv2Policy.TYPE, secPolicy);
            policyList.add(csiv2Policy);
            //  Add ZeroPortPolicy if ssl is required (it ensures home and remote IORs will have port 0 in the primary address).
            boolean sslRequired = false;
            if (iorSecurityConfigMetaData != null && iorSecurityConfigMetaData.getTransportConfig() != null) {
                IORTransportConfigMetaData tc = iorSecurityConfigMetaData.getTransportConfig();
                sslRequired = IORTransportConfigMetaData.INTEGRITY_REQUIRED.equals(tc.getIntegrity()) || IORTransportConfigMetaData.CONFIDENTIALITY_REQUIRED.equals(tc.getConfidentiality()) || IORTransportConfigMetaData.ESTABLISH_TRUST_IN_CLIENT_REQUIRED.equals(tc.getEstablishTrustInClient());
            }
            if (sslRequired) {
                policyList.add(ZeroPortPolicy.getPolicy());
            }
        }
        //TODO: what should this default to
        String securityDomain = "CORBA_REMOTE";
        if (component.getSecurityMetaData() != null) {
            securityDomain = component.getSecurityMetaData().getSecurityDomain();
        }
        Policy[] policies = policyList.toArray(new Policy[policyList.size()]);
        // If there is an interface repository, then get the homeInterfaceDef from the IR
        InterfaceDef homeInterfaceDef = null;
        if (iri != null) {
            Repository ir = iri.getReference();
            homeInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(homeRepositoryIds[0]));
        }
        // Get the POACurrent object
        Current poaCurrent = CurrentHelper.narrow(orb.resolve_initial_references("POACurrent"));
        // Instantiate home servant, bind it to the servant registry, and create CORBA reference to the EJBHome.
        final EjbCorbaServant homeServant = new EjbCorbaServant(poaCurrent, homeMethodMap, homeRepositoryIds, homeInterfaceDef, orb, homeView.getValue(), factory, configuration, jtsTransactionManager, module.getClassLoader(), true, securityDomain, component.getSecurityDomain());
        homeServantRegistry = poaRegistry.getValue().getRegistryWithPersistentPOAPerServant();
        ReferenceFactory homeReferenceFactory = homeServantRegistry.bind(homeServantName(name), homeServant, policies);
        final org.omg.CORBA.Object corbaRef = homeReferenceFactory.createReference(homeRepositoryIds[0]);
        //we do this twice to force eager dynamic stub creation
        ejbHome = (EJBHome) PortableRemoteObject.narrow(corbaRef, EJBHome.class);
        final HomeHandleImplIIOP homeHandle = new HomeHandleImplIIOP(orb.object_to_string(corbaRef));
        homeServant.setHomeHandle(homeHandle);
        // Initialize beanPOA and create metadata
        // This is a session bean (lifespan: transient)
        beanServantRegistry = poaRegistry.getValue().getRegistryWithTransientPOAPerServant();
        if (component instanceof StatelessSessionComponent) {
            // Stateless session bean
            ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, true, homeHandle);
        } else {
            // Stateful session bean
            ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, false, homeHandle);
        }
        homeServant.setEjbMetaData(ejbMetaData);
        // If there is an interface repository, then get the beanInterfaceDef from the IR
        InterfaceDef beanInterfaceDef = null;
        if (iri != null) {
            final Repository ir = iri.getReference();
            beanInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
        }
        // Instantiate the ejb object servant and bind it to the servant registry.
        final EjbCorbaServant beanServant = new EjbCorbaServant(poaCurrent, beanMethodMap, beanRepositoryIds, beanInterfaceDef, orb, remoteView.getValue(), factory, configuration, jtsTransactionManager, module.getClassLoader(), false, securityDomain, component.getSecurityDomain());
        beanReferenceFactory = beanServantRegistry.bind(beanServantName(name), beanServant, policies);
        // Register bean home in local CORBA naming context
        rebind(corbaNamingContext.getValue(), name, corbaRef);
        EjbLogger.ROOT_LOGGER.debugf("Home IOR for %s bound to %s in CORBA naming service", component.getComponentName(), this.name);
        //now eagerly force stub creation, so de-serialization of stubs will work correctly
        final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
            try {
                DynamicStubFactoryFactory.makeStubClass(homeView.getValue().getViewClass());
            } catch (Exception e) {
                EjbLogger.ROOT_LOGGER.dynamicStubCreationFailed(homeView.getValue().getViewClass().getName(), e);
            }
            try {
                DynamicStubFactoryFactory.makeStubClass(remoteView.getValue().getViewClass());
            } catch (Exception e) {
                EjbLogger.ROOT_LOGGER.dynamicStubCreationFailed(remoteView.getValue().getViewClass().getName(), e);
            }
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
        }
    } catch (Exception e) {
        throw new StartException(e);
    }
}
Also used : ZeroPortPolicy(com.sun.corba.se.spi.extension.ZeroPortPolicy) CSIv2Policy(org.wildfly.iiop.openjdk.csiv2.CSIv2Policy) Policy(org.omg.CORBA.Policy) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) ArrayList(java.util.ArrayList) InterfaceRepository(org.wildfly.iiop.openjdk.rmi.ir.InterfaceRepository) Any(org.omg.CORBA.Any) StatelessSessionComponent(org.jboss.as.ejb3.component.stateless.StatelessSessionComponent) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) EJBMetaDataImplIIOP(org.jboss.ejb.iiop.EJBMetaDataImplIIOP) StartException(org.jboss.msc.service.StartException) IORTransportConfigMetaData(org.jboss.metadata.ejb.jboss.IORTransportConfigMetaData) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) StartException(org.jboss.msc.service.StartException) InterfaceDef(org.omg.CORBA.InterfaceDef) InterfaceRepository(org.wildfly.iiop.openjdk.rmi.ir.InterfaceRepository) Repository(org.omg.CORBA.Repository) IORSecurityConfigMetaData(org.jboss.metadata.ejb.jboss.IORSecurityConfigMetaData) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) Current(org.omg.PortableServer.Current) ORB(org.omg.CORBA.ORB) HomeHandleImplIIOP(org.jboss.ejb.iiop.HomeHandleImplIIOP)

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