/**
* @see org.rioproject.servicebean.ServiceBeanManager#getServiceBeanControl()
*/
public ServiceBeanControl getServiceBeanControl() throws ServiceBeanManagerException {
if(marshalledInstance==null)
throw new ServiceBeanManagerException("Unable to obtain ServiceBeanControl, there is no marshalled proxy instance");
ServiceBeanControl serviceBeanControl;
try {
Object proxy = marshalledInstance.get(false);
if(proxy instanceof Administrable) {
Object adminObject = ((Administrable)proxy).getAdmin();
if(adminObject instanceof ServiceBeanControl) {
serviceBeanControl = (ServiceBeanControl)proxy;
} else {
throw new ServiceBeanManagerException(String.format("Service is not an instanceof %s",
ServiceBeanControl.class.getName()));
}
} else {
throw new ServiceBeanManagerException(String.format("%s is derivable from %s, however, the service proxy does not implement %s",
ServiceBeanControl.class.getName(),
Administrable.class.getName(),
Administrable.class.getName()));
}
} catch (Exception e) {
throw new ServiceBeanManagerException("Unable to obtain ServiceBeanControl", e);
}
return serviceBeanControl;
}