public static String getApplicationName(Resource resource){ String applicationName = null; if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); applicationName = application.getName(); } return applicationName; }
public static ResourceInfo getGenericResourceInfo(Resource resource, String resourceName){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resourceName, 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(resourceName, application.getName(), module.getName()); }else{ return new ResourceInfo(resourceName); } }
public static ResourceInfo getGenericResourceInfo(Resource resource, String resourceName){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resourceName, 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(resourceName, application.getName(), module.getName()); }else{ return new ResourceInfo(resourceName); } }
@Override public boolean isValid(final Resource resource, final ConstraintValidatorContext constraintValidatorContext) { if(resource.getParent().getParent() instanceof Domain){ if(resource instanceof BindableResource){ if(((BindableResource)resource).getJndiName().contains(":")){ return false; } }else if(resource instanceof ResourcePool){ if(((ResourcePool)resource).getName().contains(":")){ return false; } } } return true; } }
@Override public boolean isValid(final Resource resource, final ConstraintValidatorContext constraintValidatorContext) { if(resource.getParent().getParent() instanceof Domain){ if(resource instanceof BindableResource){ if(((BindableResource)resource).getJndiName().contains(":")){ return false; } }else if(resource instanceof ResourcePool){ if(((ResourcePool)resource).getName().contains(":")){ return false; } } } return true; } }
@Override public boolean isValid(final Resource resource, final ConstraintValidatorContext constraintValidatorContext) { if (domain != null) { if (resource.getParent().getParent() instanceof Domain) { for (Resource res : domain.getResources().getResources()) { if (resource.getIdentity().equals(res.getIdentity())) { Class[] resourceInterfaces = resource.getClass().getInterfaces(); Class[] resInterfaces = res.getClass().getInterfaces(); for (Class resourceClass : resourceInterfaces) { for (Class resClass : resInterfaces) { if (resClass.getName().equals(resourceClass.getName())) { return true; } } } return false; } } } } return true; } }
Object parentObject = resource.getParent().getParent(); if(parentObject instanceof Application){ applicationName = ((Application)parentObject).getName();