Search in sources :

Example 16 with POA

use of org.omg.PortableServer.POA 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 17 with POA

use of org.omg.PortableServer.POA 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 18 with POA

use of org.omg.PortableServer.POA in project wildfly by wildfly.

the class POARegistry method start.

public synchronized void start(final StartContext startContext) throws StartException {
    transientPoaMap = Collections.synchronizedMap(new HashMap<String, POA>());
    persistentPoaMap = Collections.synchronizedMap(new HashMap<String, POA>());
    final POA rootPOA = this.rootPOA.getValue();
    // Policies for per-servant transient POAs
    transientPoaPolicies = new Policy[] { rootPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT), rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID), rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.NON_RETAIN), rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT), rootPOA.create_id_uniqueness_policy(IdUniquenessPolicyValue.MULTIPLE_ID) };
    // Policies for per-servant persistent POAs
    persistentPoaPolicies = new Policy[] { rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT), rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID), rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.NON_RETAIN), rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT), rootPOA.create_id_uniqueness_policy(IdUniquenessPolicyValue.MULTIPLE_ID) };
    // Create this POARegistry's ServantRegistry implementations
    registryWithTransientPOAPerServant = new ServantRegistryWithTransientPOAPerServant();
    registryWithPersistentPOAPerServant = new ServantRegistryWithPersistentPOAPerServant();
}
Also used : POA(org.omg.PortableServer.POA) HashMap(java.util.HashMap)

Example 19 with POA

use of org.omg.PortableServer.POA in project ACS by ACS-Community.

the class BACIRemoteAccess method initialize.

/**
	 * Insert the method's description here.
	 * Creation date: (1.11.2000 13:00:27)
	 */
public void initialize() {
    notifier.reportMessage("Starting engine initialization...");
    Properties props = System.getProperties();
    managerLoc = props.getProperty(MANAGER_CORBALOC);
    String IRloc = props.getProperty(IR_CORBALOC);
    if (managerLoc == null || IRloc == null) {
        CorbalocDialog dialog = new CorbalocDialog();
        if (managerLoc != null)
            dialog.setManagerFieldText(managerLoc);
        if (IRloc != null)
            dialog.setRepositoryFieldText(IRloc);
        dialog.show();
        if (dialog.isOKed()) {
            managerLoc = dialog.getManagerFieldText();
            IRloc = dialog.getRepositoryFieldText();
            ORBdebug = dialog.getDebugSelected();
        }
    }
    if (IRloc == null || "".equals(IRloc))
        throw new IllegalStateException("'" + IR_CORBALOC + "' property is not set. Aborting...");
    if (managerLoc == null || "".equals(managerLoc))
        throw new IllegalStateException("'" + MANAGER_CORBALOC + "' property is not set. Aborting...");
    notifier.reportDebug("BACIRemoteAccess::initialize", "Startup using '" + MANAGER_CORBALOC + "' = '" + managerLoc + "'.");
    notifier.reportDebug("BACIRemoteAccess::initialize", "Startup using '" + IR_CORBALOC + "' = '" + IRloc + "'.");
    String poolTime = props.getProperty(PROPERTY_POOL_TIMEOUT);
    notifier.reportDebug("BACIRemoteAccess::initialize", "Startup using '" + PROPERTY_POOL_TIMEOUT + "' = '" + poolTime + "'.");
    // check it POOL_TIME has to be oveeriden
    if (poolTime != null) {
        try {
            int value = Integer.parseInt(poolTime);
            if (value >= POLL_SLEEP)
                POLL_TIMEOUT = value;
        } catch (Exception ex) {
            notifier.reportDebug("BACIRemoteAccess::initialize", "Failed to parse '" + PROPERTY_POOL_TIMEOUT + "' property value '" + poolTime + "' as integer.");
        }
    }
    notifier.reportDebug("BACIRemoteAccess::initialize", "Configuration: STRICT flag = " + strict);
    notifier.reportDebug("BACIRemoteAccess::initialize", "Configuration: POOL_TIMEOUT = " + POLL_TIMEOUT + " ms.");
    // ORB stanza
    java.util.Properties orbprops = java.lang.System.getProperties();
    // to make code completely independed, properties have to be set using JVM -D mechanism
    // ORBacus
    //orbprops.put("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
    //orbprops.put("org.omg.CORBA.ORBSingletonClass", "com.ooc.CORBA.ORBSingleton");
    // JacORB
    //orbprops.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
    //orbprops.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
    // Java JDK (does not work)
    //if (ORBdebug)
    //       what to do here
    orb = org.omg.CORBA.ORB.init(new String[0], orbprops);
    notifier.reportDebug("BACIRemoteAccess::initialize", "ORB initialized.");
    // POA stanza -- use RootPOA
    POA rootPOA = null;
    try {
        rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
    } catch (org.omg.CORBA.ORBPackage.InvalidName in) {
        throw new IllegalStateException("Cannot resolve RootPOA: " + in);
    }
    POAManager manager = rootPOA.the_POAManager();
    notifier.reportDebug("BACIRemoteAccess::initialize", "POA initialized.");
    try {
        manager.activate();
        orbThread = new Thread(this);
        orbThread.start();
    } catch (Exception e) {
        throw new IllegalStateException("POAManager activation failed: " + e);
    }
    // resolve IR
    org.omg.CORBA.Object repRef = null;
    notifier.reportDebug("BACIRemoteAccess::initialize", "Trying to resolve 'Repository'.");
    try {
        repRef = orb.string_to_object(IRloc);
    //	repRef = orb.resolve_initial_references("DefaultRepository");
    } catch (Exception e) {
        throw new IllegalStateException("Cannot access orb initial reference 'InterfaceRepository'.");
    }
    if (repRef == null)
        throw new IllegalStateException("Cannot resolve Interface Repository");
    rep = RepositoryHelper.narrow(repRef);
    notifier.reportDebug("BACIRemoteAccess::initialize", "Obtained reference to 'Repository'.");
    notifier.reportMessage("Obtained reference to 'Repository'.");
    // clear callback descriptions list, because it is static!!
    synchronized (descriptions) {
        descriptions.clear();
        notifier.reportDebug("BACIRemoveAccess::destroy", "Cleared IF descriptions list for CallbackImpl.");
    }
    // clear callback operation descriptions list, because it is static!!
    synchronized (operationListDescriptions) {
        operationListDescriptions.clear();
        notifier.reportDebug("BACIRemoveAccess::destroy", "Cleared IF operation descriptions list for CallbackImpl.");
    }
    // start dispatcher
    dispatcher = new Dispatcher();
    dispatcher.start();
    notifier.reportDebug("BACIRemoteAccess::initialize", "Started callback dispatcher thread.");
    // resolve manager
    resolveManager();
}
Also used : Properties(java.util.Properties) POA(org.omg.PortableServer.POA) ClientPOA(si.ijs.maci.ClientPOA) Properties(java.util.Properties) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) AcsJException(alma.acs.exceptions.AcsJException) DataException(si.ijs.acs.objectexplorer.engine.DataException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) POAManager(org.omg.PortableServer.POAManager)

