/** * The name of the bundle file. * * @return The name of the bundle file. */ protected String getBundleFileName() { String label = getLabel(); if (label == null) { label = getEnunciate().getConfig().getLabel(); } return label + "-php.zip"; }
/** * Reads the enunciate configuration from the specified file, if any. * * @return The configuration, or null if none is specified. */ protected EnunciateConfiguration loadConfig() throws IOException { EnunciateConfiguration config = new EnunciateConfiguration(); File configFile = getConfigFile(); if (configFile == null) { info("No config file specified, using defaults...."); } else if (!configFile.exists()) { warn("Config file %s doesn't exist, using defaults....", configFile); } else { try { config.load(configFile); } catch (SAXException e) { throw new IOException("Error parsing enunciate configuration file " + configFile + ": " + e.getMessage()); } } return config; }
/** * The list of enabled modules in the configuration. * * @return The list of enabled modules in the configuration. */ public List<DeploymentModule> getEnabledModules() { ArrayList<DeploymentModule> enabledModules = new ArrayList<DeploymentModule>(); for (DeploymentModule module : getAllModules()) { if (!module.isDisabled()) { enabledModules.add(module); } } return enabledModules; }
@Override protected EnunciateConfiguration createEnunciateConfiguration() { EnunciateConfiguration configuration = new EnunciateConfiguration(Arrays.asList((DeploymentModule) new ExportListDeploymentModule())); configuration.setExcludeUnreferencedClasses(false); return configuration; }
for (String ns : config.getNamespacesToPrefixes().keySet()) { String prefix = config.getNamespacesToPrefixes().get(ns); model.getNamespacesToPrefixes().put(ns, prefix); debug("Assigning namespace prefix %s to namespace %s as specified in the config.", prefix, ns); for (String ct : config.getContentTypesToIds().keySet()) { String id = config.getContentTypesToIds().get(ct); model.getContentTypesToIds().put(ct, id); debug("Assigning id '%s' to content type '%s' as specified in the config.", id, ct); if (config.getGeneratedCodeLicenseFile() != null) { File licenseFile = this.enunciate.resolvePath(config.getGeneratedCodeLicenseFile()); try { model.put("generatedCodeLicense", this.enunciate.readFile(licenseFile)); String baseURL = config.getDeploymentProtocol() + "://" + config.getDeploymentHost(); if (config.getDeploymentContext() != null) { baseURL += config.getDeploymentContext(); else if ((config.getLabel() != null) && (!"".equals(config.getLabel()))) { baseURL += ("/" + config.getLabel()); for (DeploymentModule module : config.getAllModules()) { if (module instanceof EnunciateTypeDeclarationListener) { typeDeclarationListeners.add((EnunciateTypeDeclarationListener) module); if (isEndpointInterface || isJAXRSRootResource || isJAXRSSupport) { if (isEndpointInterface) {
for (String ns : config.getNamespacesToPrefixes().keySet()) { String prefix = config.getNamespacesToPrefixes().get(ns); String old = model.getNamespacesToPrefixes().put(ns, prefix); debug("Replaced namespace prefix %s with %s for namespace %s as specified in the config.", old, prefix, ns); for (String ct : config.getContentTypesToIds().keySet()) { String id = config.getContentTypesToIds().get(ct); String old = model.getContentTypesToIds().put(ct, id); debug("Replaced content type '%s' with '%s' for content type '%s' as specified in the config.", old, id, ct); String baseURL = config.getDeploymentProtocol() + "://" + config.getDeploymentHost(); if (config.getDeploymentContext() != null) { baseURL += config.getDeploymentContext(); else if ((config.getLabel() != null) && (!"".equals(config.getLabel()))) { baseURL += ("/" + config.getLabel());
model.put("springDispatcherServletClass", getDispatcherServletClass()); model.put("soapAddressPath", new SoapAddressPathMethod()); model.put("restSubcontext", model.getEnunciateConfig().getDefaultRestSubcontext()); model.put("displayName", model.getEnunciateConfig().getLabel()); if (!globalServiceInterceptors.isEmpty()) { for (GlobalServiceInterceptor interceptor : this.globalServiceInterceptors) { String realmName = "Generic Enunciate Application Realm"; EnunciateConfiguration enunciateConfig = enunciate.getConfig(); if (enunciateConfig.getDescription() != null) { realmName = enunciateConfig.getDescription();
ValidatorChain validator = new ValidatorChain(); EnunciateConfiguration config = this.enunciate.getConfig(); Set<String> disabledRules = new TreeSet<String>(config.getDisabledRules()); if (this.enunciate.isModuleEnabled("rest")) { Validator coreValidator = config.getValidator(); if (coreValidator instanceof ConfigurableRules) { ((ConfigurableRules) coreValidator).disableRules(disabledRules); for (DeploymentModule module : config.getEnabledModules()) { Validator moduleValidator = module.getValidator(); if (moduleValidator != null) { if (!config.isAllowEmptyNamespace()) { validator.addValidator("emptyns", new EmptyNamespaceValidator());
/** * Whether the specified module is enabled. * * @param moduleName The name of the module. * @return Whether the module is enabled. */ public boolean isModuleEnabled(String moduleName) { if (this.config != null) { for (DeploymentModule module : this.config.getEnabledModules()) { if (module.getName().equals(moduleName)) { return true; } } } return false; }
Digester digester = createDigester(); digester.setErrorHandler(this); digester.setValidating(true); for (DeploymentModule module : getAllModules()) { String pattern = String.format("enunciate/modules/%s", module.getName()); digester.addRule(pattern, new PushModuleRule(module));
for (DeploymentModule module : config.getAllModules()) { if (module instanceof EnunciateModelAware) { ((EnunciateModelAware) module).initModel(model); for (DeploymentModule module : config.getEnabledModules()) { debug("Invoking %s step for module %s", Enunciate.Target.GENERATE, module.getName());
/** * Loads the configuration specified by the given config file. * * @param file The file. */ public void load(File file) throws IOException, SAXException { load(new FileInputStream(file)); }
/** * Create an Enunciate configuration. * * @return The enunciate configuration. */ protected EnunciateConfiguration createEnunciateConfiguration() { return new EnunciateConfiguration(); }
protected String getSubcontext(EnunciateConfiguration config) { return config.getDefaultRestSubcontext(); }
ValidatorChain validator = new ValidatorChain(); EnunciateConfiguration config = this.enunciate.getConfig(); validator.addValidator(config.getValidator()); debug("Default validator added to the chain."); for (DeploymentModule module : config.getEnabledModules()) { Validator moduleValidator = module.getValidator(); if (moduleValidator != null) {
/** * Whether the specified module is enabled. * * @param moduleName The name of the module. * @return Whether the module is enabled. */ public boolean isModuleEnabled(String moduleName) { if (this.config != null) { for (DeploymentModule module : this.config.getEnabledModules()) { if (module.getName().equals(moduleName)) { return true; } } } return false; }
Digester digester = createDigester(); digester.setErrorHandler(this); digester.setValidating(false); for (DeploymentModule module : getAllModules()) { String pattern = String.format("enunciate/modules/%s", module.getName()); digester.addRule(pattern, new PushModuleRule(module));
/** * Loads the configuration specified by the given config file. * * @param file The file. */ public void load(File file) throws IOException, SAXException { load(new FileInputStream(file)); }
/** * Package-private constructor for testing purposes. */ EnunciateAnnotationProcessor() throws EnunciateException { this(new Enunciate(new String[0], new EnunciateConfiguration())); }
protected String getRestSubcontext() { String restSubcontext = getEnunciate().getConfig().getDefaultRestSubcontext(); //todo: override default rest subcontext? return restSubcontext; }