예제 #1
0
    public void define()
    {
        org.jacorb.util.Debug.output(2, "Struct " + name +  " defining...");
        for( Enumeration e = containedLocals.elements();
             e.hasMoreElements();
             ((IRObject)e.nextElement()).define())
            ;

        for( int i = 0; i < members.length; i++ )
        {
            members[i].type_def = IDLType.create( members[i].type, containing_repository);
            org.jacorb.util.Debug.assert( members[i].type_def != null,
                                      "No type_def for member " + members[i].name + 
                                      " in struct " +  full_name );
        }
        defined = true;
        org.jacorb.util.Debug.output(2, "Struct " + name +  " defined");

    }
예제 #2
0
    public StructDef(Class c, 
                     String path,
                     org.omg.CORBA.Container _defined_in,
                     org.omg.CORBA.Repository ir)
    {
        def_kind = org.omg.CORBA.DefinitionKind.dk_Struct;
        containing_repository = ir;
        defined_in = _defined_in;
        this.path = path;
        Debug.assert( defined_in != null, "defined_in = null");
        Debug.assert( containing_repository != null, "containing_repository = null");

        try
        { 
            String classId = c.getName();
            myClass = c;
            version( "1.0" );
            full_name = classId.replace('.', '/');

            if( classId.indexOf('.') > 0 ) 
            {
                name( classId.substring( classId.lastIndexOf('.')+1 ) );
                absolute_name = 
                    org.omg.CORBA.ContainedHelper.narrow( defined_in ).absolute_name() + 
                    "::" + name;
            }             
            else 
            {
                name( classId );
                absolute_name = "::" + name;
            }
	
            helperClass = RepositoryImpl.loader.loadClass( classId + "Helper") ;
            id( (String)helperClass.getDeclaredMethod( "id", null ).invoke( null, null ));
            type = 
                TypeCodeUtil.getTypeCode( myClass, RepositoryImpl.loader, null, classId );
            
            members = new org.omg.CORBA.StructMember[ type.member_count() ];
            for( int i = 0; i < members.length; i++ )
            {
                org.omg.CORBA.TypeCode type_code = type.member_type(i);
                String member_name = type.member_name(i);
                members[i] = new org.omg.CORBA.StructMember( member_name, 
                                                             type_code,
                                                             null );
            }
            /* get directory for nested definitions' classes */
            File f = new File( path + fileSeparator + 
                               classId.replace('.', fileSeparator) + "Package" );

            if( f.exists() && f.isDirectory() )
                my_dir = f;
            org.jacorb.util.Debug.output(2, "StructDef: " + absolute_name );
        }
        catch ( Exception e )
        {
            e.printStackTrace();
            throw new org.omg.CORBA.INTF_REPOS( ErrorMsg.IR_Not_Implemented,
                                                org.omg.CORBA.CompletionStatus.COMPLETED_NO);
        }
    }
예제 #3
0
    public org.omg.CORBA.Contained lookup( String scopedname )
    {
        org.jacorb.util.Debug.output(2,"Struct " + this.name + " lookup " + scopedname );

        String top_level_name;
        String rest_of_name;
        String name;

        if( scopedname.startsWith("::") )       
        {
            name = scopedname.substring(2);
        }
        else
            name = scopedname;

        if( name.indexOf("::") > 0 )
        {
            top_level_name = name.substring( 0, name.indexOf("::") );
            rest_of_name = name.substring( name.indexOf("::") + 2);
        } 
        else 
        {
            top_level_name = name;
            rest_of_name = null;
        }
		
        try
        {
            org.omg.CORBA.Contained top = 
                (org.omg.CORBA.Contained)contained.get( top_level_name );

            if( top == null )
            {
                org.jacorb.util.Debug.output(2,"Interface " + this.name + 
                                         " top " + top_level_name + " not found ");
                return null;
            }
	
            if( rest_of_name == null )
            {
                return top;
            }
            else 
            {
                if( top instanceof org.omg.CORBA.Container)
                {
                    return ((org.omg.CORBA.Container)top).lookup( rest_of_name );
                }
                else
                {
                    org.jacorb.util.Debug.output(2,"Interface " + this.name +
                                             " " + scopedname + " not found ");
                    return null;		
                }
            }
        } 
        catch( Exception e )
        {
            e.printStackTrace();
            return null;			
        }	
    }
예제 #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();
                    }
                }
            }
        }
    }