Example 20 with POA

use of org.omg.PortableServer.POA in project ACS by ACS-Community.

the class BACIRemoteAccess method destroy.

/**
	 * Insert the method's description here.
	 * Creation date: (1.11.2000 13:00:27)
	 */
public synchronized void destroy() {
    if (destroyed)
        return;
    destroyed = true;
    synchronized (invocations) {
        for (BACIInvocation invoc : invocations) {
            try {
                if (invoc.isControllable())
                    BACIIntrospector.destroyInvocation(invoc);
            } catch (Exception e) {
            // try others
            }
        }
        invocations.clear();
    }
    notifier.reportMessage("Logging out from the Manager.");
    synchronized (connected) {
        notifier.reportDebug("BACIRemoteAccess::destroy", "Releasing Components on Manager, " + connected.size() + " Components total.");
        for (Iterator<String> iter = connected.iterator(); iter.hasNext(); ) {
            String compName = iter.next();
            try {
                manager.release_component(handle, compName);
            } catch (Exception ex) {
                notifier.reportError("Cannot release component " + compName, ex);
            }
        }
        connected.clear();
    }
    synchronized (descriptions) {
        descriptions.clear();
        notifier.reportDebug("BACIRemoveAccess::destroy", "Cleared IF descriptions list for CallbackImpl.");
    }
    synchronized (operationListDescriptions) {
        operationListDescriptions.clear();
        notifier.reportDebug("BACIRemoveAccess::destroy", "Cleared IF operation descriptions list for CallbackImpl.");
    }
    synchronized (interfaceDescriptions) {
        interfaceDescriptions.clear();
    }
    synchronized (operationsIntrospected) {
        operationsIntrospected.clear();
    }
    synchronized (attributeIntrospected) {
        attributeIntrospected.clear();
    }
    if (manager != null) {
        try {
            manager.logout(handle);
        } catch (Exception e) {
        // try others
        }
        notifier.reportDebug("BACIRemoteAccess::destroy", "ObjectExplorer logout OK.");
    }
    /* deactivate the client object */
    org.omg.PortableServer.POA poa = client._default_POA();
    try {
        byte[] id = poa.servant_to_id(client);
        poa.deactivate_object(id);
    } catch (Exception e) {
        notifier.reportError("Error while deactivating Client servant.", e);
    }
    orb.destroy();
    notifier.reportDebug("BACIRemoteAccess::destroy", "ORB shutdown complete.");
    notifier.reportMessage("Shutting down CORBA.");
    notifier.reportDebug("BACIRemoteAccess::destroy", "Sending dispatcher termination signal.");
    dispatcher.destroy();
}
Also used : POA(org.omg.PortableServer.POA) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) AcsJException(alma.acs.exceptions.AcsJException) DataException(si.ijs.acs.objectexplorer.engine.DataException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException)

Aggregations

POA (org.omg.PortableServer.POA)33 ORB (org.omg.CORBA.ORB)11 POAManager (org.omg.PortableServer.POAManager)10 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)6 Properties (java.util.Properties)5 ClientPOA (si.ijs.maci.ClientPOA)5 Servant (org.omg.PortableServer.Servant)4 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)3 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)2 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)2 AcsJException (alma.acs.exceptions.AcsJException)2 AcsLogger (alma.acs.logging.AcsLogger)2 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)2 CDBFieldDoesNotExistEx (alma.cdbErrType.CDBFieldDoesNotExistEx)2 WrongCDBDataTypeEx (alma.cdbErrType.WrongCDBDataTypeEx)2 DummyComponent (alma.jconttest.DummyComponent)2 DummyComponentPOATie (alma.jconttest.DummyComponentPOATie)2 WDAOPOA (com.cosylab.CDB.WDAOPOA)2 HandleDataStore (com.cosylab.acs.maci.manager.HandleDataStore)2 FileWriter (java.io.FileWriter)2