use of jp.ossc.nimbus.service.log.Logger in project nimbus by nimbus-org.
the class DefaultServiceManagerService method unregisterService.
// ServiceManagerのJavaDoc
public boolean unregisterService(String name) {
final Logger logger = getLogger();
logger.write(SVCM_00004, name);
Service service = null;
try {
service = getService(name);
} catch (ServiceNotFoundException e) {
return true;
}
final boolean result = repository.unregister(name);
if (result) {
processUnregisterd(service);
logger.write(SVCM_00005, new Object[] { getServiceName(), name });
} else {
logger.write(SVCM_00006, new Object[] { getServiceName(), name });
}
return result;
}
use of jp.ossc.nimbus.service.log.Logger in project nimbus by nimbus-org.
the class DefaultServiceManagerService method waitRegistrationServiceProcess.
private void waitRegistrationServiceProcess(final ServiceManager targetMng, final String targetService, final String waitService, final int state, final Set completed, final boolean isInit) {
final Logger logger = getLogger();
final ServiceName cause = new ServiceName(targetMng.getServiceName(), targetService);
addWaitingServiceCause(cause, waitService);
targetMng.addRegistrationListener(new RegistrationListener() {
public void registered(RegistrationEvent e) {
final Service service = (Service) e.getRegistration();
if (!service.getServiceName().equals(targetService)) {
return;
}
removeWaitingServiceCause(cause, waitService);
targetMng.removeRegistrationListener(this);
if (!isMatchingState(service, state, isInit)) {
waitServiceStateProcess(service, DefaultServiceManagerService.this, waitService, state, completed);
} else if (!completed.contains(waitService)) {
DefaultServiceManagerService.this.changeServiceState(waitService, state, completed);
}
}
public void unregistered(RegistrationEvent e) {
}
});
String messageId = null;
switch(state) {
case CREATING:
messageId = SVCM_00029;
break;
case STARTING:
messageId = SVCM_00030;
break;
default:
break;
}
logger.write(messageId, new Object[] { targetMng.getServiceName(), targetService, getServiceName(), waitService });
}
use of jp.ossc.nimbus.service.log.Logger in project nimbus by nimbus-org.
the class DefaultServiceManagerService method changeServiceState.
private boolean changeServiceState(Service service, int state) {
final Logger logger = getLogger();
final String managerName = service.getServiceManagerName();
final String serviceName = service.getServiceName();
if (getServiceName().equals(serviceName)) {
return false;
}
ServiceManager manager = null;
if (managerName.equals(getServiceName())) {
manager = this;
} else {
manager = ServiceManagerFactory.findManager(managerName);
}
ServiceMetaData serviceData = null;
try {
serviceData = manager.getServiceMetaData(serviceName);
} catch (ServiceNotFoundException e) {
}
try {
return changeServiceState(service, serviceData, state);
} catch (Exception e) {
switch(state) {
case CREATING:
logger.write(SVCM_00033, new Object[] { managerName, serviceName }, e);
if (managerName.equals(getServiceName())) {
addFailedServiceCause(serviceName, e);
}
return false;
case STARTING:
logger.write(SVCM_00034, new Object[] { managerName, serviceName }, e);
if (managerName.equals(getServiceName())) {
addFailedServiceCause(serviceName, e);
}
return false;
case STOPPING:
case DESTROYING:
default:
return true;
}
}
}
use of jp.ossc.nimbus.service.log.Logger in project nimbus by nimbus-org.
the class DefaultServiceManagerService method callInvoke.
private Object callInvoke(Object target, ObjectMetaData objData, InvokeMetaData invoke) throws Exception {
final Logger logger = getLogger();
final String methodName = invoke.getName();
Class clazz = null;
Method method = null;
Object[] argVals = null;
try {
if (invoke instanceof StaticInvokeMetaData) {
clazz = Utility.convertStringToClass(((StaticInvokeMetaData) invoke).getCode());
} else {
if (target == null) {
logger.write(SVCM_00017, new Object[] { invoke });
return null;
}
clazz = target.getClass();
}
final Collection argCollection = invoke.getArguments();
Class[] argTypes = null;
if (argCollection.size() == 0) {
} else {
argTypes = new Class[argCollection.size()];
argVals = new Object[argCollection.size()];
final Iterator args = argCollection.iterator();
int i = 0;
while (args.hasNext()) {
final ArgumentMetaData argData = (ArgumentMetaData) args.next();
argVals[i] = getValueOfArgument(argData);
if (argData.getType() != null) {
argTypes[i] = Utility.convertStringToClass(argData.getType());
} else if (argVals[i] != null) {
argTypes[i] = argVals[i].getClass();
} else {
argTypes[i] = String.class;
}
i++;
}
}
if (!isAccessableClass(clazz)) {
final Class[] interfaces = clazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (isAccessableClass(interfaces[i])) {
try {
method = interfaces[i].getMethod(methodName, argTypes);
clazz = interfaces[i];
break;
} catch (NoSuchMethodException e) {
}
}
}
}
if (method == null) {
method = clazz.getMethod(methodName, argTypes);
}
} catch (Exception e) {
if (objData == null) {
logger.write(SVCM_00019, new Object[] { clazz.getName(), invoke }, e);
} else if (objData instanceof ServiceMetaData) {
ServiceMetaData serviceData = (ServiceMetaData) objData;
logger.write(SVCM_00020, new Object[] { serviceData.getManager().getName(), serviceData.getName(), invoke }, e);
} else {
logger.write(SVCM_00021, new Object[] { objData.getCode(), invoke }, e);
}
throw e;
}
try {
return method.invoke(target, argVals);
} catch (Exception e) {
if (objData == null) {
logger.write(SVCM_00018, new Object[] { clazz.getName(), method }, e);
} else if (objData instanceof ServiceMetaData) {
ServiceMetaData serviceData = (ServiceMetaData) objData;
logger.write(SVCM_00022, new Object[] { serviceData.getManager().getName(), serviceData.getName(), method }, e);
} else {
logger.write(SVCM_00023, new Object[] { objData.getCode(), method }, e);
}
throw e;
}
}
use of jp.ossc.nimbus.service.log.Logger in project nimbus by nimbus-org.
the class LoggerWrapper method stop.
public synchronized void stop() {
if (currentLog == defaultLog) {
currentLog = null;
if (defaultLog instanceof Service) {
((Service) defaultLog).stop();
}
} else {
Logger oldLog = currentLog;
currentLog = defaultLog;
if (oldLog instanceof Service) {
((Service) oldLog).stop();
((Service) oldLog).destroy();
}
currentLog = null;
if (defaultLog instanceof Service) {
((Service) defaultLog).stop();
}
}
}
Aggregations