Beispiel #1
0
  public org.omg.CORBA.ContainedPackage.Description describe() {
    org.omg.CORBA.Any a = orb.create_any();

    String def_in_name;
    if (myContainer != null) def_in_name = myContainer.id();
    else def_in_name = "IDL:/:1.0";

    org.omg.CORBA.TypeDescriptionHelper.insert(
        a, new org.omg.CORBA.TypeDescription(name(), id(), def_in_name, version(), type()));
    return new org.omg.CORBA.ContainedPackage.Description(org.omg.CORBA.DefinitionKind.dk_Enum, a);
  }
Beispiel #2
0
    public org.omg.CORBA.Contained[] contents(org.omg.CORBA.DefinitionKind limit_type, 
                                              boolean exclude_inherited)
    {
        Hashtable limited = new Hashtable();

        // analog constants, exceptions etc.

        for( Enumeration e = contained.elements(); e.hasMoreElements();  )
        {
            org.omg.CORBA.Contained c = (org.omg.CORBA.Contained)e.nextElement();
            if( limit_type == org.omg.CORBA.DefinitionKind.dk_all || 
                limit_type == c.def_kind() )
            {
                limited.put( c, "" );
            }
        }

        org.omg.CORBA.Contained[] c = new org.omg.CORBA.Contained[limited.size()];
        int i;
        Enumeration e;
        for( e = limited.keys(), i=0 ; e.hasMoreElements(); i++ )
            c[i] = (org.omg.CORBA.Contained)e.nextElement();
        return c;			
    }
Beispiel #3
0
  public EnumDef(
      Class c,
      org.omg.CORBA.Container _defined_in,
      org.omg.CORBA.Repository ir,
      ClassLoader loader) {
    def_kind = org.omg.CORBA.DefinitionKind.dk_Enum;
    defined_in = _defined_in;
    containing_repository = ir;
    version = "1.0";
    String classId = c.getName();
    myContainer = org.omg.CORBA.ContainedHelper.narrow(defined_in);

    if (classId.indexOf('.') > 0) {
      name(classId.substring(classId.lastIndexOf('.') + 1));
      String path = classId.substring(0, classId.lastIndexOf('.'));

      if (path.endsWith("Package")) {
        id(
            RepositoryID.toRepositoryID(
                path.substring(0, path.lastIndexOf("Package")) + "." + name, loader));
      } else {
        id(RepositoryID.toRepositoryID(path + "." + name, loader));
      }

      absolute_name = myContainer.absolute_name() + "::" + name;
    } else {
      name(classId);
      defined_in = containing_repository;
      id(RepositoryID.toRepositoryID(name, loader));
      absolute_name = "::" + name;
    }

    Field memberFields[] = c.getDeclaredFields();
    int member_size = (memberFields.length - 1) / 2;
    members = new String[member_size];
    // only every second field denotes an original enum member
    for (int i = 0; i < member_size; i++) {
      members[i] = memberFields[2 + (2 * i)].getName();
    }
    type = org.omg.CORBA.ORBSingleton.init().create_enum_tc(id, name, members);
  }
Beispiel #4
0
    public void loadContents()
    {
        // read from the  class (operations and atributes)
        Debug.assert( getReference() != null, "my own ref null");

        org.omg.CORBA.StructDef myReference = 
            org.omg.CORBA.StructDefHelper.narrow( getReference());

        Debug.assert( myReference != null, "narrow failed for " + getReference() );

        /* load nested definitions from interfacePackage directory */
        
        String[] classes = null;
        if( my_dir != null )
        {
            classes = my_dir.list( new IRFilenameFilter(".class") );

            // load class files in this interface's Package directory
            if( classes != null) 
            {
                for( int j = 0; j < classes.length; j++ )
                {
                    try 
                    { 
                        org.jacorb.util.Debug.output(2, "Struct " +name+ " tries " + 
                                                 full_name.replace('.', fileSeparator) + 
                                                 "Package" + fileSeparator + 
                                                 classes[j].substring( 0, classes[j].indexOf(".class")) );

                        ClassLoader loader = getClass().getClassLoader();
                        if( loader == null )
                        {
                            loader = RepositoryImpl.loader;
                        }

                        Class cl = 
                            loader.loadClass( 
                                             ( full_name.replace('.', fileSeparator) + "Package" + fileSeparator + 
                                               classes[j].substring( 0, classes[j].indexOf(".class"))
                                               ).replace( fileSeparator, '/') );
                        

                        Contained containedObject = Contained.createContained( cl, 
                                                                               path,
                                                                               myReference, 
                                                                               containing_repository );
                        if( containedObject == null )
                            continue;
                        
                        org.omg.CORBA.Contained containedRef = 
                            Contained.createContainedReference(containedObject);
                        
                        if( containedObject instanceof ContainerType )
                            ((ContainerType)containedObject).loadContents();
                        
                        containedRef.move( myReference, containedRef.name(), containedRef.version() );
                        
                        org.jacorb.util.Debug.output(2, "Struct " + full_name + 
                                                 " loads "+ containedRef.name() );
                        contained.put( containedRef.name() , containedRef );
                        containedLocals.put( containedRef.name(), containedObject );                        
                    } 
                    catch ( Exception e ) 
                    {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
Beispiel #5
0
  /**
   * print the IDL definition for a contained objec
   *
   * @param c the contained object
   * @param indentation how many spaces to use for indentation
   */
  public void printContained(org.omg.CORBA.Contained c, int indentation) {
    org.omg.CORBA.ContainedPackage.Description descr = c.describe();

    switch (descr.kind.value()) {
      case org.omg.CORBA.DefinitionKind._dk_Module:
        {
          printModule(org.omg.CORBA.ModuleDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Interface:
        {
          org.omg.CORBA.InterfaceDef idef =
              org.omg.CORBA.InterfaceDefHelper.narrow(
                  ir.lookup_id(org.omg.CORBA.InterfaceDescriptionHelper.extract(descr.value).id));
          printInterface(idef, indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Attribute:
        {
          printAttribute(
              org.omg.CORBA.AttributeDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Operation:
        {
          printOperation(
              org.omg.CORBA.OperationDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Exception:
        {
          printException(
              org.omg.CORBA.ExceptionDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Constant:
        {
          printConstant(
              org.omg.CORBA.ConstantDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Struct:
        {
          printStruct(org.omg.CORBA.TypeDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Enum:
        {
          printEnum(org.omg.CORBA.TypeDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Union:
        {
          printUnion(org.omg.CORBA.TypeDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
      case org.omg.CORBA.DefinitionKind._dk_Alias:
        {
          printAlias(org.omg.CORBA.TypeDescriptionHelper.extract(descr.value), indentation + 3);
          break;
        }
    }
  }