Search in sources :

Example 31 with POA

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

the class AcsCorba method getPOAForOffshoots.

/**
	 * Creates (or reuses) the non-persistent POA for offshoot objects as a child of the given POA.
	 * In spite of the suggestive name 'componentPOA', this POA can actually be any kind of POA,
	 * so that also client application can use the offshoot mechanism. 
	 * <p>
	 * This method is synchronized inside to avoid race conditions between several offshoot POA creation/retrievals,
	 * where otherwise the POA would fail to be created even though first it was not found for reuse.
	 * 
	 * @param componentPOA  the POA of the component that owns the offshoot object;
	 * 							 will become the parent of the offshoot POA.
	 * @return POA  non-persistent POA for offshoot objects for the current component.
	 * 
	 * @throws AcsJContainerServicesEx
	 */
public POA getPOAForOffshoots(POA componentPOA) throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
    final String offshootPoaName = "offshootPoa";
    POA offshootPoa = null;
    synchronized (componentPOA) {
        try {
            // can we reuse it? 
            offshootPoa = componentPOA.find_POA(offshootPoaName, false);
        } catch (AdapterNonExistent e) {
            m_logger.finest("will have to create offshoot POA");
            if (m_offshootPolicies == null) {
                m_offshootPolicies = new Policy[4];
                m_offshootPolicies[0] = componentPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
                m_offshootPolicies[1] = componentPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
                m_offshootPolicies[2] = componentPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
                m_offshootPolicies[3] = componentPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
            }
            try {
                offshootPoa = componentPOA.create_POA(offshootPoaName, sharedPoaManager, m_offshootPolicies);
                m_logger.finest("successfully created offshoot POA");
            } catch (InvalidPolicy ex) {
                AcsJContainerEx ex2 = new AcsJContainerEx(ex);
                ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
                throw ex2;
            } catch (AdapterAlreadyExists ex) {
                // we sync on componentPOA, so this should never happen
                throw new AcsJUnexpectedExceptionEx(ex);
            }
        }
    }
    return offshootPoa;
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) POA(org.omg.PortableServer.POA) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AdapterAlreadyExists(org.omg.PortableServer.POAPackage.AdapterAlreadyExists) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) AdapterNonExistent(org.omg.PortableServer.POAPackage.AdapterNonExistent)

Example 32 with POA

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

the class ACSRemoteAccess method initialize.

/**
	 * Initialize the connection.
	 * 
	 * @param theORB The ORB. 
	 *               If it is null then a new CORBA connection is initialized.
	 * @param manager A reference to the Manager
	 *                If it is null a reference is built by reading the properties.
	 */
public void initialize(ORB theORB, Manager manager) {
    isExternalORB = (theORB != null);
    this.orb = theORB;
    if (orb == null) {
        listenersDispatcher.publishReport("Initializing CORBA...");
        // ORB stanza
        java.util.Properties orbprops = java.lang.System.getProperties();
        orb = ORB.init(new String[0], orbprops);
        // 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 poaManager = rootPOA.the_POAManager();
        try {
            poaManager.activate();
        } catch (Exception e) {
            throw new IllegalStateException("POAManager activation failed." + e);
        }
        // setup ORB profiling
        try {
            if (orb instanceof AcsProfilingORB) {
                AcsORBProfiler profiler = new AcsORBProfilerImplBase(logger);
                ((AcsProfilingORB) orb).registerAcsORBProfiler(profiler);
                logger.finer("Orb profiling set up, using class " + AcsORBProfilerImplBase.class.getName());
            }
        } catch (Throwable th) {
            logger.log(Level.WARNING, "Failed to setup ORB profiling.", th);
        }
        // end of CORBA stanza
        listenersDispatcher.publishReport("CORBA initialized.");
    }
    Manager maciManager = manager;
    if (maciManager == null) {
        maciManager = resolveManagerReference();
        if (maciManager == null) {
            // HSO: Ale, should this not throw an exception?
            return;
        }
    }
    NamingContext namingContext = resolveNamingServiceContext(maciManager);
    if (namingContext == null) {
        return;
    }
    if (!resolveNotifyChannel(LOGGING_XML_CHANNEL, namingContext)) {
        return;
    }
    boolean isConsumerAdminCreated = createConsumerAdmin();
    if (!isConsumerAdminCreated) {
        return;
    }
    isInitialized = createStructuredPushConsumer();
}
Also used : AcsORBProfilerImplBase(alma.acs.profiling.orb.AcsORBProfilerImplBase) POA(org.omg.PortableServer.POA) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) NamingContext(org.omg.CosNaming.NamingContext) AcsORBProfiler(org.jacorb.orb.acs.AcsORBProfiler) POAManager(org.omg.PortableServer.POAManager) AcsProfilingORB(org.jacorb.orb.acs.AcsProfilingORB)

Example 33 with POA

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

the class BlockingPingClient method initializeCORBA.

/**
	 * Initializes CORBA.
	 */
private void initializeCORBA() {
    System.out.println("Initializing CORBA...");
    // 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 (none)
    orb = org.omg.CORBA.ORB.init(new String[0], orbprops);
    // 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();
    try {
        // activate POA
        manager.activate();
        // start CORBA event-handler thread 
        orbThread = new Thread(this);
        orbThread.start();
    } catch (Exception e) {
        throw new IllegalStateException("POAManager activation failed: " + e);
    }
    System.out.println("CORBA initialized.");
}
Also used : POA(org.omg.PortableServer.POA) ClientPOA(si.ijs.maci.ClientPOA) POAManager(org.omg.PortableServer.POAManager)

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