use of org.omg.PortableServer.POA in project ACS by ACS-Community.
the class DumpManagerState 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.");
}
use of org.omg.PortableServer.POA 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.PortableServer.POA in project ACS by ACS-Community.
the class ComponentClientTestCase method setUp.
/**
* Starts CORBA in the client process and connects to the manager and logger.
* <p>
* <b>Subclasses that override this method must call <code>super.setUp()</code>,
* likely before any other code in that method.</b>
*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
m_logger = ClientLogManager.getAcsLogManager().getLoggerForApplication(getFullName(), true);
m_logger.info("-------------------------------");
m_logger.info("ComponentClientTestCase#setUp()");
POA rootPOA = null;
try {
acsCorba = new AcsCorba(m_logger);
rootPOA = acsCorba.initCorbaForClient(false);
connectToManager();
DAL cdb = DALHelper.narrow(m_acsManagerProxy.get_service("CDB", false));
m_threadFactory = new CleaningDaemonThreadFactory(m_namePrefix, m_logger);
m_containerServices = new ContainerServicesImpl(m_acsManagerProxy, cdb, rootPOA, acsCorba, m_logger, m_acsManagerProxy.getManagerHandle(), this.getClass().getName(), null, m_threadFactory) {
public AcsLogger getLogger() {
return m_logger;
}
};
managerClientImpl.setContainerServices(m_containerServices);
initRemoteLogging();
ACSAlarmSystemInterfaceFactory.init(m_containerServices);
} catch (Exception ex1) {
m_logger.log(Level.SEVERE, "failed to initialize the ORB, or connect to the ACS Manager, " + "or to set up the container services.", ex1);
if (acsCorba != null) {
try {
acsCorba.shutdownORB(true, false);
acsCorba.doneCorba();
} catch (Exception ex2) {
// to JUnit we want to forward the original exception ex1,
// not any other exception from cleaning up the orb
// which we would not have done without the first exception.
// Thus we simply print ex2 but let ex1 fly
ex2.printStackTrace();
}
}
throw ex1;
}
}
use of org.omg.PortableServer.POA in project ACS by ACS-Community.
the class ManagerEngine method initializeManager.
/**
* Initialize and activate Manager.
*/
private void initializeManager() throws Throwable {
logger = ClientLogManager.getAcsLogManager().getLoggerForApplication("Manager", true);
logger.info("Initializing Manager.");
//
// CORBA
//
// obtain CORBA Service
corbaService = new DefaultCORBAService(logger);
// get ORB
final ORB orb = corbaService.getORB();
if (orb == null) {
CoreException ce = new CoreException("CORBA Service can not provide ORB.");
throw ce;
}
// get RootPOA
POA rootPOA = corbaService.getRootPOA();
if (rootPOA == null) {
CoreException ce = new CoreException("CORBA Service can not provide RootPOA.");
throw ce;
}
//
// Remote Directory
//
NamingServiceRemoteDirectory remoteDirectory = new NamingServiceRemoteDirectory(orb, logger);
Context context = null;
if (remoteDirectory != null)
context = remoteDirectory.getContext();
//
// Initialize CORBA
//
// set USER_ID, PERSISTENT policies
org.omg.CORBA.Policy[] policies = new org.omg.CORBA.Policy[2];
/*
// set USER_ID, PERSISTENT,BIDIRECTIONAL policies
org.omg.CORBA.Policy [] policies = new org.omg.CORBA.Policy[3];
*/
policies[0] = rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID);
policies[1] = rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
/*
// create BIDIRECTIONAL policy
Any bidirValue = orb.create_any();
BidirectionalPolicyValueHelper.insert(bidirValue, BOTH.value);
policies[2] = orb.create_policy(BIDIRECTIONAL_POLICY_TYPE.value, bidirValue);
*/
// create ManagerPOA
managerPOA = rootPOA.create_POA("ManagerPOA", rootPOA.the_POAManager(), policies);
// destroy policies
for (int i = 0; i < policies.length; i++) policies[i].destroy();
// initialize Manager implementation
// allow object reference serialization
CORBAReferenceSerializator.setOrb(orb);
manager = new ManagerImpl();
manager.setDomain(MANAGER_DOMAIN);
recoveryLocation = FileHelper.getTempFileName(null, RECOVERY_DIR_NAME);
String readRecovery = System.getProperties().getProperty("Manager.recovery", "true");
if (readRecovery.equalsIgnoreCase("false")) {
// if we are not interested in recovery files just delete them
File recoveryDir = new File(recoveryLocation);
//recoveryDir.delete();
File[] files = recoveryDir.listFiles();
for (int i = 0; files != null && i < files.length; i++) files[i].delete();
// Now check if there are log files left. Maybe user do not have enough permision
// or we are didn't set proper permission before Manager killed.
// That can lead to unwanted or illegal state so we will refuse to continue
files = recoveryDir.listFiles();
for (int i = 0; files != null && i < files.length; i++) {
if (files[i].getName().endsWith(".commandLog"))
throw new Exception("Some recovery files are left in recovery location probably because of permission\nUnable to start without recovery state!");
}
} else {
// remove old recovery files
RecoveryFilesRemover.removeRecoveryFiles(new File(recoveryLocation));
}
SnapshotPrevayler prevayler = null;
if (isPrevaylerDisabled) {
System.out.println("Prevayler disabled!");
} else {
prevayler = new SnapshotPrevayler(manager, recoveryLocation);
if (readRecovery.equalsIgnoreCase("false")) {
// just to invalidate prevaylers message
System.out.println("Skipping saved manager state!");
}
manager = (ManagerImpl) prevayler.system();
}
CDBAccess cdbAccess = new CDBAccess(orb, logger);
LogConfig logConfig = ClientLogManager.getAcsLogManager().getLogConfig();
logConfig.setCDBLoggingConfigPath("MACI/Managers/Manager");
logConfig.setCDB(cdbAccess.connectAndGetDAL());
try {
logConfig.initialize(false);
} catch (LogConfigException ex) {
// if the CDB can't be read, we still want to run the manager, so
// we only log the problems
logger.log(Level.FINE, "Failed to configure logging (default values will be used). Reason: " + ex.getMessage());
}
// initialize manager "mock" container services
ManagerContainerServices managerContainerServices = new ManagerContainerServices(orb, managerPOA, cdbAccess.getDAL(), logger);
manager.initialize(prevayler, cdbAccess, context, logger, managerContainerServices);
manager.setShutdownImplementation(shutdownImplementation);
// setup ORB profiling
try {
if (orb instanceof AcsProfilingORB) {
AcsORBProfiler profiler = new ManagerOrbProfiler(manager, logger);
((AcsProfilingORB) orb).registerAcsORBProfiler(profiler);
logger.finer("Orb profiling set up, using class " + ManagerOrbProfiler.class.getName());
}
} catch (Throwable th) {
logger.log(Level.WARNING, "Failed to setup ORB profiling.", th);
}
if (prevayler != null) {
FileHelper.setFileAttributes("g+w", recoveryLocation);
// create new task for snapshoot creation,
final long MINUTE_IN_MS = 60 * 1000;
new RecoverySnapshotTask(prevayler, 1 * MINUTE_IN_MS, recoveryLocation, manager.getStatePersitenceFlag());
}
// initialize Manager CORBA Proxy (create servant)
managerProxy = new ManagerProxyImpl(manager, logger);
//activate object
managerPOA.activate_object_with_id(MANAGER_ID, managerProxy);
// get object reference from the servant
org.omg.CORBA.Object obj = managerPOA.servant_to_reference(managerProxy);
managerReference = ManagerHelper.narrow(obj);
// get IOR
String ior = orb.object_to_string(managerReference);
// notify user
logger.info("Manager activated with " + ior);
// register special service components to the Manager
manager.setManagerComponentReference(managerReference);
// set transport
manager.setTransport(new CORBATransport(orb, ior));
// register NameService
if (remoteDirectory != null) {
String reference = remoteDirectory.getReference();
if (reference != null) {
// convert iiop to corbaloc
if (reference.startsWith("iiop://")) {
reference = reference.replaceFirst("iiop://", "corbaloc::");
if (reference.charAt(reference.length() - 1) != '/')
reference += "/NameService";
else
reference += "NameService";
}
}
try {
obj = NamingContextHelper.narrow(orb.string_to_object(reference));
} catch (Exception ex) {
// Something went wrong getting the NS
logger.log(Level.SEVERE, "Error getting the NameServer. Manager exiting...");
this.shutdownImplementation.shutdown(false);
}
manager.setRemoteDirectoryComponentReference(obj);
}
// intitialize federation here - after remote directory is set (if it is)
// (this is not a nice solution)
Hashtable federationDirectoryProperties = new Hashtable();
// set CosNamingFactory
federationDirectoryProperties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
// set orb
federationDirectoryProperties.put("java.naming.corba.orb", orb);
manager.initializeFederation(federationDirectoryProperties);
// initialize remote logging
new Thread(new Runnable() {
public void run() {
ClientLogManager.getAcsLogManager().initRemoteLogging(orb, managerReference, manager.getHandle(), true);
}
}, "Remote logging initializer").start();
manager.initializationDone();
}
use of org.omg.PortableServer.POA in project wildfly by wildfly.
the class IIOPSubsystemAdd method launchServices.
protected void launchServices(final OperationContext context, final ModelNode model) throws OperationFailedException {
IIOPLogger.ROOT_LOGGER.activatingSubsystem();
// set the ORBUseDynamicStub system property.
WildFlySecurityManager.setPropertyPrivileged("org.jboss.com.sun.CORBA.ORBUseDynamicStub", "true");
// we set the same stub factory to both the static and dynamic stub factory. As there is no way to dynamically change
// the userDynamicStubs's property at runtime it is possible for the ORB class's <clinit> method to be
// called before this property is set.
// TODO: investigate a better way to handle this
com.sun.corba.se.spi.orb.ORB.getPresentationManager().setStubFactoryFactory(true, new DelegatingStubFactoryFactory());
com.sun.corba.se.spi.orb.ORB.getPresentationManager().setStubFactoryFactory(false, new DelegatingStubFactoryFactory());
// setup naming.
InitialContext.addUrlContextFactory("corbaloc", JBossCNCtxFactory.INSTANCE);
InitialContext.addUrlContextFactory("corbaname", JBossCNCtxFactory.INSTANCE);
InitialContext.addUrlContextFactory("IOR", JBossCNCtxFactory.INSTANCE);
InitialContext.addUrlContextFactory("iiopname", JBossCNCtxFactory.INSTANCE);
InitialContext.addUrlContextFactory("iiop", JBossCNCtxFactory.INSTANCE);
context.addStep(new AbstractDeploymentChainStep() {
public void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(IIOPExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JDKORB, new IIOPDependencyProcessor());
processorTarget.addDeploymentProcessor(IIOPExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JDKORB, new IIOPMarkerProcessor());
}
}, OperationContext.Stage.RUNTIME);
// get the configured ORB properties.
Properties props = this.getConfigurationProperties(context, model);
// setup the ORB initializers using the configured properties.
this.setupInitializers(props);
// setup the SSL socket factories, if necessary.
final boolean sslConfigured = this.setupSSLFactories(props);
// create the service that initializes and starts the CORBA ORB.
CorbaORBService orbService = new CorbaORBService(props);
final ServiceBuilder<ORB> builder = context.getServiceTarget().addService(CorbaORBService.SERVICE_NAME, orbService);
org.jboss.as.server.Services.addServerExecutorDependency(builder, orbService.getExecutorInjector(), false);
// if a security domain has been specified, add a dependency to the domain service.
String securityDomain = props.getProperty(Constants.SECURITY_SECURITY_DOMAIN);
if (securityDomain != null)
builder.addDependency(SECURITY_DOMAIN_SERVICE_NAME.append(securityDomain));
// add dependencies to the ssl context services if needed.
final String serverSSLContextName = props.getProperty(Constants.SERVER_SSL_CONTEXT);
if (serverSSLContextName != null) {
ServiceName serverContextServiceName = context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, serverSSLContextName, SSLContext.class);
builder.addDependency(serverContextServiceName);
}
final String clientSSLContextName = props.getProperty(Constants.CLIENT_SSL_CONTEXT);
if (clientSSLContextName != null) {
ServiceName clientContextServiceName = context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, clientSSLContextName, SSLContext.class);
builder.addDependency(clientContextServiceName);
}
// if an authentication context has ben specified, add a dependency to its service.
final String authContext = props.getProperty(Constants.ORB_INIT_AUTH_CONTEXT);
if (authContext != null) {
ServiceName authContextServiceName = context.getCapabilityServiceName(AUTH_CONTEXT_CAPABILITY, authContext, AuthenticationContext.class);
builder.addDependency(authContextServiceName);
}
// inject the socket bindings that specify IIOP and IIOP/SSL ports.
String socketBinding = props.getProperty(Constants.ORB_SOCKET_BINDING);
builder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(socketBinding), SocketBinding.class, orbService.getIIOPSocketBindingInjector());
String sslSocketBinding = props.getProperty(Constants.ORB_SSL_SOCKET_BINDING);
if (sslSocketBinding != null) {
if (!sslConfigured) {
throw IIOPLogger.ROOT_LOGGER.sslPortWithoutSslConfiguration();
}
builder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(sslSocketBinding), SocketBinding.class, orbService.getIIOPSSLSocketBindingInjector());
}
// create the IOR security config metadata service.
final IORSecurityConfigMetaData securityConfigMetaData = this.createIORSecurityConfigMetaData(context, model, sslConfigured);
final IORSecConfigMetaDataService securityConfigMetaDataService = new IORSecConfigMetaDataService(securityConfigMetaData);
context.getServiceTarget().addService(IORSecConfigMetaDataService.SERVICE_NAME, securityConfigMetaDataService).setInitialMode(ServiceController.Mode.ACTIVE).install();
builder.addDependency(IORSecConfigMetaDataService.SERVICE_NAME);
// set the initial mode and install the service.
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
// create the service the initializes the Root POA.
CorbaPOAService rootPOAService = new CorbaPOAService("RootPOA", "poa");
context.getServiceTarget().addService(CorbaPOAService.ROOT_SERVICE_NAME, rootPOAService).addDependency(CorbaORBService.SERVICE_NAME, ORB.class, rootPOAService.getORBInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// create the service the initializes the interface repository POA.
final CorbaPOAService irPOAService = new CorbaPOAService("IRPOA", "irpoa", IdAssignmentPolicyValue.USER_ID, null, null, LifespanPolicyValue.PERSISTENT, null, null, null);
context.getServiceTarget().addService(CorbaPOAService.INTERFACE_REPOSITORY_SERVICE_NAME, irPOAService).addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, irPOAService.getParentPOAInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// create the service that initializes the naming service POA.
final CorbaPOAService namingPOAService = new CorbaPOAService("Naming", null, IdAssignmentPolicyValue.USER_ID, null, null, LifespanPolicyValue.PERSISTENT, null, null, null);
context.getServiceTarget().addService(CorbaPOAService.SERVICE_NAME.append("namingpoa"), namingPOAService).addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, namingPOAService.getParentPOAInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// create the CORBA naming service.
final CorbaNamingService namingService = new CorbaNamingService(props);
context.getServiceTarget().addService(CorbaNamingService.SERVICE_NAME, namingService).addDependency(CorbaORBService.SERVICE_NAME, ORB.class, namingService.getORBInjector()).addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, namingService.getRootPOAInjector()).addDependency(CorbaPOAService.SERVICE_NAME.append("namingpoa"), POA.class, namingService.getNamingPOAInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
configureClientSecurity(props);
}
Aggregations