String specification = imp.getAttribute("specification");
if (specification == null) {
// Malformed import
error("Malformed import: the specification attribute is mandatory");
throw new ConfigurationException("Malformed import : the specification attribute is mandatory");
} else {
String opt = imp.getAttribute("optional");
optional = opt != null && opt.equalsIgnoreCase("true");
String agg = imp.getAttribute("aggregate");
aggregate = agg != null && agg.equalsIgnoreCase("true");
String original = "(&(objectClass=" + specification + ")(!(instance.name=" + getCompositeManager().getInstanceName() + ")))"; // Cannot import yourself
String filter = original;
String givenFilter = imp.getAttribute("filter");
if (givenFilter != null) {
filter = "(&" + filter + givenFilter + ")"; //NOPMD
}
String identitity = imp.getAttribute("id");
String scope = imp.getAttribute("scope");
BundleContext context = getCompositeManager().getGlobalContext(); // Get the default bundle context.
if (scope != null) {
if (scope.equalsIgnoreCase("global")) {
context = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.GLOBAL);
} else if (scope.equalsIgnoreCase("composite")) {
context = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL);
} else if (scope.equalsIgnoreCase("composite+global")) {
context = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL_AND_GLOBAL);
}
}
// Configure instance filter if available
if (confFilter != null && identitity != null && confFilter.get(identitity) != null) {
filter = "(&" + original + (String) confFilter.get(identitity) + ")";
}
Filter fil = null;
if (filter != null) {
try {
fil = getCompositeManager().getGlobalContext().createFilter(filter);
} catch (InvalidSyntaxException e) {
throw new ConfigurationException("A required filter " + filter + " is malformed", e);
}
}
Comparator cmp = DependencyMetadataHelper.getComparator(imp, getCompositeManager().getGlobalContext());
Class spec = DependencyMetadataHelper.loadSpecification(specification, getCompositeManager().getGlobalContext());