private static Map<String, QName> findProvidedServices(final IdentitySchemaNode moduleIdentity, final Module currentModule, final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext) { Map<String, QName> result = new HashMap<>(); for (UnknownSchemaNode unknownNode : moduleIdentity.getUnknownSchemaNodes()) { if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME.equals(unknownNode.getNodeType())) { String prefixAndIdentityLocalName = unknownNode.getNodeParameter(); ServiceInterfaceEntry sie = findSIE(prefixAndIdentityLocalName, currentModule, qNamesToSIEs, schemaContext); result.put(sie.getFullyQualifiedName(), sie.getQName()); } } return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Dependency that = (Dependency) o; if (mandatory != that.mandatory) { return false; } if (!sie.equals(that.sie)) { return false; } return true; }
public static GeneralInterfaceTemplate serviceInterfaceFromSie( final ServiceInterfaceEntry sie) { List<String> extendedInterfaces = Lists .newArrayList(AbstractServiceInterface.class.getCanonicalName()); if (sie.getBase().isPresent()) { extendedInterfaces.add(sie.getBase().get().getFullyQualifiedName()); } // FIXME header GeneralInterfaceTemplate sieTemplate = new GeneralInterfaceTemplate( getHeaderFromEntry(sie), sie.getPackageName(), sie.getTypeName(), extendedInterfaces, Lists.<MethodDeclaration> newArrayList()); sieTemplate.setJavadoc(sie.getNullableDescription()); if (sie.getNullableDescription() != null) { sieTemplate.getAnnotations().add( Annotation.createDescriptionAnnotation(sie .getNullableDescription())); } sieTemplate.getAnnotations().addAll(Annotation.createSieAnnotations(sie)); return sieTemplate; }
public File writeSie(final ServiceInterfaceEntry sie, final File outputBaseDir) { try { GeneralInterfaceTemplate generalInterfaceTemplate = TemplateFactory.serviceInterfaceFromSie(sie); GeneratedObject go = new GenericGeneratedObjectFactory().toGeneratedObject(generalInterfaceTemplate, COPYRIGHT); return go.persist(outputBaseDir).get().getValue(); } catch (Exception e) { String message = "An error occurred during Service interface generating, sie:" + sie.getTypeName() + ", " + sie.getFullyQualifiedName(); LOG.error(message, e); throw new RuntimeException(message, e); } }
public static Collection<Annotation> createSieAnnotations(ServiceInterfaceEntry sie){ String exportedClassName = sie.getExportedOsgiClassName(); Preconditions.checkNotNull(sie.getQName(), "Cannot create annotation from null qname"); Preconditions.checkNotNull(exportedClassName, "Cannot create annotation from null exportedClassName"); List<Annotation> result = new ArrayList<>(); { List<Parameter> params = Lists.newArrayList(new Parameter("value", q(sie.getQName().toString()))); params.add(new Parameter("osgiRegistrationType", exportedClassName + ".class")); params.add(new Parameter("registerToOsgi", Boolean.toString(sie.isRegisterToOsgi()))); params.add(new Parameter("namespace", q(sie.getQName().getNamespace().toString()))); params.add(new Parameter("revision", q(sie.getQName().getFormattedRevision()))); params.add(new Parameter("localName", q(sie.getQName().getLocalName()))); Annotation sieAnnotation = new Annotation(ServiceInterfaceAnnotation.class.getCanonicalName(), params); result.add(sieAnnotation); } { List<Parameter> params = new ArrayList<>(); params.add(new Parameter("namespace", q(sie.getYangModuleQName().getNamespace().toString()))); params.add(new Parameter("revision", q(sie.getYangModuleQName().getFormattedRevision()))); params.add(new Parameter("name", q(sie.getYangModuleQName().getLocalName()))); Annotation moduleQNameAnnotation = new Annotation(ModuleQName.class.getCanonicalName(), params); result.add(moduleQNameAnnotation); } return result; }
.equals(SERVICE_TYPE_Q_NAME)) { created = new ServiceInterfaceEntry(identity, packageName, ModuleUtil.getQName(currentModule)); } else { ServiceInterfaceEntry foundBase = definedSEItracker created = new ServiceInterfaceEntry( Optional.of(foundBase), identity, packageName, ModuleUtil.getQName(currentModule)); created.setYangModuleName(currentModule.getName()); created.setYangModuleLocalname(identity.getQName() .getLocalName()); identitiesToSIs.put(identity, created); resultMap.put(sie.getQName(), sie);
String packageName = packageTranslator.getPackageName(module); Map<QName, ServiceInterfaceEntry> namesToSIEntries = ServiceInterfaceEntry .create(module, packageName, knownSEITracker); for (Entry<QName, ServiceInterfaceEntry> sieEntry : namesToSIEntries.entrySet()) {
public AttributeMappingStrategy<?, ? extends OpenType<?>> prepareStrategy(AttributeIfc attributeIfc) { if(attributeIfc instanceof DependencyAttribute) { namespaceOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString(); } else if (attributeIfc instanceof ListDependenciesAttribute) { namespaceOfDepAttr = ((ListDependenciesAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString(); } return switchAttribute(attributeIfc); }
@Override public String toString() { return "ServiceInterfaceEntry{" + "maybeBaseCache=" + maybeBaseCache + ", qName='" + qName + '\'' + ", fullyQualifiedName='" + getFullyQualifiedName() + '\'' + ", exportedOsgiClassName=" + exportedOsgiClassName + ", nullableDescription='" + nullableDescription + '\'' + '}'; } }
private static String getCachesOfResolvedDependencies(List<ModuleField> moduleFields) { StringBuilder result = new StringBuilder(); for (ModuleField moduleField: moduleFields) { if (moduleField.isDependent()) { String osgi = moduleField.getDependency().getSie().getExportedOsgiClassName(); if (moduleField.isList()) { result .append(format("private java.util.List<%s> %sDependency = new java.util.ArrayList<%s>();", osgi, moduleField.getName(), osgi)) .append(format("protected final java.util.List<%s> get%sDependency(){\n", osgi, moduleField.getAttributeName())) .append(format("return %sDependency;\n", moduleField.getName())) .append("}\n"); } else { result.append(format( "private %s %sDependency;\n"+ "protected final %s get%sDependency(){\n"+ "return %sDependency;\n"+ "}", osgi, moduleField.getName(), osgi, moduleField.getAttributeName(), moduleField.getName())); } } } return result.toString(); }
String packageName = packageTranslator.getPackageName(module); Map<QName, ServiceInterfaceEntry> namesToSIEntries = ServiceInterfaceEntry .create(module, packageName, knownSEITracker);
public static Annotation createRequireIfcAnnotation( ServiceInterfaceEntry sie) { String reqIfc = sie.getFullyQualifiedName() + ".class"; return new Annotation(RequireInterface.class.getCanonicalName(), Lists.newArrayList(new Parameter("value", reqIfc))); }
if (moduleField.isDependent()) { String str; String osgi = moduleField.getDependency().getSie().getExportedOsgiClassName(); if (moduleField.isList()) { str = format(
String packageName = packageTranslator.getPackageName(module); Map<QName, ServiceInterfaceEntry> namesToSIEntries = ServiceInterfaceEntry .create(module, packageName,knownSEITracker);
format("for(javax.management.ObjectName dep : %s) {\n", moduleField.getName()) + format(" dependencyResolver.validateDependency(%s.class, dep, %sJmxAttribute);\n", moduleField.getDependency().getSie().getFullyQualifiedName(), moduleField.getName()) + "}\n"; } else { moduleField.getDependency().getSie().getFullyQualifiedName(), moduleField.getName(), moduleField.getName()); if(moduleField.getDependency().isMandatory() == false) { result += "}\n";