MCKernelAbstractionpublic class MCKernelAbstraction extends MCClientKernelAbstraction implements KernelAbstractionAbstraction layer for installing beans into the micro container. |
Fields Summary |
---|
private static final Logger | log | private MBeanServer | server |
Methods Summary |
---|
private boolean | hasOperation(javax.management.MBeanInfo info, java.lang.String operationName)
for(MBeanOperationInfo operationInfo : info.getOperations())
{
if(operationInfo.getName().equals(operationName) == false)
continue;
// void return type
if(operationInfo.getReturnType().equals("void") == false)
continue;
// no parameters
if(operationInfo.getSignature().length != 0)
continue;
return true;
}
return false;
| public void | install(java.lang.String name, DependencyPolicy dependencies, java.lang.Object service)
AbstractBeanMetaData bean = new AbstractBeanMetaData(name, service.getClass().getName());
bean.setConstructor(new AlreadyInstantiated(service));
MCDependencyPolicy policy = (MCDependencyPolicy) dependencies;
bean.setDemands(policy.getDependencies());
log.info("installing bean: " + name + " with dependencies:");
for (Object obj : policy.getDependencies())
{
String msg;
if (obj instanceof AbstractDemandMetaData)
{
msg = ((AbstractDemandMetaData)obj).getDemand().toString();
}
else
{
msg = obj.toString();
}
log.info("\t" + msg);
}
try
{
try
{
kernel.getController().uninstall(name);
}
catch (IllegalStateException e){}
kernel.getController().install(bean);
}
catch (Throwable throwable)
{
throw new RuntimeException(throwable);
}
| public void | installMBean(javax.management.ObjectName on, DependencyPolicy dependencies, java.lang.Object service)
try
{
server.registerMBean(service, on);
install(on.getCanonicalName(), dependencies, service);
// EJBTHREE-606: emulate the ServiceController calls
MBeanInfo info = server.getMBeanInfo(on); // redundant call for speed
invokeOptionalMethod(on, info, "create");
invokeOptionalMethod(on, info, "start");
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
| public java.lang.Object | invoke(javax.management.ObjectName objectName, java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)
String name = objectName.getCanonicalName();
KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
if (entry != null)
{
Object target = entry.getTarget();
if (target instanceof RARDeployment)
{
RARDeployment deployment = (RARDeployment)target;
return deployment.invoke(operationName, params, signature);
}
else
{
Class[] types = new Class[signature.length];
for (int i = 0; i < signature.length; ++i)
{
types[i] = Thread.currentThread().getContextClassLoader().loadClass(signature[i]);
}
Method method = target.getClass().getMethod(operationName, types);
return method.invoke(target, params);
}
}
return null;
| private void | invokeOptionalMethod(javax.management.ObjectName on, javax.management.MBeanInfo info, java.lang.String operationName)
Object params[] = { };
String signature[] = { };
if(hasOperation(info, operationName))
server.invoke(on, operationName, params, signature);
| public void | setMbeanServer(javax.management.MBeanServer server)
this.server = server;
| public void | uninstall(java.lang.String name)
try
{
log.info("uninstalling bean: " + name);
kernel.getController().uninstall(name);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
| public void | uninstallMBean(javax.management.ObjectName on)
try
{
// EJBTHREE-606: emulate the ServiceController calls
MBeanInfo info = server.getMBeanInfo(on); // redundant call for speed
invokeOptionalMethod(on, info, "stop");
invokeOptionalMethod(on, info, "destroy");
server.unregisterMBean(on);
kernel.getController().uninstall(on.toString());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
|
|