Skip to content

Commit

Permalink
Fix generate-domain-schema asadmin command
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Pinčuk <alexander.v.pinchuk@gmail.com>
  • Loading branch information
avpinchuk committed Apr 17, 2023
1 parent 984d2f9 commit 25b13a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -17,30 +17,32 @@

package com.sun.enterprise.admin.cli.schemadoc;

import org.objectweb.asm.AnnotationVisitor;
import org.glassfish.api.admin.config.PropertiesDesc;
import org.glassfish.api.admin.config.PropertyDesc;
import org.jvnet.hk2.config.Attribute;
import org.objectweb.asm.AnnotationVisitor;

import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ASM9;

public class AttributeMethodVisitor extends EmptyVisitor {
private ClassDef def;
private String name;
private String type;
private boolean duckTyped;
private final ClassDef def;
private final String name;
private final String type;
private final boolean defaultMethod;

public AttributeMethodVisitor(ClassDef classDef, String method, String aggType) {
public AttributeMethodVisitor(ClassDef classDef, int access, String method, String aggType) {
super(ASM9);
def = classDef;
name = method;
type = aggType;
this.def = classDef;
this.name = method;
this.type = aggType;
this.defaultMethod = access == ACC_PUBLIC;
def.addAttribute(name, null);
}

@Override
public String toString() {
return "AttributeMethodVisitor{" + "def=" + def + ", name='" + name + '\'' + ", type='" + type + '\'' + ", duckTyped=" + duckTyped
return "AttributeMethodVisitor{" + "def=" + def + ", name='" + name + '\'' + ", type='" + type + '\'' + ", defaultMethod=" + defaultMethod
+ '}';
}

Expand All @@ -55,7 +57,6 @@ public String toString() {
*/
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
duckTyped |= "Lorg/jvnet/hk2/config/DuckTyped;".equals(desc);
AnnotationVisitor visitor = null;
if ("Lorg/jvnet/hk2/config/Attribute;".equals(desc) || "Lorg/jvnet/hk2/config/Element;".equals(desc)) {
try {
Expand Down Expand Up @@ -83,7 +84,7 @@ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {

@Override
public void visitEnd() {
if (!duckTyped) {
if (!defaultMethod) {
if (!isSimpleType(type)) {
def.addAggregatedType(name, type);
def.removeAttribute(name);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -96,7 +96,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
} catch (StringIndexOutOfBoundsException e) {
throw new RuntimeException(e.getMessage());
}
return name.startsWith("get") && type != null ? new AttributeMethodVisitor(classDef, name, type) : null;
return name.startsWith("get") && type != null ? new AttributeMethodVisitor(classDef, access, name, type) : null;
}

/**
Expand Down

0 comments on commit 25b13a1

Please sign in to comment.