@SuppressWarnings("unchecked") public URLArtifactProcessor<?> getProcessor(Object artifactType) { Collection<URLArtifactProcessor<?>> processors = getProcessors(artifactType); return processors.isEmpty() ? null : processors.iterator().next(); }
@SuppressWarnings("unchecked") @Override public <T> URLArtifactProcessor<T> getProcessor(Class<T> modelType) { loadProcessors(); return (URLArtifactProcessor<T>)super.getProcessor(modelType); }
public void removeArtifactProcessor(URLArtifactProcessor<?> artifactProcessor) { if (artifactProcessor.getArtifactType() != null) { String regex = wildcard2regex(artifactProcessor.getArtifactType()); for (Object key : processorsByArtifactType.keySet()) { if ((key instanceof Pattern) && ((Pattern)key).pattern().equals(regex)) { processorsByArtifactType.remove(key); } } processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType()); } if (artifactProcessor.getModelType() != null) { processorsByModelType.remove(artifactProcessor.getModelType()); } }
/** * Lazily load artifact processors registered in the extension point. */ private synchronized void loadProcessors() { if (loaded) return; // Get the processor service declarations Collection<ServiceDeclaration> processorDeclarations; try { processorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(URLArtifactProcessor.class.getName()); } catch (IOException e) { IllegalStateException ie = new IllegalStateException(e); throw ie; } for (ServiceDeclaration processorDeclaration : processorDeclarations) { Map<String, String> attributes = processorDeclaration.getAttributes(); // Load a URL artifact processor String artifactType = attributes.get("type"); String modelTypeName = attributes.get("model"); // Create a processor wrapper and register it URLArtifactProcessor<?> processor = new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, registry, staxProcessor); addArtifactProcessor(processor); } loaded = true; }
public void removeArtifactProcessor(URLArtifactProcessor<?> artifactProcessor) { if (artifactProcessor.getArtifactType() != null) { String regex = wildcard2regex(artifactProcessor.getArtifactType()); for (Object key : processorsByArtifactType.keySet()) { if ((key instanceof Pattern) && ((Pattern)key).pattern().equals(regex)) { processorsByArtifactType.remove(key); } } processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType()); } if (artifactProcessor.getModelType() != null) { processorsByModelType.remove(artifactProcessor.getModelType()); } }
/** * Lazily load artifact processors registered in the extension point. */ private synchronized void loadProcessors() { if (loaded) return; // Get the processor service declarations Collection<ServiceDeclaration> processorDeclarations; try { processorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(URLArtifactProcessor.class.getName()); } catch (IOException e) { IllegalStateException ie = new IllegalStateException(e); throw ie; } for (ServiceDeclaration processorDeclaration : processorDeclarations) { Map<String, String> attributes = processorDeclaration.getAttributes(); // Load a URL artifact processor String artifactType = attributes.get("type"); String modelTypeName = attributes.get("model"); // Create a processor wrapper and register it URLArtifactProcessor<?> processor = new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, registry, staxProcessor); addArtifactProcessor(processor); } loaded = true; }
@SuppressWarnings("unchecked") @Override public <T> URLArtifactProcessor<T> getProcessor(Class<T> modelType) { loadProcessors(); return (URLArtifactProcessor<T>)super.getProcessor(modelType); }
public void addArtifactProcessor(URLArtifactProcessor<?> artifactProcessor) { if (artifactProcessor.getArtifactType() != null) { Pattern pattern = Pattern.compile(wildcard2regex(artifactProcessor.getArtifactType())); processorsByArtifactType.put(pattern, artifactProcessor); } if (artifactProcessor.getModelType() != null) { processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor); } }
@SuppressWarnings("unchecked") public URLArtifactProcessor<?> getProcessor(Object artifactType) { Collection<URLArtifactProcessor<?>> processors = getProcessors(artifactType); return processors.isEmpty() ? null : processors.iterator().next(); }
public Collection<URLArtifactProcessor<?>> getProcessors(Object artifactType) { loadProcessors(); String uri = (String)artifactType; if (uri.endsWith("/")) { // Ignore directories return Collections.emptyList(); } if (!uri.startsWith("/")) { uri = "/" + uri; } List<URLArtifactProcessor<?>> processors = new ArrayList<URLArtifactProcessor<?>>(); for (Map.Entry<Object, URLArtifactProcessor<?>> e : processorsByArtifactType.entrySet()) { Pattern pattern = (Pattern)e.getKey(); if (pattern.matcher(uri).matches()) { processors.add(e.getValue()); } } return processors; }
public void addArtifactProcessor(URLArtifactProcessor<?> artifactProcessor) { if (artifactProcessor.getArtifactType() != null) { Pattern pattern = Pattern.compile(wildcard2regex(artifactProcessor.getArtifactType())); processorsByArtifactType.put(pattern, artifactProcessor); } if (artifactProcessor.getModelType() != null) { processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor); } }
public Collection<URLArtifactProcessor<?>> getProcessors(Object artifactType) { loadProcessors(); String uri = (String)artifactType; if (uri.endsWith("/")) { // Ignore directories return Collections.emptyList(); } if (!uri.startsWith("/")) { uri = "/" + uri; } List<URLArtifactProcessor<?>> processors = new ArrayList<URLArtifactProcessor<?>>(); for (Map.Entry<Object, URLArtifactProcessor<?>> e : processorsByArtifactType.entrySet()) { Pattern pattern = (Pattern)e.getKey(); if (pattern.matcher(uri).matches()) { processors.add(e.getValue()); } } return processors; }