public static ResourceInfo getResourceInfo(BindableResource resource){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resource.getJndiName(), application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new ResourceInfo(resource.getJndiName(), application.getName(), module.getName()); }else{ return new ResourceInfo(resource.getJndiName()); } }
public static ResourceInfo getResourceInfo(BindableResource resource){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resource.getJndiName(), application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new ResourceInfo(resource.getJndiName(), application.getName(), module.getName()); }else{ return new ResourceInfo(resource.getJndiName()); } }
@Override public boolean isValid(final BindableResource resource, final ConstraintValidatorContext constraintValidatorContext) { Resources resources = (Resources) resource.getParent(); if(resources.getParent() instanceof Domain || // for app-scoped/module-scoped resources, <resources> configuration will not // not be fully available until deployment is complete. (!(resources.getParent() instanceof Domain) && resources.getResources().size() > 0)){ if(resource instanceof ConnectorResource){ ConnectorResource cr = (ConnectorResource)resource; return resources.getResourceByName(ConnectorConnectionPool.class, cr.getPoolName()) != null; }else if(resource instanceof JdbcResource){ JdbcResource jr = (JdbcResource)resource; return resources.getResourceByName(JdbcConnectionPool.class, jr.getPoolName()) != null; } } return true; } }