use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.
the class ObjectMappedEditorFinderService method startService.
/* (非 Javadoc)
* @see jp.ossc.nimbus.core.ServiceBaseSupport#startService()
*/
public void startService() throws Exception {
// 上位リポジトリの取得
if (mFinderServiceName != null) {
this.mParentFinder = (EditorFinder) ServiceManagerFactory.getServiceObject(this.mFinderServiceName);
}
ServiceNameEditor editor = new ServiceNameEditor();
editor.setServiceManagerName(getServiceManagerName());
// 自分が管理するエディターサービスの設定
Iterator iterator = mEditorMap.keySet().iterator();
while (iterator.hasNext()) {
String classAndKey = (String) iterator.next();
String key = null;
String clsName = null;
final int index = classAndKey.indexOf(',');
if (index == -1) {
clsName = classAndKey;
} else {
clsName = classAndKey.substring(0, index);
if (index != classAndKey.length() - 1) {
key = classAndKey.substring(index + 1);
}
}
Class cls = convertStringToClass(clsName);
JournalEditor journalEditor = null;
Object value = mEditorMap.get(classAndKey);
if (value instanceof String) {
String serviceName = (String) value;
editor.setAsText(serviceName);
ServiceName name = (ServiceName) editor.getValue();
journalEditor = (JournalEditor) ServiceManagerFactory.getServiceObject(name);
} else if (value instanceof JournalEditor) {
journalEditor = (JournalEditor) value;
}
Map keyEditorMap = (Map) mEditorRepository.getValueOf(cls);
if (keyEditorMap == null) {
keyEditorMap = new HashMap();
mEditorRepository.add(cls, keyEditorMap);
}
keyEditorMap.put(key, journalEditor);
}
}
use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.
the class GroupEJBFactoryService method startService.
public void startService() throws Exception {
if (nameAndEJBFactoryServiceNameMapping == null || nameAndEJBFactoryServiceNameMapping.size() == 0) {
throw new IllegalArgumentException("nameAndEJBFactoryServiceNameMapping must be specified.");
}
final ServiceNameEditor editor = new ServiceNameEditor();
editor.setServiceManagerName(getServiceManagerName());
final Iterator names = nameAndEJBFactoryServiceNameMapping.keySet().iterator();
while (names.hasNext()) {
final String name = (String) names.next();
final Pattern pattern = Pattern.compile(name);
final String serviceNameStr = nameAndEJBFactoryServiceNameMapping.getProperty(name);
editor.setAsText(serviceNameStr);
final ServiceName serviceName = (ServiceName) editor.getValue();
nameAndEJBFactoryMap.put(pattern, (EJBFactory) ServiceManagerFactory.getServiceObject(serviceName));
}
if (defaultEJBFactoryServiceName != null) {
defaultEJBFactory = (EJBFactory) ServiceManagerFactory.getServiceObject(defaultEJBFactoryServiceName);
}
}
use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.
the class BeanShellInterpreterService method main.
public static void main(String[] args) throws Exception {
if (args.length == 0 || (args.length != 0 && args[0].equals("-help"))) {
usage();
if (args.length == 0) {
System.exit(-1);
}
return;
}
boolean option = false;
String key = null;
ServiceName serviceName = null;
List servicePaths = null;
List files = null;
String encode = null;
StringWriter code = new StringWriter();
PrintWriter codeWriter = new PrintWriter(code);
for (int i = 0; i < args.length; i++) {
if (option) {
if (key.equals("-servicename")) {
ServiceNameEditor editor = new ServiceNameEditor();
editor.setAsText(args[i]);
serviceName = (ServiceName) editor.getValue();
} else if (key.equals("-servicepath")) {
servicePaths = parsePaths(args[i]);
} else if (key.equals("-file")) {
files = parsePaths(args[i]);
} else if (key.equals("-encoding")) {
encode = args[i];
}
option = false;
key = null;
} else {
if (args[i].equals("-servicename") || args[i].equals("-servicepath") || args[i].equals("-file") || args[i].equals("-encoding")) {
option = true;
key = args[i];
} else if (args[i].equals("-help")) {
usage();
return;
} else {
codeWriter.print(" " + args[i]);
}
}
}
Interpreter interpreter = null;
if (servicePaths == null) {
BeanShellInterpreterService service = new BeanShellInterpreterService();
service.create();
service.start();
interpreter = service;
} else {
for (int i = 0, imax = servicePaths.size(); i < imax; i++) {
if (!ServiceManagerFactory.loadManager((String) servicePaths.get(i))) {
System.out.println("Service load error." + servicePaths.get(i));
Thread.sleep(1000);
System.exit(-1);
}
}
if (!ServiceManagerFactory.checkLoadManagerCompleted()) {
Thread.sleep(1000);
System.exit(-1);
}
if (serviceName == null) {
serviceName = new ServiceName("Nimbus", "Interpreter");
}
interpreter = (Interpreter) ServiceManagerFactory.getServiceObject(serviceName);
}
if (files != null) {
code.flush();
for (int i = 0, imax = files.size(); i < imax; i++) {
FileInputStream fis = new FileInputStream((String) files.get(i));
InputStreamReader isr = null;
if (encode == null) {
isr = new InputStreamReader(fis);
} else {
isr = new InputStreamReader(fis, encode);
}
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
codeWriter.println(line);
}
fis.close();
}
}
codeWriter.flush();
try {
System.out.println(interpreter.evaluate(code.toString()));
} catch (Throwable e) {
StringBuilder buf = new StringBuilder();
final String lineSeparator = System.getProperty("line.separator");
buf.append("Exception occuers :").append(e.toString()).append(lineSeparator);
final StackTraceElement[] elemss = e.getStackTrace();
if (elemss != null) {
for (int i = 0; i < elemss.length; i++) {
buf.append('\t');
if (elemss[i] != null) {
buf.append(elemss[i].toString()).append(lineSeparator);
} else {
buf.append("null").append(lineSeparator);
}
}
}
for (Throwable ee = getCause(e); ee != null; ee = getCause(ee)) {
buf.append("Caused by:").append(ee.toString()).append(lineSeparator);
final StackTraceElement[] elems = ee.getStackTrace();
if (elems != null) {
for (int i = 0; i < elems.length; i++) {
buf.append('\t');
if (elems[i] != null) {
buf.append(elems[i].toString()).append(lineSeparator);
} else {
buf.append("null").append(lineSeparator);
}
}
}
}
System.out.println(buf.toString());
} finally {
if (servicePaths != null) {
for (int i = servicePaths.size(); --i >= 0; ) {
ServiceManagerFactory.unloadManager((String) servicePaths.get(i));
}
}
}
System.exit(0);
}
use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.
the class ScheduleManagerServlet method getSchedulerServiceName.
private ServiceName getSchedulerServiceName() {
final ServletConfig config = getServletConfig();
final String serviceNameStr = config.getInitParameter(INIT_PARAM_NAME_SCHEDULER_SERVICE_NAME);
if (serviceNameStr == null) {
return null;
}
final ServiceNameEditor editor = new ServiceNameEditor();
editor.setAsText(serviceNameStr);
return (ServiceName) editor.getValue();
}
use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.
the class BeanFlowServlet method getServiceName.
protected ServiceName getServiceName(String paramName) {
final ServletConfig config = getServletConfig();
final String serviceNameStr = config.getInitParameter(paramName);
if (serviceNameStr == null) {
return null;
}
final ServiceNameEditor editor = new ServiceNameEditor();
editor.setAsText(serviceNameStr);
return (ServiceName) editor.getValue();
}
Aggregations