Search in sources :

Example 1 with InterfaceDef

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

the class BACIIntrospector method isOfType.

/**
 * Insert the method's description here.
 * Creation date: (13.11.2000 18:44:35)
 * @return boolean
 * @param tc org.omg.CORBA.TypeCode
 * @param baciType java.lang.String
 */
private boolean isOfType(TypeCode tc, String type) {
    switch(tc.kind().value()) {
        case TCKind._tk_objref:
            break;
        case TCKind._tk_alias:
            try {
                return isOfType(tc.content_type(), type);
            } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
                throw new RemoteException("Exception while analyzing typecode (getting typecode name raises exception). Exception: " + bk);
            }
        default:
            return false;
    }
    try {
        ra.getNotifier().reportDebug("BACIIntrospector::isOfType", "Checking if '" + tc.id() + "' implements '" + type + "'.");
        if (tc.id().equals(ID_CORBA_OBJECT))
            if (type.equals(ID_CORBA_OBJECT))
                return true;
            else
                return false;
        /*	Class c = Class.forName(IDtoClassName(tc.id()));
		Class c1 = null;
		try
		{ 
			c1 = Class.forName(addJavaPackagePrefix(baciType));
		} catch (Exception e)
		{
			throw new JavaIDLIntrospectionException("Introspection error while loading property class '" + addJavaPackagePrefix(baciType) + "'.");
		}
		if (c1.isAssignableFrom(c)) return true;*/
        InterfaceDef idef = InterfaceDefHelper.narrow(ra.lookupId(tc.id()));
        if (idef.is_a(type))
            return true;
    } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
        throw new RemoteException("Exception while analyzing typecode (getting typecode name raises exception). Exception: " + bk);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return false;
}
Also used : InterfaceDef(org.omg.CORBA.InterfaceDef) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) DataException(si.ijs.acs.objectexplorer.engine.DataException)

Example 2 with InterfaceDef

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

the class ComponentsManager method getComponentProperties.

/**
	 * Recursive function to get the list of all the ACS properties
	 * for a given IDL type. It scans the current interface, and then
	 * it sub-scans the inherited types
	 * 
	 * @param ifdef The IDL interface defintion
	 * @return The list of properties for the given IDL definition, including the parents' properties
	 * @throws BadKind
	 */
private List<String> getComponentProperties(InterfaceDef ifdef) throws BadKind {
    List<String> tmp = new ArrayList<String>();
    FullInterfaceDescription ifdes = ifdef.describe_interface();
    for (int i = 0; i < ifdes.attributes.length; i++) {
        TypeCode tc = ifdes.attributes[i].type;
        if (// ojo
        tc.kind() != TCKind.tk_objref)
            continue;
        InterfaceDef tcdef = InterfaceDefHelper.narrow(rep.lookup_id(tc.id()));
        if (tc.kind() == TCKind.tk_objref && tcdef.is_a(IDL_PROPERTY))
            tmp.add(ifdes.attributes[i].name);
    }
    // Lookup the children properties
    // TODO: Loop only over CharacteristicComponent interfaces
    InterfaceDef[] ifaces = ifdef.base_interfaces();
    for (int i = 0; i != ifaces.length; i++) {
        tmp.addAll(getComponentProperties(ifaces[i]));
    }
    return tmp;
}
Also used : InterfaceDef(org.omg.CORBA.InterfaceDef) FullInterfaceDescription(org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription) TypeCode(org.omg.CORBA.TypeCode) ArrayList(java.util.ArrayList)

Example 3 with InterfaceDef

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

the class EjbIIOPService method start.

