use of org.omg.CORBA.Policy in project ACS by ACS-Community.
the class ManagerContainerServices method checkOffShootPOA.
/**
* Creates the shared offshoot poa on demand
*/
public void checkOffShootPOA() throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
final String offshootPoaName = "offshootPoa";
synchronized (clientPOA) {
try {
// can we reuse it?
offshootPoa = clientPOA.find_POA(offshootPoaName, false);
} catch (AdapterNonExistent e) {
logger.finest("will have to create offshoot POA");
if (offshootPolicies == null) {
offshootPolicies = new Policy[4];
offshootPolicies[0] = clientPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
offshootPolicies[1] = clientPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
offshootPolicies[2] = clientPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
offshootPolicies[3] = clientPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
}
try {
offshootPoa = clientPOA.create_POA(offshootPoaName, clientPOA.the_POAManager(), offshootPolicies);
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);
}
}
}
}
use of org.omg.CORBA.Policy in project ACS by ACS-Community.
the class ClientProxy method wrapForRoundtripTimeout.
/**
* <p>
* Impl note: The corba spec (v 2.4, 4.3.8.1) describes the difference between
* SetOverrideType.SET_OVERRIDE and SetOverrideType.ADD_OVERRIDE. It is not clear to me (HSO)
* which one should be used, or if there is no practical difference.
* @param corbaRef
* @param timeoutSeconds
* @return
* @throws AcsJCORBAProblemEx
*/
public si.ijs.maci.Client wrapForRoundtripTimeout(si.ijs.maci.Client corbaRef, double timeoutSeconds) throws AcsJCORBAProblemEx {
try {
org.omg.CORBA.ORB orb = getOrb();
Any rrtPolicyAny = orb.create_any();
rrtPolicyAny.insert_ulonglong(UTCUtility.durationJavaMillisToOmg((long) timeoutSeconds * 1000));
Policy p = orb.create_policy(RELATIVE_RT_TIMEOUT_POLICY_TYPE.value, rrtPolicyAny);
org.omg.CORBA.Object ret = corbaRef._set_policy_override(new Policy[] { p }, SetOverrideType.SET_OVERRIDE);
p.destroy();
return si.ijs.maci.ClientHelper.narrow(ret);
} catch (Throwable thr) {
AcsJCORBAProblemEx ex2 = new AcsJCORBAProblemEx(thr);
ex2.setInfo("Failed to set the object-level client-side corba roundtrip timeout to " + timeoutSeconds);
throw ex2;
}
}
use of org.omg.CORBA.Policy in project ACS by ACS-Community.
the class AlarmSystemContainerServices method getPOAForOffshoots.
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) {
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, alSysCorbaServer.getRootPOA().the_POAManager(), m_offshootPolicies);
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;
}
use of org.omg.CORBA.Policy 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);
}
}
use of org.omg.CORBA.Policy in project Payara by payara.
the class POARemoteReferenceFactory method createReferenceFactory.
private ReferenceFactory createReferenceFactory(String poaId, String repoid) throws Exception {
try {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, ".createReferenceFactory->: {0} {1}", new Object[] { poaId, repoid });
}
ReferenceFactoryManager rfm = (ReferenceFactoryManager) orb.resolve_initial_references(ORBConstants.REFERENCE_FACTORY_MANAGER);
List<Policy> policies = new ArrayList<Policy>();
// Servant caching for local RMI-IIOP invocation performance
policies.add(ServantCachingPolicy.getPolicy());
// OTS Policy
policies.add(new OTSPolicyImpl());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, ".createReferenceFactory: {0} {1}: {2}", new Object[] { poaId, repoid, ejbDescriptor });
}
// CSIv2 Policy
policies.add(new CSIv2Policy(ejbDescriptor));
String threadPoolName = container.getUseThreadPoolId();
int threadPoolNumericID = 0;
boolean usePassByReference = container.getPassByReference();
if (usePassByReference) {
policies.add(new CopyObjectPolicy(PASS_BY_REFERENCE_ID));
}
if (threadPoolName != null) {
ThreadPoolManager threadPoolManager = S1ASThreadPoolManager.getThreadPoolManager();
try {
threadPoolNumericID = threadPoolManager.getThreadPoolNumericId(threadPoolName);
policies.add(new RequestPartitioningPolicy(threadPoolNumericID));
} catch (Exception ex) {
logger.log(Level.WARNING, "Not using threadpool-request-partitioning...", ex);
}
}
if (logger.isLoggable(Level.FINE)) {
String jndiName = ejbDescriptor.getJndiName();
logger.log(Level.FINE, "Using Thread-Pool: [{0} ==> {1}] for jndi name: {2}", new Object[] { threadPoolName, threadPoolNumericID, jndiName });
logger.log(Level.FINE, "Pass by reference: [{0}] for jndi name: {1}", new Object[] { usePassByReference, usePassByReference });
}
// if EJB allows only SSL invocations
if (ejbDescriptor.allMechanismsRequireSSL()) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.WARNING, ".createReferenceFactory: {0} {1}: adding ZeroPortPolicy", new Object[] { poaId, repoid });
}
if (!GlassFishORBManager.disableSSLCheck()) {
policies.add(ZeroPortPolicy.getPolicy());
}
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, ".createReferenceFactory: {0} {1}: policies: {2}", new Object[] { poaId, repoid, policies });
}
ReferenceFactory rf = rfm.create(poaId, repoid, policies, this);
return rf;
} finally {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.WARNING, ".createReferenceFactory<-: {0} {1}", new Object[] { poaId, repoid });
}
}
}
Aggregations