diff options
| author | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
| commit | 0a0baee45ebcff44635907d457c4ff6810b09c87 (patch) | |
| tree | 8bfb0f9eddbc23cff88af69be80ab3ce7d47011c /qpid/java/broker-codegen/src | |
| parent | 54aa3d7070da16ce55c28ccad3f7d0871479e461 (diff) | |
| download | qpid-python-0a0baee45ebcff44635907d457c4ff6810b09c87.tar.gz | |
QPID-6481: Move java source tree to top level
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1673693 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-codegen/src')
12 files changed, 0 insertions, 1551 deletions
diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/License.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/License.java deleted file mode 100644 index 15c01246a7..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/License.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server; - -public interface License -{ - String[] LICENSE = { - " Licensed to the Apache Software Foundation (ASF) under one", - " or more contributor license agreements. See the NOTICE file", - " distributed with this work for additional information", - " regarding copyright ownership. The ASF licenses this file", - " to you under the Apache License, Version 2.0 (the", - " \"License\"); you may not use this file except in compliance", - " with the License. You may obtain a copy of the License at", - "", - " http://www.apache.org/licenses/LICENSE-2.0", - "", - " Unless required by applicable law or agreed to in writing,", - " software distributed under the License is distributed on an", - " \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY", - " KIND, either express or implied. See the License for the", - " specific language governing permissions and limitations", - " under the License." - }; -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryGenerator.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryGenerator.java deleted file mode 100644 index 8fd5de76e5..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryGenerator.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.Collections; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Filer; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.PackageElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.TypeMirror; -import javax.tools.Diagnostic; -import javax.tools.JavaFileObject; - -import org.apache.qpid.server.License; - -public class ConfiguredObjectFactoryGenerator extends AbstractProcessor -{ - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.latest(); - } - - @Override - public Set<String> getSupportedAnnotationTypes() - { - return Collections.singleton(ManagedObjectFactoryConstructor.class.getName()); - } - - @Override - public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) - { - - if(roundEnv.processingOver()) - { - - return true; - } - - Filer filer = processingEnv.getFiler(); - - try - { - - for (Element e : roundEnv.getElementsAnnotatedWith(ManagedObjectFactoryConstructor.class)) - { - if(e.getKind() == ElementKind.CONSTRUCTOR) - { - ExecutableElement constructorElement = (ExecutableElement) e; - String factoryName = generateObjectFactory(filer, constructorElement); - } - } - - } - catch (Exception e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error: " + e.getLocalizedMessage()); - } - - return true; - } - - private String generateObjectFactory(final Filer filer, final ExecutableElement constructorElement) - { - TypeElement classElement = (TypeElement) constructorElement.getEnclosingElement(); - String factoryName = classElement.getQualifiedName().toString() + "Factory"; - String factorySimpleName = classElement.getSimpleName().toString() + "Factory"; - String objectSimpleName = classElement.getSimpleName().toString(); - processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Generating factory file for " + classElement.getQualifiedName().toString()); - - PackageElement packageElement = (PackageElement) classElement.getEnclosingElement(); - - try - { - JavaFileObject factoryFile = filer.createSourceFile(factoryName); - PrintWriter pw = new PrintWriter(new OutputStreamWriter(factoryFile.openOutputStream(), "UTF-8")); - pw.println("/*"); - for(String headerLine : License.LICENSE) - { - pw.println(" *" + headerLine); - } - pw.println(" */"); - pw.println(); - pw.print("package "); - pw.print(packageElement.getQualifiedName()); - pw.println(";"); - pw.println(); - - pw.println("import java.util.Map;"); - pw.println(); - pw.println("import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;"); - pw.println("import org.apache.qpid.server.model.ConfiguredObject;"); - pw.println("import org.apache.qpid.server.plugin.PluggableService;"); - pw.println(); - pw.println("@PluggableService"); - pw.println("public final class " + factorySimpleName + " extends AbstractConfiguredObjectTypeFactory<"+ objectSimpleName +">"); - pw.println("{"); - pw.println(" public " + factorySimpleName + "()"); - pw.println(" {"); - pw.println(" super(" + objectSimpleName + ".class);"); - pw.println(" }"); - pw.println(); - pw.println(" @Override"); - pw.println(" protected "+objectSimpleName+" createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)"); - pw.println(" {"); - pw.print(" return new "+objectSimpleName+"(attributes"); - boolean first = true; - for(VariableElement param : constructorElement.getParameters()) - { - if(first) - { - first = false; - } - else - { - TypeMirror erasureType = processingEnv.getTypeUtils().erasure(param.asType()); - pw.print(", getParent("+erasureType.toString()+".class,parents)"); - } - } - pw.println(");"); - pw.println(" }"); - - pw.println("}"); - - pw.close(); - } - catch (IOException e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, - "Failed to write factory file: " - + factoryName - + " - " - + e.getLocalizedMessage()); - } - - return factoryName; - } - -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java deleted file mode 100644 index 9e63e96fb7..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.PackageElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.Elements; -import javax.tools.Diagnostic; -import javax.tools.JavaFileObject; - -import org.apache.qpid.server.License; - -public class ConfiguredObjectRegistrationGenerator extends AbstractProcessor -{ - - public static final String MANAGED_OBJECT_CANONICAL_NAME = "org.apache.qpid.server.model.ManagedObject"; - - private Map<String, Set<String>> _managedObjectClasses = new HashMap<>(); - - private Map<String, String> _typeMap = new HashMap<>(); - private Map<String, String> _categoryMap = new HashMap<>(); - - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.latest(); - } - - @Override - public Set<String> getSupportedAnnotationTypes() - { - return Collections.singleton(MANAGED_OBJECT_CANONICAL_NAME); - } - - @Override - public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) - { - - Elements elementUtils = processingEnv.getElementUtils(); - TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_OBJECT_CANONICAL_NAME); - - - try - { - - for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement)) - { - if (e.getKind().equals(ElementKind.INTERFACE) || e.getKind().equals(ElementKind.CLASS)) - { - PackageElement packageElement = elementUtils.getPackageOf(e); - String packageName = packageElement.getQualifiedName().toString(); - String className = e.getSimpleName().toString(); - AnnotationMirror annotation = getAnnotation(e, annotationElement); - - AnnotationValue registerValue = getAnnotationValue(annotation, "register"); - - if(registerValue == null || (Boolean) registerValue.getValue() ) - { - AnnotationValue typeValue = getAnnotationValue(annotation, "type"); - - if (typeValue != null) - { - _typeMap.put(packageName + "." + className, (String) typeValue.getValue()); - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.NOTE, - "looking for " + packageName + "." + className); - _categoryMap.put(packageName + "." + className, getCategory((TypeElement) e)); - - } - - - Set<String> classNames = _managedObjectClasses.get(packageName); - if (classNames == null) - { - classNames = new HashSet<>(); - _managedObjectClasses.put(packageName, classNames); - } - classNames.add(className); - } - } - } - for (Map.Entry<String, Set<String>> entry : _managedObjectClasses.entrySet()) - { - generateRegistrationFile(entry.getKey(), entry.getValue()); - } - _managedObjectClasses.clear(); - _typeMap.clear(); - _categoryMap.clear(); - } - catch (Exception e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error: " + e.getLocalizedMessage()); - } - - return false; - } - - private AnnotationValue getAnnotationValue(final AnnotationMirror annotation, final String attribute) - { - for(Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation.getElementValues().entrySet()) - { - if(entry.getKey().getSimpleName().toString().equals(attribute)) - { - return entry.getValue(); - } - } - return null; - } - - private AnnotationMirror getAnnotation(final Element e, final TypeElement annotationElement) - { - for(AnnotationMirror a : e.getAnnotationMirrors()) - { - if (a.getAnnotationType().asElement().equals(annotationElement)) - { - return a; - } - } - return null; - } - - private String getCategory(final TypeElement e) - { - Elements elementUtils = processingEnv.getElementUtils(); - TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_OBJECT_CANONICAL_NAME); - String category = null; - List<? extends AnnotationMirror> annotationMirrors = e.getAnnotationMirrors(); - if(annotationMirrors != null) - { - for (AnnotationMirror a : annotationMirrors) - { - if (a.getAnnotationType().asElement().equals(annotationElement)) - { - category = e.getSimpleName().toString().toLowerCase(); - - for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : a.getElementValues() - .entrySet()) - { - if (entry.getKey().getSimpleName().toString().equals("category")) - { - if (!Boolean.TRUE.equals(entry.getValue().getValue())) - { - category = null; - } - - break; - } - } - break; - } - } - } - - if (category == null) - { - for (TypeMirror interfaceMirror : e.getInterfaces()) - { - category = getCategory((TypeElement) processingEnv.getTypeUtils().asElement(interfaceMirror)); - if (category != null) - { - break; - } - } - } - - if (category == null && e.getSuperclass() != null) - { - TypeElement parent = (TypeElement) processingEnv.getTypeUtils().asElement(e.getSuperclass()); - if(parent != null) - { - category = getCategory(parent); - } - } - - return category; - - } - - private void generateRegistrationFile(final String packageName, final Set<String> classNames) - { - final String className = "ConfiguredObjectRegistrationImpl"; - final String qualifiedClassName = packageName + "." + className; - - try - { - - - JavaFileObject factoryFile = processingEnv.getFiler().createSourceFile(qualifiedClassName); - - PrintWriter pw = new PrintWriter(new OutputStreamWriter(factoryFile.openOutputStream(), "UTF-8")); - pw.println("/*"); - for (String headerLine : License.LICENSE) - { - pw.println(" *" + headerLine); - } - pw.println(" */"); - pw.println(); - pw.print("package "); - pw.print(packageName); - pw.println(";"); - pw.println(); - - pw.println("import java.util.Collections;"); - pw.println("import java.util.HashSet;"); - pw.println("import java.util.Set;"); - pw.println(); - pw.println("import org.apache.qpid.server.model.ConfiguredObject;"); - pw.println("import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;"); - pw.println("import org.apache.qpid.server.plugin.PluggableService;"); - pw.println(); - pw.println("@PluggableService"); - pw.println("public class " + className + " implements ConfiguredObjectRegistration"); - pw.println("{"); - pw.println(" private final Set<Class<? extends ConfiguredObject>> _implementations;"); - pw.println(); - pw.println(" public " + className + "()"); - pw.println(" {"); - pw.println(" Set<Class<? extends ConfiguredObject>> implementations = new HashSet<>();"); - for(String implementationName : classNames) - { - String qualifiedImplementationName = packageName + "." + implementationName; - if(_typeMap.get(qualifiedImplementationName) != null && _categoryMap.get(qualifiedImplementationName) != null) - { - pw.println(" if(!Boolean.getBoolean(\"qpid.type.disabled:" - +_categoryMap.get(qualifiedImplementationName) - +"."+_typeMap.get(qualifiedImplementationName)+"\"))"); - pw.println(" {"); - pw.println(" implementations.add("+implementationName+".class);"); - pw.println(" }"); - - } - else - { - pw.println(" implementations.add(" + implementationName + ".class);"); - } - } - pw.println(" _implementations = Collections.unmodifiableSet(implementations);"); - pw.println(" }"); - pw.println(); - pw.println(" public String getType()"); - pw.println(" {"); - pw.println(" return \""+packageName+"\";"); - pw.println(" }"); - pw.println(); - pw.println(" public Set<Class<? extends ConfiguredObject>> getConfiguredObjectClasses()"); - pw.println(" {"); - pw.println(" return _implementations;"); - pw.println(" }"); - pw.println(); - - - pw.println("}"); - - pw.close(); - } - catch (IOException e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, - "Failed to write file: " - + qualifiedClassName - + " - " - + e.getLocalizedMessage() - ); - } - } - -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ManagedObjectFactoryConstructor.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ManagedObjectFactoryConstructor.java deleted file mode 100644 index 21193b3a37..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ManagedObjectFactoryConstructor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.CONSTRUCTOR) -public @interface ManagedObjectFactoryConstructor -{ -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/SystemConfigFactoryConstructor.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/SystemConfigFactoryConstructor.java deleted file mode 100644 index 38551c8cac..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/SystemConfigFactoryConstructor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.CONSTRUCTOR) -public @interface SystemConfigFactoryConstructor -{ -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/SystemConfigFactoryGenerator.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/SystemConfigFactoryGenerator.java deleted file mode 100644 index 52c1276d49..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/SystemConfigFactoryGenerator.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.Collections; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Filer; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.PackageElement; -import javax.lang.model.element.TypeElement; -import javax.tools.Diagnostic; -import javax.tools.JavaFileObject; - -import org.apache.qpid.server.License; - -public class SystemConfigFactoryGenerator extends AbstractProcessor -{ - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.latest(); - } - - @Override - public Set<String> getSupportedAnnotationTypes() - { - return Collections.singleton(SystemConfigFactoryConstructor.class.getName()); - } - - @Override - public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) - { - - if(roundEnv.processingOver()) - { - - return true; - } - - Filer filer = processingEnv.getFiler(); - - try - { - - for (Element e : roundEnv.getElementsAnnotatedWith(SystemConfigFactoryConstructor.class)) - { - if(e.getKind() == ElementKind.CONSTRUCTOR) - { - ExecutableElement constructorElement = (ExecutableElement) e; - String factoryName = generateObjectFactory(filer, constructorElement); - } - } - - } - catch (Exception e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error: " + e.getLocalizedMessage()); - } - - return true; - } - - private String generateObjectFactory(final Filer filer, final ExecutableElement constructorElement) - { - TypeElement classElement = (TypeElement) constructorElement.getEnclosingElement(); - String factoryName = classElement.getQualifiedName().toString() + "Factory"; - String factorySimpleName = classElement.getSimpleName().toString() + "Factory"; - String objectSimpleName = classElement.getSimpleName().toString(); - processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Generating factory file for " + classElement.getQualifiedName().toString()); - - PackageElement packageElement = (PackageElement) classElement.getEnclosingElement(); - - try - { - JavaFileObject factoryFile = filer.createSourceFile(factoryName); - PrintWriter pw = new PrintWriter(new OutputStreamWriter(factoryFile.openOutputStream(), "UTF-8")); - pw.println("/*"); - for(String headerLine : License.LICENSE) - { - pw.println(" *" + headerLine); - } - pw.println(" */"); - pw.println(); - pw.print("package "); - pw.print(packageElement.getQualifiedName()); - pw.println(";"); - pw.println(); - - pw.println("import java.util.Map;"); - pw.println(); - pw.println("import org.apache.qpid.server.configuration.updater.TaskExecutor;"); - pw.println("import org.apache.qpid.server.logging.EventLogger;"); - pw.println("import org.apache.qpid.server.logging.LogRecorder;"); - pw.println("import org.apache.qpid.server.model.BrokerShutdownProvider;"); - pw.println("import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;"); - pw.println("import org.apache.qpid.server.model.SystemConfig;"); - pw.println("import org.apache.qpid.server.plugin.PluggableService;"); - pw.println("import org.apache.qpid.server.plugin.SystemConfigFactory;"); - pw.println(); - pw.println("@PluggableService"); - pw.println("public final class " + factorySimpleName + " implements SystemConfigFactory<"+ objectSimpleName +">"); - pw.println("{"); - pw.println(" public " + factorySimpleName + "()"); - pw.println(" {"); - pw.println(" }"); - pw.println(); - pw.println(" @Override"); - pw.println(" public final String getType()"); - pw.println(" {"); - pw.println(" return ConfiguredObjectTypeRegistry.getType(" + objectSimpleName + ".class);"); - pw.println(" }"); - pw.println(); - pw.println(" @Override"); - pw.println(" public "+objectSimpleName+" newInstance(final TaskExecutor taskExecutor,"); - pw.println(" final EventLogger eventLogger,"); - pw.println(" final LogRecorder logRecorder,"); - pw.println(" final Map<String,Object> attributes,"); - pw.println(" final BrokerShutdownProvider brokerShutdownProvider)"); - pw.println(" {"); - pw.println(" return new "+objectSimpleName+"(taskExecutor, eventLogger, logRecorder, attributes, brokerShutdownProvider);"); - pw.println(" }"); - pw.println("}"); - - pw.close(); - } - catch (IOException e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, - "Failed to write factory file: " - + factoryName - + " - " - + e.getLocalizedMessage()); - } - - return factoryName; - } - -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/AttributeAnnotationValidator.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/AttributeAnnotationValidator.java deleted file mode 100644 index c09a2b4f72..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/AttributeAnnotationValidator.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.validation; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; -import javax.tools.Diagnostic; - - -@SupportedAnnotationTypes({AttributeAnnotationValidator.MANAGED_ATTRIBUTE_CLASS_NAME, - AttributeAnnotationValidator.DERIVED_ATTRIBUTE_CLASS_NAME, - AttributeAnnotationValidator.MANAGED_STATISTIC_CLASS_NAME}) -public class AttributeAnnotationValidator extends AbstractProcessor -{ - - public static final String MANAGED_ATTRIBUTE_CLASS_NAME = "org.apache.qpid.server.model.ManagedAttribute"; - public static final String DERIVED_ATTRIBUTE_CLASS_NAME = "org.apache.qpid.server.model.DerivedAttribute"; - - public static final String MANAGED_STATISTIC_CLASS_NAME = "org.apache.qpid.server.model.ManagedStatistic"; - - - - private static final Set<TypeKind> VALID_PRIMITIVE_TYPES = new HashSet<>(Arrays.asList(TypeKind.BOOLEAN, - TypeKind.BYTE, - TypeKind.CHAR, - TypeKind.DOUBLE, - TypeKind.FLOAT, - TypeKind.INT, - TypeKind.LONG, - TypeKind.SHORT)); - - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.latest(); - } - - @Override - public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) - { - - processAttributes(roundEnv, MANAGED_ATTRIBUTE_CLASS_NAME); - processAttributes(roundEnv, DERIVED_ATTRIBUTE_CLASS_NAME); - - processStatistics(roundEnv, MANAGED_STATISTIC_CLASS_NAME); - - return false; - } - - public void processAttributes(final RoundEnvironment roundEnv, - String elementName) - { - - Elements elementUtils = processingEnv.getElementUtils(); - TypeElement annotationElement = elementUtils.getTypeElement(elementName); - - for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement)) - { - checkAnnotationIsOnMethodInInterface(annotationElement, e); - - ExecutableElement methodElement = (ExecutableElement) e; - - checkInterfaceExtendsConfiguredObject(annotationElement, methodElement); - checkMethodTakesNoArgs(annotationElement, methodElement); - checkMethodName(annotationElement, methodElement); - checkMethodReturnType(annotationElement, methodElement); - - checkTypeAgreesWithName(annotationElement, methodElement); - } - } - - public void processStatistics(final RoundEnvironment roundEnv, - String elementName) - { - - Elements elementUtils = processingEnv.getElementUtils(); - TypeElement annotationElement = elementUtils.getTypeElement(elementName); - - for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement)) - { - checkAnnotationIsOnMethodInInterface(annotationElement, e); - - ExecutableElement methodElement = (ExecutableElement) e; - - checkInterfaceExtendsConfiguredObject(annotationElement, methodElement); - checkMethodTakesNoArgs(annotationElement, methodElement); - checkMethodName(annotationElement, methodElement); - checkTypeAgreesWithName(annotationElement, methodElement); - checkMethodReturnTypeIsNumber(annotationElement, methodElement); - - } - } - - private void checkMethodReturnTypeIsNumber(final TypeElement annotationElement, - final ExecutableElement methodElement) - { - Types typeUtils = processingEnv.getTypeUtils(); - Elements elementUtils = processingEnv.getElementUtils(); - - TypeMirror numberType = elementUtils.getTypeElement("java.lang.Number").asType(); - if(!typeUtils.isAssignable(methodElement.getReturnType(),numberType)) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " return type does not extend Number: " - + methodElement.getReturnType().toString(), - methodElement - ); - } - } - - public void checkTypeAgreesWithName(final TypeElement annotationElement, final ExecutableElement methodElement) - { - Types typeUtils = processingEnv.getTypeUtils(); - - String methodName = methodElement.getSimpleName().toString(); - - if((methodName.startsWith("is") || methodName.startsWith("has")) - && !(methodElement.getReturnType().getKind() == TypeKind.BOOLEAN - || typeUtils.isSameType(typeUtils.boxedClass(typeUtils.getPrimitiveType(TypeKind.BOOLEAN)).asType(), methodElement.getReturnType()))) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " return type is not boolean or Boolean: " - + methodElement.getReturnType().toString(), - methodElement - ); - } - } - - public void checkMethodReturnType(final TypeElement annotationElement, final ExecutableElement methodElement) - { - if (!isValidType(methodElement.getReturnType())) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " cannot be applied to methods with return type " - + methodElement.getReturnType().toString(), - methodElement - ); - } - } - - public void checkMethodName(final TypeElement annotationElement, final ExecutableElement methodElement) - { - String methodName = methodElement.getSimpleName().toString(); - - if (methodName.length() < 3 - || (methodName.length() < 4 && !methodName.startsWith("is")) - || !(methodName.startsWith("is") || methodName.startsWith("get") || methodName.startsWith("has"))) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " can only be applied to methods which of the form getXXX(), isXXX() or hasXXX()", - methodElement - ); - } - } - - public void checkMethodTakesNoArgs(final TypeElement annotationElement, final ExecutableElement methodElement) - { - if (!methodElement.getParameters().isEmpty()) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " can only be applied to methods which take no parameters", - methodElement - ); - } - } - - public void checkInterfaceExtendsConfiguredObject(final TypeElement annotationElement, final Element e) - { - Types typeUtils = processingEnv.getTypeUtils(); - TypeMirror configuredObjectType = getErasure("org.apache.qpid.server.model.ConfiguredObject"); - TypeElement parent = (TypeElement) e.getEnclosingElement(); - - - if (!typeUtils.isAssignable(typeUtils.erasure(parent.asType()), configuredObjectType)) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " can only be applied to methods within an interface which extends " - + configuredObjectType.toString() - + " which does not apply to " - + parent.asType().toString(), - e); - } - } - - public void checkAnnotationIsOnMethodInInterface(final TypeElement annotationElement, final Element e) - { - if (e.getKind() != ElementKind.METHOD || e.getEnclosingElement().getKind() != ElementKind.INTERFACE) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " can only be applied to methods within an interface", - e - ); - } - } - - private boolean isValidType(final TypeMirror type) - { - Types typeUtils = processingEnv.getTypeUtils(); - Elements elementUtils = processingEnv.getElementUtils(); - Element typeElement = typeUtils.asElement(type); - - if (VALID_PRIMITIVE_TYPES.contains(type.getKind())) - { - return true; - } - for(TypeKind primitive : VALID_PRIMITIVE_TYPES) - { - if(typeUtils.isSameType(type, typeUtils.boxedClass(typeUtils.getPrimitiveType(primitive)).asType())) - { - return true; - } - } - if(typeElement.getKind()==ElementKind.ENUM) - { - return true; - } - - String className = "org.apache.qpid.server.model.ConfiguredObject"; - TypeMirror configuredObjectType = getErasure(className); - - if(typeUtils.isAssignable(typeUtils.erasure(type), configuredObjectType)) - { - return true; - } - - - if(typeUtils.isSameType(type,elementUtils.getTypeElement("java.lang.Object").asType())) - { - return true; - } - - - if(typeUtils.isSameType(type, elementUtils.getTypeElement("java.lang.String").asType())) - { - return true; - } - - - if(typeUtils.isSameType(type,elementUtils.getTypeElement("java.util.UUID").asType())) - { - return true; - } - - TypeMirror erasedType = typeUtils.erasure(type); - if(typeUtils.isSameType(erasedType, getErasure("java.util.List")) - || typeUtils.isSameType(erasedType, getErasure("java.util.Set")) - || typeUtils.isSameType(erasedType, getErasure("java.util.Collection"))) - { - - - for(TypeMirror paramType : ((DeclaredType)type).getTypeArguments()) - { - - if(!isValidType(paramType)) - { - return false; - } - } - return true; - } - - if(typeUtils.isSameType(erasedType, getErasure("java.util.Map"))) - { - List<? extends TypeMirror> args = ((DeclaredType) type).getTypeArguments(); - if (args.size() != 2) - { - throw new IllegalArgumentException("Map types " + type + " must have exactly two type arguments"); - } - return isValidType(args.get(0)) && (isValidType(args.get(1)) || typeUtils.isSameType(args.get(1), getErasure("java.lang.Object"))); - } - - - return false; - } - - private TypeMirror getErasure(final String className) - { - final Types typeUtils = processingEnv.getTypeUtils(); - final Elements elementUtils = processingEnv.getElementUtils(); - return typeUtils.erasure(elementUtils.getTypeElement(className).asType()); - } - -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/AttributeFieldValidation.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/AttributeFieldValidation.java deleted file mode 100644 index 58b7191ba7..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/AttributeFieldValidation.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.validation; - -import java.util.Map; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; -import javax.tools.Diagnostic; - -@SupportedAnnotationTypes(AttributeFieldValidation.MANAGED_ATTRIBUTE_FIELD_CLASS_NAME) -public class AttributeFieldValidation extends AbstractProcessor -{ - public static final String MANAGED_ATTRIBUTE_FIELD_CLASS_NAME = "org.apache.qpid.server.model.ManagedAttributeField"; - - - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.latest(); - } - - @Override - public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) - { - Elements elementUtils = processingEnv.getElementUtils(); - Types typeUtils = processingEnv.getTypeUtils(); - - TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_ATTRIBUTE_FIELD_CLASS_NAME); - for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement)) - { - for(AnnotationMirror am : e.getAnnotationMirrors()) - { - if(typeUtils.isSameType(am.getAnnotationType(), annotationElement.asType())) - { - for(Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : am.getElementValues().entrySet()) - { - String elementName = entry.getKey().getSimpleName().toString(); - if(elementName.equals("beforeSet") || elementName.equals("afterSet")) - { - String methodName = entry.getValue().getValue().toString(); - if(!"".equals(methodName)) - { - TypeElement parent = (TypeElement) e.getEnclosingElement(); - if(!containsMethod(parent, methodName)) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, - "Could not find method '" - + methodName - + "' which is defined as the " - + elementName - + " action", e); - - } - } - } - } - } - } - } - return false; - } - - private boolean containsMethod(final TypeElement parent, final String methodName) - { - for(Element element : parent.getEnclosedElements()) - { - if(element.getKind().equals(ElementKind.METHOD) - && element.getSimpleName().toString().equals(methodName) - && ((ExecutableElement)element).getParameters().isEmpty()) - { - return true; - } - } - return false; - } -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java deleted file mode 100644 index b38866147b..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/validation/ManagedAnnotationValidator.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.model.validation; - -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; -import javax.tools.Diagnostic; - -@SupportedAnnotationTypes(ManagedAnnotationValidator.MANAGED_ANNOTATION_CLASS_NAME) -public class ManagedAnnotationValidator extends AbstractProcessor -{ - public static final String MANAGED_ANNOTATION_CLASS_NAME = "org.apache.qpid.server.model.ManagedAnnotation"; - - - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.latest(); - } - - - @Override - public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) - { - Elements elementUtils = processingEnv.getElementUtils(); - Types typeUtils = processingEnv.getTypeUtils(); - - TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_ANNOTATION_CLASS_NAME); - - String className = "org.apache.qpid.server.model.ManagedInterface"; - TypeMirror configuredObjectType = getErasure(className); - - for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement)) - { - if (e.getKind() != ElementKind.INTERFACE) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " can only be applied to an interface", - e - ); - } - - - if(!typeUtils.isAssignable(typeUtils.erasure(e.asType()), configuredObjectType)) - { - - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "@" - + annotationElement.getSimpleName() - + " can only be applied to an interface which extends " + className, - e - ); - } - } - - return false; - } - - - private TypeMirror getErasure(final String className) - { - final Types typeUtils = processingEnv.getTypeUtils(); - final Elements elementUtils = processingEnv.getElementUtils(); - return typeUtils.erasure(elementUtils.getTypeElement(className).asType()); - } -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/plugin/PluggableProcessor.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/plugin/PluggableProcessor.java deleted file mode 100644 index ba55f6cf20..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/plugin/PluggableProcessor.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.plugin; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Filer; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.NoType; -import javax.lang.model.type.TypeMirror; -import javax.tools.Diagnostic; -import javax.tools.FileObject; -import javax.tools.StandardLocation; - -import org.apache.qpid.server.License; - -public class PluggableProcessor extends AbstractProcessor -{ - private Map<String, Set<String>> factoryImplementations = new HashMap<>(); - - - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.latest(); - } - - @Override - public Set<String> getSupportedAnnotationTypes() - { - return Collections.singleton(PluggableService.class.getName()); - } - - @Override - public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) - { - if(roundEnv.processingOver()) - { - generateServiceFiles(processingEnv.getFiler()); - - return true; - } - try - { - - for (Element e : roundEnv.getElementsAnnotatedWith(PluggableService.class)) - { - - if (e.getKind() == ElementKind.CLASS) - { - TypeElement classElement = (TypeElement) e; - Set<String> pluggableTypes = getPluggableTypes(classElement); - for(String pluggableType : pluggableTypes) - { - Set<String> existingFactories = factoryImplementations.get(pluggableType); - if(existingFactories == null) - { - existingFactories = new HashSet<>(); - factoryImplementations.put(pluggableType, existingFactories); - } - existingFactories.add(classElement.getQualifiedName().toString()); - } - } - } - - } - catch (Exception e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error: " + e.getLocalizedMessage()); - } - - return true; - } - - private Set<String> getPluggableTypes(final TypeElement classElement) - { - - final Set<String> types = new HashSet<>(); - - List<? extends TypeMirror> interfaces = classElement.getInterfaces(); - for(TypeMirror typeMirror : interfaces) - { - TypeElement interfaceElt = (TypeElement) processingEnv.getTypeUtils().asElement(typeMirror); - if(interfaceElt.getQualifiedName().toString().equals("org.apache.qpid.server.plugin.Pluggable")) - { - types.add(classElement.getQualifiedName().toString()); - } - else - { - types.addAll(getPluggableTypes(interfaceElt)); - } - - } - TypeMirror superClass = classElement.getSuperclass(); - if(!(superClass instanceof NoType)) - { - types.addAll(getPluggableTypes((TypeElement) processingEnv.getTypeUtils().asElement(superClass))); - } - - return types; - } - - private void generateServiceFiles(Filer filer) - { - for(String serviceName : factoryImplementations.keySet()) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.NOTE, "Generating service file for " + serviceName); - - String relativeName = "META-INF/services/" + serviceName; - loadExistingServicesFile(filer, serviceName); - try - { - FileObject serviceFile = filer.createResource(StandardLocation.CLASS_OUTPUT, "", relativeName); - PrintWriter pw = new PrintWriter(new OutputStreamWriter(serviceFile.openOutputStream(), "UTF-8")); - - for (String headerLine : License.LICENSE) - { - pw.println("#" + headerLine); - } - pw.println("#"); - pw.println("# Note: Parts of this file are auto-generated from annotations."); - pw.println("#"); - for (String implementation : factoryImplementations.get(serviceName)) - { - pw.println(implementation); - } - - pw.close(); - } - catch (IOException e) - { - processingEnv.getMessager() - .printMessage(Diagnostic.Kind.ERROR, - "Failed to write services file: " - + relativeName - + " - " - + e.getLocalizedMessage() - ); - } - } - } - - private String loadExistingServicesFile(final Filer filer, String serviceName) - { - String relativeName = "META-INF/services/" + serviceName; - try - { - - FileObject existingFile = filer.getResource(StandardLocation.CLASS_OUTPUT, "", relativeName); - BufferedReader r = new BufferedReader(new InputStreamReader(existingFile.openInputStream(), "UTF-8")); - String line; - while((line=r.readLine())!=null) - { - if(!line.matches(" *#")) - { - factoryImplementations.get(serviceName).add(line); - } - } - r.close(); - } - catch (FileNotFoundException e) - { - // no existing file (ignore) - } - catch (IOException e) - { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, - "Error loading existing services file: " + relativeName - + " - " + e.getLocalizedMessage()); - } - return relativeName; - } - -} diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/plugin/PluggableService.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/plugin/PluggableService.java deleted file mode 100644 index c9c3afccba..0000000000 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/plugin/PluggableService.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.qpid.server.plugin;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.TYPE) -public @interface PluggableService -{ -} diff --git a/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor deleted file mode 100644 index 7f88042433..0000000000 --- a/qpid/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ /dev/null @@ -1,25 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.model.ConfiguredObjectFactoryGenerator -org.apache.qpid.server.model.SystemConfigFactoryGenerator -org.apache.qpid.server.plugin.PluggableProcessor -org.apache.qpid.server.model.ConfiguredObjectRegistrationGenerator -org.apache.qpid.server.model.validation.AttributeAnnotationValidator -org.apache.qpid.server.model.validation.AttributeFieldValidation -org.apache.qpid.server.model.validation.ManagedAnnotationValidator |