@Override
public synchronized void start(final StartContext startContext) throws StartException {
    try {
        final RiverMarshallerFactory factory = new RiverMarshallerFactory();
        final MarshallingConfiguration configuration = new MarshallingConfiguration();
        configuration.setClassResolver(new FilteringClassResolver(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(".", "_");
        EjbLogger.DEPLOYMENT_LOGGER.iiopBindings(component.getComponentName(), component.getModuleName(), name);
        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 securityDomainName = "CORBA_REMOTE";
        if (component.getSecurityMetaData() != null) {
            securityDomainName = component.getSecurityMetaData().getSecurityDomainName();
        }
        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, securityDomainName, 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, securityDomainName, 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) InvalidClassException(java.io.InvalidClassException) StartException(org.jboss.msc.service.StartException) IOException(java.io.IOException) 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)

Example 4 with InterfaceDef

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

the class BACIInvocation method process.

/**
 * Insert the method's description here.
 * Creation date: (2.12.2000 2:08:26)
 * @param data si.ijs.acs.objectexplorer.engine.RemoteCall
 */
private void process(RemoteCall data) {
    BACIIntrospector.InvocationObjectHolder ioh = ra.getIntrospector().extractInvocationObject(data);
    ref = ioh.ref;
    if (ref != null) {
        InterfaceDef def = InterfaceDefHelper.narrow(ra.lookupId(ioh.id));
        if (def != null)
            desc = def.describe_interface();
    }
}
Also used : InterfaceDef(org.omg.CORBA.InterfaceDef)

Example 5 with InterfaceDef

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

the class BACIRemoteAccess method getIFDesc.

/**
	 * Insert the method's description here.
	 * Creation date: (6.5.2001 14:59:46)
	 * @return org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription
	 * @param id java.lang.String
	 */
private FullInterfaceDescription getIFDesc(String id) {
    FullInterfaceDescription fid = null;
    if (bufferDescs)
        fid = (FullInterfaceDescription) interfaceDescriptions.get(id);
    if (fid == null) {
        notifier.reportDebug("BACIRemoteAccess::getIFDesc", "Querying IR for full interface description for id '" + id + "'.");
        InterfaceDef idef = InterfaceDefHelper.narrow(rep.lookup_id(id));
        if (idef == null)
            throw new IllegalStateException("ID '" + id + "' was not found in the Repository.");
        fid = idef.describe_interface();
        if (bufferDescs)
            interfaceDescriptions.put(id, fid);
    } else {
        notifier.reportDebug("BACIRemoteAccess::getIFDesc", "Full interface description for id '" + id + "' was found in interface cache.");
    }
    return fid;
}
Also used : InterfaceDef(org.omg.CORBA.InterfaceDef) FullInterfaceDescription(org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription)

Aggregations

InterfaceDef (org.omg.CORBA.InterfaceDef)7 ArrayList (java.util.ArrayList)3 FullInterfaceDescription (org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription)2 ComponentDescriptor (alma.acs.component.ComponentDescriptor)1 ZeroPortPolicy (com.sun.corba.se.spi.extension.ZeroPortPolicy)1 IOException (java.io.IOException)1 InvalidClassException (java.io.InvalidClassException)1 TransactionManager (javax.transaction.TransactionManager)1 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)1 StatelessSessionComponent (org.jboss.as.ejb3.component.stateless.StatelessSessionComponent)1 EJBMetaDataImplIIOP (org.jboss.ejb.iiop.EJBMetaDataImplIIOP)1 HomeHandleImplIIOP (org.jboss.ejb.iiop.HomeHandleImplIIOP)1 MarshallingConfiguration (org.jboss.marshalling.MarshallingConfiguration)1 RiverMarshallerFactory (org.jboss.marshalling.river.RiverMarshallerFactory)1 IORSecurityConfigMetaData (org.jboss.metadata.ejb.jboss.IORSecurityConfigMetaData)1 IORTransportConfigMetaData (org.jboss.metadata.ejb.jboss.IORTransportConfigMetaData)1 StartException (org.jboss.msc.service.StartException)1 Any (org.omg.CORBA.Any)1 Contained (org.omg.CORBA.Contained)1 ORB (org.omg.CORBA.ORB)1