1 20 21 package org.jacorb.ir; 22 23 import java.lang.reflect.*; 24 import java.util.*; 25 26 import org.omg.CORBA.INTF_REPOS ; 27 import org.omg.CORBA.TypeCode ; 28 import org.omg.PortableServer.POA ; 29 30 import org.apache.avalon.framework.logger.Logger; 31 32 public class AttributeDef 33 extends Contained 34 implements org.omg.CORBA.AttributeDefOperations 35 { 36 private org.omg.CORBA.TypeCode typeCode = null; 37 private org.omg.CORBA.IDLType type_def = null; 38 private org.omg.CORBA.AttributeMode mode = null; 39 private Method method = null; 40 private boolean defined = false; 41 private Logger logger; 42 private POA poa; 43 44 public AttributeDef( java.lang.reflect.Method m, 45 String attrTypeName, 46 org.omg.CORBA.AttributeMode mode, 47 org.omg.CORBA.Container _defined_in, 48 org.omg.CORBA.Repository _containing_repository, 49 Logger logger , 50 ClassLoader loader, 51 POA poa) 52 { 53 this.logger = logger; 54 this.poa = poa; 55 def_kind = org.omg.CORBA.DefinitionKind.dk_Attribute; 56 method = m; 57 this.mode = mode; 58 name( m.getName() ); 59 version( "1.0" ); 60 61 try 62 { 63 typeCode = 64 TypeCodeUtil.getTypeCode( m.getReturnType(), 65 loader, 66 null, 67 attrTypeName, 68 this.logger); 69 } 70 catch( ClassNotFoundException cnfe ) 71 { 72 this.logger.error("Error: TypeCode for AttributeDef could not be created!", 73 cnfe); 74 } 75 76 defined_in = _defined_in; 77 containing_repository = _containing_repository; 78 79 if (containing_repository == null) 80 { 81 throw new INTF_REPOS ("containing_repository null"); 82 } 83 if (defined_in == null) 84 { 85 throw new INTF_REPOS ("defined_in null"); 86 } 87 88 org.omg.CORBA.Contained myContainer = 89 org.omg.CORBA.ContainedHelper.narrow( defined_in ); 90 String interface_id = myContainer.id(); 91 92 id = interface_id.substring(interface_id.lastIndexOf(':')-1) + 93 name() + ":" + version(); 94 absolute_name = myContainer.absolute_name() + "::" + name(); 95 96 if (this.logger.isDebugEnabled()) 97 { 98 this.logger.debug("New AttributeDef, name: " + name() + 99 " " + absolute_name); 100 } 101 } 102 103 public org.omg.CORBA.TypeCode type() 104 { 105 return typeCode; 106 } 107 108 public org.omg.CORBA.IDLType type_def() 109 { 110 return type_def; 111 } 112 113 public void type_def(org.omg.CORBA.IDLType a) 114 { 115 if (defined == false) 116 { 117 throw new INTF_REPOS ("Attribute not defined" ); 118 } 119 type_def = a; 120 } 121 122 public org.omg.CORBA.AttributeMode mode() 123 { 124 return mode; 125 } 126 127 public void mode(org.omg.CORBA.AttributeMode a) 128 { 129 mode = a; 130 } 131 132 org.omg.CORBA.AttributeDescription describe_attribute() 133 { 134 return new org.omg.CORBA.AttributeDescription ( 135 name(), 136 id(), 137 org.omg.CORBA.ContainedHelper.narrow(defined_in).id(), 138 version(), 139 type(), 140 mode()); 141 } 142 143 public void define() 144 { 145 type_def = IDLType.create(typeCode, containing_repository, 146 this.logger, this.poa ); 147 defined = true; 148 } 149 150 152 public org.omg.CORBA.ContainedPackage.Description describe() 153 { 154 org.omg.CORBA.Any a = orb.create_any(); 155 org.omg.CORBA.AttributeDescriptionHelper.insert( a, describe_attribute() ); 156 return new org.omg.CORBA.ContainedPackage.Description( 157 org.omg.CORBA.DefinitionKind.dk_Attribute, a); 158 } 159 160 162 public void destroy() 163 {} 164 165 166 } 167 | Popular Tags |