use of jp.ossc.nimbus.service.transaction.TransactionManagerFactory in project nimbus by nimbus-org.
the class AbstractSchedulerService method preStartService.
/**
* サービスの開始前処理を行う。<p>
*
* @exception Exception サービスの開始前処理に失敗した場合
*/
public void preStartService() throws Exception {
super.preStartService();
if (isTransactionControl) {
if (transactionManagerFactoryServiceName == null) {
final InitialContext context = new InitialContext();
transactionManager = (TransactionManager) context.lookup(TRANSACTION_MANAGER_JNDI_NAME);
} else {
TransactionManagerFactory transactionManagerFactory = (TransactionManagerFactory) ServiceManagerFactory.getServiceObject(transactionManagerFactoryServiceName);
transactionManager = transactionManagerFactory.getTransactionManager();
}
}
if (scheduleExecutorServiceNames != null) {
scheduleExecutors = new HashMap();
for (int i = 0; i < scheduleExecutorServiceNames.length; i++) {
ScheduleExecutor executor = (ScheduleExecutor) ServiceManagerFactory.getServiceObject(scheduleExecutorServiceNames[i]);
scheduleExecutors.put(executor.getType(), executor);
}
}
if (scheduleExecutors == null || scheduleExecutors.size() == 0) {
throw new IllegalArgumentException("ScheduleExecutor is null.");
}
if (scheduleManagerServiceName != null) {
scheduleManager = (ScheduleManager) ServiceManagerFactory.getServiceObject(scheduleManagerServiceName);
}
if (scheduleManager == null) {
throw new IllegalArgumentException("ScheduleManager is null.");
}
if (threadContextServiceName != null) {
threadContext = (Context) ServiceManagerFactory.getServiceObject(threadContextServiceName);
}
if (sequenceServiceName != null) {
sequence = (Sequence) ServiceManagerFactory.getServiceObject(sequenceServiceName);
}
if (timeServiceName != null) {
time = (Time) ServiceManagerFactory.getServiceObject(timeServiceName);
}
}
use of jp.ossc.nimbus.service.transaction.TransactionManagerFactory in project nimbus by nimbus-org.
the class BeanFlowInvokerAccessImpl2 method fillInstance.
public void fillInstance(Element element, BeanFlowInvokerFactoryCallBack callBack, String encoding) {
this.encoding = encoding;
try {
factoryCallBack = callBack;
flowName = MetaData.getUniqueAttribute(element, NAME_ATTRIBUTE);
coverage = new BeanFlowCoverageImpl("<flow name=\"" + flowName + "\">");
String maxThreadsStr = MetaData.getOptionalAttribute(element, MAX_RUN_THREADS_ATTRIBUTE);
if (maxThreadsStr != null) {
maxThreadsStr = factoryCallBack.replaceProperty(maxThreadsStr);
try {
int maxThreads = Integer.parseInt(maxThreadsStr);
semaphore = new MemorySemaphore();
semaphore.setResourceCapacity(maxThreads);
semaphore.accept();
} catch (NumberFormatException e) {
throw new InvalidConfigurationException("maxThreads is number " + maxThreadsStr);
}
}
String timeoutStr = MetaData.getOptionalAttribute(element, TIMEOUT_ATTRIBUTE);
if (timeoutStr != null) {
timeoutStr = factoryCallBack.replaceProperty(timeoutStr);
try {
timeout = Long.parseLong(timeoutStr);
} catch (NumberFormatException e) {
throw new InvalidConfigurationException("timeout is number " + timeoutStr);
}
}
String maxWaitCountStr = MetaData.getOptionalAttribute(element, MAX_WAIT_THREADS_ATTRIBUTE);
if (maxWaitCountStr != null) {
maxWaitCountStr = factoryCallBack.replaceProperty(maxWaitCountStr);
try {
maxWaitCount = Integer.parseInt(maxWaitCountStr);
} catch (NumberFormatException e) {
throw new InvalidConfigurationException("maxWaitThreads is number " + maxWaitCountStr);
}
}
String forceFreeTimeoutStr = MetaData.getOptionalAttribute(element, FORCE_FREE_TIMEOUT_ATTRIBUTE);
if (forceFreeTimeoutStr != null) {
forceFreeTimeoutStr = factoryCallBack.replaceProperty(forceFreeTimeoutStr);
try {
forceFreeTimeout = Long.parseLong(forceFreeTimeoutStr);
} catch (NumberFormatException e) {
throw new InvalidConfigurationException("forceFreeTimeout is number " + forceFreeTimeoutStr);
}
}
final String transactionStr = MetaData.getOptionalAttribute(element, TRANSACTION_ATTRIBUTE);
if (transactionStr != null) {
if (REQUIRED.equals(transactionStr)) {
transactionType = REQUIRED_VALUE;
} else if (REQUIRESNEW.equals(transactionStr)) {
transactionType = REQUIRESNEW_VALUE;
} else if (SUPPORTS.equals(transactionStr)) {
transactionType = SUPPORTS_VALUE;
} else if (MANDATORY.equals(transactionStr)) {
transactionType = MANDATORY_VALUE;
} else if (NEVER.equals(transactionStr)) {
transactionType = NEVER_VALUE;
} else if (NOT_SUPPORTED.equals(transactionStr)) {
transactionType = NOT_SUPPORTED_VALUE;
} else {
throw new InvalidConfigurationException("Invalid transaction : " + transactionStr);
}
if (transactionType != SUPPORTS_VALUE) {
try {
TransactionManagerFactory tranMngFactory = factoryCallBack.getTransactionManagerFactory();
if (getTransactionManagerJndiName() != null && tranMngFactory instanceof JndiTransactionManagerFactoryService) {
((JndiTransactionManagerFactoryService) tranMngFactory).setTransactionManagerName(getTransactionManagerJndiName());
}
tranManager = tranMngFactory.getTransactionManager();
} catch (TransactionManagerFactoryException e) {
throw new DeploymentException(e);
}
}
}
final String transactionTimeoutStr = MetaData.getOptionalAttribute(element, TRANTIMEOUT_ATTRIBUTE);
if (transactionTimeoutStr != null) {
try {
transactionTimeout = Integer.parseInt(transactionTimeoutStr);
} catch (NumberFormatException e) {
throw new InvalidConfigurationException("trantimeout is number " + transactionTimeoutStr);
}
}
final String journalStr = MetaData.getOptionalAttribute(element, JOURNAL_ATTRIBUTE);
if (journalStr != null) {
isJournal = Boolean.valueOf(journalStr).booleanValue();
}
final String suspendStr = MetaData.getOptionalAttribute(element, SUSPEND_ATTRIBUTE);
if (suspendStr != null) {
isSuspend = Boolean.valueOf(suspendStr).booleanValue();
}
final String stopStr = MetaData.getOptionalAttribute(element, STOP_ATTRIBUTE);
if (stopStr != null) {
isStop = Boolean.valueOf(stopStr).booleanValue();
}
final Iterator aliasElements = MetaData.getChildrenByTagName(element, ALIAS_ELEMENT);
while (aliasElements.hasNext()) {
aliasNames.add(MetaData.getUniqueAttribute((Element) aliasElements.next(), NAME_ATTRIBUTE));
}
final Iterator owElements = getChildrenByTagName(element, OVERRIDE_ELEMENT);
List overrideNameList = null;
while (owElements.hasNext()) {
Element owElement = (Element) owElements.next();
String overrideName = getUniqueAttribute(owElement, NAME_ATTRIBUTE);
if (overrideNameList == null) {
overrideNameList = new ArrayList();
}
overrideNameList.add(overrideName);
}
if (overrideNameList != null) {
overrideNames = (String[]) overrideNameList.toArray(new String[overrideNameList.size()]);
}
final Iterator inputDefElements = MetaData.getChildrenByTagName(element, INPUT_DEF_ELEMENT);
while (inputDefElements.hasNext()) {
final Element inputDefElement = (Element) inputDefElements.next();
final String name = MetaData.getUniqueAttribute(inputDefElement, NAME_ATTRIBUTE);
final String nullCheckAttribute = MetaData.getOptionalAttribute(inputDefElement, NULLCHECK_ATTRIBUTE);
boolean nullCheck = false;
if (nullCheckAttribute != null) {
nullCheck = Boolean.valueOf(nullCheckAttribute).booleanValue();
}
String val = MetaData.getElementContent(inputDefElement);
Property property = null;
if (val != null && val.length() != 0) {
try {
property = PropertyFactory.createProperty(val);
if (!nullCheck) {
property.setIgnoreNullProperty(true);
}
} catch (Exception e) {
throw new DeploymentException(e);
}
}
if (inputDefs == null) {
inputDefs = new HashMap();
}
inputDefs.put(name, property);
}
final ServiceNameEditor editor = new ServiceNameEditor();
final Iterator resourceElements = MetaData.getChildrenByTagName(element, RESOURCE_ELEMENT);
while (resourceElements.hasNext()) {
final Element resourceElement = (Element) resourceElements.next();
final String name = MetaData.getUniqueAttribute(resourceElement, NAME_ATTRIBUTE);
final String key = MetaData.getOptionalAttribute(resourceElement, KEY_ATTRIBUTE);
final String serviceNameStr = MetaData.getUniqueAttribute(resourceElement, SERVICE_ATTRIBUTE);
editor.setAsText(factoryCallBack.replaceProperty(serviceNameStr));
final ServiceName serviceName = (ServiceName) editor.getValue();
final boolean isTranControl = MetaData.getOptionalBooleanAttribute(resourceElement, TRANCONTROL_ATTRIBUTE);
final boolean isTranClose = MetaData.getOptionalBooleanAttribute(resourceElement, TRANCLOSE_ATTRIBUTE, true);
ResourceInfo resourceInfo = new ResourceInfo();
resourceInfo.name = name;
resourceInfo.key = key;
resourceInfo.serviceName = serviceName;
resourceInfo.isTranControl = isTranControl;
resourceInfo.isTranClose = isTranClose;
if (resources == null) {
resources = new HashMap();
}
resources.put(name, resourceInfo);
}
Iterator children = MetaData.getChildrenWithoutTagName(element, new String[] { ALIAS_ELEMENT, OVERRIDE_ELEMENT, INPUT_DEF_ELEMENT, RESOURCE_ELEMENT, CATCH_ELEMENT, FINALLY_ELEMENT });
boolean isReturn = false;
while (children.hasNext()) {
final Element currentElement = (Element) children.next();
final String tagName = currentElement.getTagName();
if (isReturn) {
throw new DeploymentException("Unreachable element : " + tagName);
}
Step stepObj = null;
if (STEP_ELEMENT.equals(tagName)) {
StepMetaData step = new StepMetaData(this, coverage);
step.importXML(currentElement);
stepObj = step;
} else if (CALL_FLOW_ELEMENT.equals(tagName)) {
CallFlowMetaData callFlowData = new CallFlowMetaData(this, coverage);
callFlowData.importXML(currentElement);
stepObj = callFlowData;
} else if (REPLY_ELEMENT.equals(tagName)) {
GetAsynchReplyMetaData replyData = new GetAsynchReplyMetaData(this, coverage);
replyData.importXML(currentElement);
stepObj = replyData;
} else if (SWITCH_ELEMENT.equals(tagName)) {
SwitchMetaData sw = new SwitchMetaData(this, coverage);
sw.importXML(currentElement);
stepObj = sw;
} else if (IF_ELEMENT.equals(tagName)) {
IfMetaData ifData = new IfMetaData(this, coverage);
ifData.importXML(currentElement);
stepObj = ifData;
} else if (FOR_ELEMENT.equals(tagName)) {
ForMetaData forData = new ForMetaData(this, coverage);
forData.importXML(currentElement);
stepObj = forData;
} else if (WHILE_ELEMENT.equals(tagName)) {
WhileMetaData whileData = new WhileMetaData(this, coverage);
whileData.importXML(currentElement);
stepObj = whileData;
} else if (RETURN_ELEMENT.equals(tagName)) {
ReturnMetaData returnData = new ReturnMetaData(this, coverage);
returnData.importXML(currentElement);
stepObj = returnData;
isReturn = true;
} else {
throw new DeploymentException("Invalid child tag of flow tag : " + tagName);
}
if (stepObj != null) {
if (jobSteps == null) {
jobSteps = new ArrayList();
}
jobSteps.add(stepObj);
}
}
final Iterator catchElements = MetaData.getChildrenByTagName(element, CATCH_ELEMENT);
while (catchElements.hasNext()) {
final Element catchElement = (Element) catchElements.next();
CatchMetaData step = new CatchMetaData(this, coverage);
step.importXML(catchElement);
if (catchSteps == null) {
catchSteps = new ArrayList();
}
catchSteps.add(step);
}
final Element finallyElement = MetaData.getOptionalChild(element, FINALLY_ELEMENT);
if (finallyElement != null) {
FinallyMetaData step = new FinallyMetaData(this, coverage);
step.importXML(finallyElement);
finallyStep = step;
}
stepNames = new HashSet();
if (inputDefs != null) {
stepNames.addAll(inputDefs.keySet());
}
if (jobSteps != null) {
for (int i = 0, max = jobSteps.size(); i < max; i++) {
Step jobStep = (Step) jobSteps.get(i);
jobStep.setupStepNames(stepNames);
}
}
} catch (InvalidConfigurationException e) {
e.setResourceName("flowName=" + flowName);
throw e;
} catch (DeploymentException e) {
e.setResourceName("flowName=" + flowName);
throw new InvalidConfigurationException("Invalid flow." + flowName, e);
}
journal = factoryCallBack.getJournal(this);
}
Aggregations