private void checkDependsOn(EjbDescriptor ejb) {
if( ejb instanceof EjbSessionDescriptor ) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejb;
if( sessionDesc.hasDependsOn()) {
if( !sessionDesc.isSingleton() ) {
throw new RuntimeException("Illegal usage of DependsOn for EJB " +
ejb.getName() + ". DependsOn is only supported for Singleton beans");
}
String[] dependsOn = sessionDesc.getDependsOn();
for(String next : dependsOn) {
// TODO support new EJB 3.1 syntax
boolean fullyQualified = next.contains("#");
Application app = sessionDesc.getEjbBundleDescriptor().getApplication();
if( fullyQualified ) {
int indexOfHash = next.indexOf("#");
String ejbName = next.substring(indexOfHash+1);
String relativeJarPath = next.substring(0, indexOfHash);
BundleDescriptor bundle = app.getRelativeBundle(sessionDesc.getEjbBundleDescriptor(),
relativeJarPath);
if( bundle == null ) {
throw new IllegalStateException("Invalid @DependOn value = " + next +
" for Singleton " + sessionDesc.getName());
}
EjbBundleDescriptorImpl ejbBundle = (bundle.getModuleType() != null && bundle.getModuleType().equals(DOLUtils.warType())) ?
bundle.getExtensionsDescriptors(EjbBundleDescriptorImpl.class).iterator().next()
: (EjbBundleDescriptorImpl) bundle;