View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.webservice.generator.bcm;
9   
10  import it.imolinfo.jbi4corba.webservice.generator.InterfaceType;
11  import it.imolinfo.jbi4corba.webservice.generator.InterfaceTypeUtils;
12  import java.util.Map;
13  
14  import org.objectweb.asm.ClassAdapter;
15  import org.objectweb.asm.ClassVisitor;
16  import org.objectweb.asm.MethodVisitor;
17  import org.objectweb.asm.Type;
18  
19  /**
20   * 
21   * This ASM Adapter class changes the change the return type of a method that
22   * return an interface for all methods that return's an interface it returns an
23   * W3CEndpointReference
24   * 
25   * @author Luca Acquaviva
26   */
27  public class InterfaceTypeClassAdapter extends ClassAdapter {
28  
29  	private Map<String, InterfaceType> opInterfaceTypes = null;
30  	private static final String W3CEPR = Type
31  			.getDescriptor(javax.xml.ws.wsaddressing.W3CEndpointReference.class);
32  	private static final String W3CEPRA = Type
33  			.getDescriptor(javax.xml.ws.wsaddressing.W3CEndpointReference[].class);
34         
35  
36  	/**
37  	 * 
38  	 * The Format of descriptor is
39  	 * (Ljava/lang/String;)Lit/imolinfo/jbi4corba/test;
40  	 * /testprovidersimplemult/Echo2; input return type
41  	 */
42  	@Override
43  	public MethodVisitor visitMethod(int access, String name, String desc,
44  			String signature, String[] exceptions) {
45  
46  		if (!"<init>".equals(name)) {
47  			
48               // change all interface type with W3CENDPOINTREFERENCE for 
49  			if (desc != null) {
50  				desc=InterfaceTypeUtils.changeInterfaceTypeDesc(desc, opInterfaceTypes);
51  	
52  			}
53  		}
54  		return super.visitMethod(access, name, desc, signature, exceptions);
55  	}
56  
57          
58         
59  	
60  	
61  
62          
63  	public InterfaceTypeClassAdapter(ClassVisitor arg0,
64  			Map<String, InterfaceType> opIntTypes) {
65  		super(arg0);
66  		opInterfaceTypes = opIntTypes;
67  	}
68  }