ContainerConfig.Container.Property iiopHost = cfg.getProperty("iiop-host");
ContainerConfig.Container.Property iiopPort = cfg.getProperty("iiop-port");
// check the required delegator-name property
if (delegatorProp == null || UtilValidate.isEmpty(delegatorProp.value)) {
throw new ContainerException("Invalid delegator-name defined in container configuration");
}
// check the required dispatcher-name property
if (dispatcherProp == null || UtilValidate.isEmpty(dispatcherProp.value)) {
throw new ContainerException("Invalid dispatcher-name defined in container configuration");
}
// check the required admin-user property
if (adminProp == null || UtilValidate.isEmpty(adminProp.value)) {
throw new ContainerException("Invalid admin-user defined in container configuration");
}
if (adminPassProp == null || UtilValidate.isEmpty(adminPassProp.value)) {
throw new ContainerException("Invalid admin-pass defined in container configuration");
}
if (engineName == null || UtilValidate.isEmpty(engineName.value)) {
throw new ContainerException("Invalid engine-name defined in container configuration");
}
// get the delegator and dispatcher objects
SharkContainer.delegator = DelegatorFactory.getDelegator(delegatorProp.value);
SharkContainer.dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherProp.value, SharkContainer.delegator);
// get the admin user
try {
SharkContainer.adminUser = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", adminProp.value));
} catch (GenericEntityException e) {
throw new ContainerException(e);
}
// make sure the admin user exists
if (SharkContainer.adminUser == null) {
Debug.logWarning("Invalid admin-user; UserLogin not found not starting Shark!", module);
return false;
}
SharkContainer.adminPass = adminPassProp.value;
// set the Shark configuration
Properties props = UtilProperties.getProperties("shark.properties");
Shark.configure(props);
String java_home = System.getenv("JAVA_HOME");
if ((java_home == null) && (java_home.length() > 0))
{
Debug.logError("OUT :Java home variable is undefined", module);
} else
if (iiopHost != null && UtilValidate.isNotEmpty(iiopHost.value)) {
if (iiopPort != null && UtilValidate.isNotEmpty(iiopPort.value)) {
try {
p = Runtime.getRuntime().exec(java_home + "\\" + "bin\\tnameserv"
+ " -ORBInitialPort "
+ iiopPort.value);
Thread.sleep(5000);
} catch (IOException e) {
Debug.logError("OUT : Could not start SERVER", module);
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else
Debug.logError("OUT : Error in iiop port property", module);
}
else
Debug.logError("OUT : Error in iiop host property", module);
SharkContainer.shark = Shark.getInstance();
Debug.logInfo("Started Shark workflow service", module);
// create the CORBA server and bind to iiop
if (iiopHost != null && UtilValidate.isNotEmpty(iiopHost.value)) {
if (iiopPort != null && UtilValidate.isNotEmpty(iiopPort.value)) {
try {
corbaServer = new SharkCORBAServer(engineName.value, iiopHost.value, iiopPort.value, shark);
orbThread = new Thread(this);
orbThread.setDaemon(false);
orbThread.setName(this.getClass().getName());
orbThread.start();
Debug.logInfo("Started Shark CORBA service", module);
} catch (IllegalArgumentException e) {
throw new ContainerException(e);
} catch (GeneralRuntimeException e) {
throw new ContainerException(e);
}
}
}
// re-eval current assignments
ExecutionAdministration exAdmin = SharkContainer.getAdminInterface().getExecutionAdministration();
try {
//exAdmin.connect(adminUser.getString("userLoginId"), SharkContainer.adminPass, null, null);
exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
// this won't work with encrypted passwords: exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
exAdmin.reevaluateAssignments();
exAdmin.disconnect();
} catch (ConnectFailed e) {
String errMsg = "Shark Connection error (if it is a password wrong error, check the admin-pass property in the container config file, probably ofbiz-containers.xml): " + e.toString();
throw new ContainerException(errMsg, e);
} catch (NotConnected e) {
throw new ContainerException(e);
} catch (BaseException e) {
throw new ContainerException(e);
}
return true;
}