1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer.classes; 27 28 import static org.objectweb.easybeans.deployment.annotations.ClassType.MDB; 29 30 import org.objectweb.asm.AnnotationVisitor; 31 import org.objectweb.asm.Type; 32 import org.objectweb.asm.commons.EmptyVisitor; 33 34 import org.objectweb.easybeans.deployment.annotations.analyzer.AnnotationType; 35 import org.objectweb.easybeans.deployment.annotations.impl.JActivationConfigProperty; 36 import org.objectweb.easybeans.deployment.annotations.impl.JMessageDriven; 37 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 38 39 44 public class JavaxEjbMessageDrivenVisitor extends AbsCommonEjbVisitor<JMessageDriven> implements AnnotationType { 45 46 49 public static final String TYPE = "Ljavax/ejb/MessageDriven;"; 50 51 54 private static final String MESSAGE_LISTENER_INTERFACE = "messageListenerInterface"; 55 56 59 private static final String ACTIVATION_CONFIG = "activationConfig"; 60 61 64 private String messageListenerInterface = null; 65 66 70 public JavaxEjbMessageDrivenVisitor(final ClassAnnotationMetadata classAnnotationMetadata) { 71 super(classAnnotationMetadata); 72 } 73 74 82 @Override 83 public void visit(final String name, final Object value) { 84 super.visit(name, value); 85 if (name.equals(MESSAGE_LISTENER_INTERFACE)) { 86 this.messageListenerInterface = ((Type) value).getInternalName(); 87 } 88 } 89 90 96 @Override 97 public void visitEnum(final String name, final String desc, final String value) { 98 99 } 100 101 109 @Override 110 public AnnotationVisitor visitAnnotation(final String name, final String desc) { 111 return this; 112 } 113 114 122 @Override 123 public AnnotationVisitor visitArray(final String name) { 124 if (name.equals(ACTIVATION_CONFIG)) { 125 return new ActivationConfigPropertyVisitor(); 126 } 127 return this; 128 } 129 130 133 @Override 134 public void visitEnd() { 135 super.visitEnd(); 136 137 getJCommonBean().setMessageListenerInterface(messageListenerInterface); 139 140 getAnnotationMetadata().setClassType(MDB); 142 143 } 144 145 148 public String getType() { 149 return TYPE; 150 } 151 152 157 class ActivationConfigPropertyVisitor extends EmptyVisitor { 158 159 162 private static final String PROPERTY_NAME = "propertyName"; 163 164 167 private static final String PROPERTY_VALUE = "propertyValue"; 168 169 172 private String propertyName = null; 173 174 177 private String propertyValue = null; 178 179 187 @Override 188 public void visit(final String name, final Object value) { 189 if (name.equals(PROPERTY_NAME)) { 190 propertyName = (String ) value; 191 } else if (name.equals(PROPERTY_VALUE)) { 192 propertyValue = (String ) value; 193 } 194 } 195 196 199 @Override 200 public void visitEnd() { 201 JActivationConfigProperty jActivationConfigProperty = new JActivationConfigProperty(propertyName, 203 propertyValue); 204 getJCommonBean().addActivationConfigProperty(jActivationConfigProperty); 205 206 } 207 } 208 209 212 @Override 213 public JMessageDriven getJCommonBean() { 214 JMessageDriven jMessageDriven = getAnnotationMetadata().getJMessageDriven(); 215 if (jMessageDriven == null) { 216 jMessageDriven = new JMessageDriven(); 217 getAnnotationMetadata().setJMessageDriven(jMessageDriven); 218 } 219 return jMessageDriven; 220 } 221 222 } 223 | Popular Tags |