当前位置: 首页>>代码示例>>Java>>正文


Java Util.loadClass方法代码示例

本文整理汇总了Java中javax.rmi.CORBA.Util.loadClass方法的典型用法代码示例。如果您正苦于以下问题:Java Util.loadClass方法的具体用法?Java Util.loadClass怎么用?Java Util.loadClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.rmi.CORBA.Util的用法示例。


在下文中一共展示了Util.loadClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStubFactory

import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase,
    Class expectedClass, ClassLoader classLoader)
{
    Class cls = null ;

    try {
        cls = Util.loadClass( className, remoteCodeBase, classLoader ) ;
    } catch (ClassNotFoundException exc) {
        throw wrapper.classNotFound3(
            CompletionStatus.COMPLETED_MAYBE, exc, className ) ;
    }

    PresentationManager pm = ORB.getPresentationManager() ;

    if (IDLEntity.class.isAssignableFrom( cls ) &&
        !Remote.class.isAssignableFrom( cls )) {
        // IDL stubs must always use static factories.
        PresentationManager.StubFactoryFactory sff =
            pm.getStubFactoryFactory( false ) ;
        PresentationManager.StubFactory sf =
            sff.createStubFactory( className, true, remoteCodeBase,
                expectedClass, classLoader ) ;
        return sf ;
    } else {
        PresentationManager.ClassData classData = pm.getClassData( cls ) ;
        return makeDynamicStubFactory( pm, classData, classLoader ) ;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:StubFactoryFactoryDynamicBase.java

示例2: loadClassForClass

import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
public static Class loadClassForClass (String className,
                                       String remoteCodebase,
                                       ClassLoader loader,
                                       Class relatedType,
                                       ClassLoader relatedTypeClassLoader)
    throws ClassNotFoundException
{
    if (relatedType == null)
        return Util.loadClass(className, remoteCodebase, loader);

    Class loadedClass = null;
    try {
        loadedClass = Util.loadClass(className, remoteCodebase, loader);
    } catch (ClassNotFoundException cnfe) {
        if (relatedType.getClassLoader() == null)
            throw cnfe;
    }

    // If no class was not loaded, or if the loaded class is not of the
    // correct type, make a further attempt to load the correct class
    // using the classloader of the related type.
    // _REVISIT_ Is this step necessary, or should the Util,loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if (loadedClass == null ||
        (loadedClass.getClassLoader() != null &&
         loadedClass.getClassLoader().loadClass(relatedType.getName()) !=
             relatedType))
    {
        if (relatedType.getClassLoader() != relatedTypeClassLoader)
            throw new IllegalArgumentException(
                "relatedTypeClassLoader not class loader of relatedType.");

        if (relatedTypeClassLoader != null)
            loadedClass = relatedTypeClassLoader.loadClass(className);
    }

    return loadedClass;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:Utility.java

示例3: getClassFromType

import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
public final Class getClassFromType()
    throws ClassNotFoundException {
    if (clazz != null)
        return clazz;

    Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());

    if (specialCase != null){
        clazz = specialCase;
        return specialCase;
    }
    else
        {
            try{
                return Util.loadClass(getClassName(), null, null);
            }
            catch(ClassNotFoundException cnfe){
                if (defaultServerURL != null) {
                    try{
                        return getClassFromType(defaultServerURL);
                    }
                    catch(MalformedURLException mue){
                        throw cnfe;
                    }
                }
                else throw cnfe;
            }
        }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:RepositoryId.java

示例4: createStubFactory

import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:72,代码来源:StubFactoryFactoryStaticImpl.java

示例5: _createInstance

import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
static Object _createInstance(String id, String codebase)
{
  if (id == null)
    return null;
  if (id.equals(StringValueHelper.id()))
    return "";
  StringTokenizer st = new StringTokenizer(id, ":");

  String prefix = st.nextToken();
  if (prefix.equalsIgnoreCase("IDL"))
    return ObjectCreator.Idl2Object(id);
  else if (prefix.equalsIgnoreCase("RMI"))
    {
      String className = st.nextToken();
      String hashCode = st.nextToken();
      String sid = null;
      if (st.hasMoreElements())
        sid = st.nextToken();

      try
        {
          Class objectClass = Util.loadClass(className, codebase,
            Vio.class.getClassLoader());

          String rid = ObjectCreator.getRepositoryId(objectClass);

          if (!rid.equals(id))
            {
              // If direct string comparison fails, compare by meaning.
              StringTokenizer st2 = new StringTokenizer(rid, ":");
              if (!st2.nextToken().equals("RMI"))
                throw new InternalError("RMI format expected: '" + rid + "'");
              if (!st2.nextToken().equals(className))
                throwIt("Class name mismatch", id, rid, null);

              try
                {
                  long h1 = Long.parseLong(hashCode, 16);
                  long h2 = Long.parseLong(st2.nextToken(), 16);
                  if (h1 != h2)
                    throwIt("Hashcode mismatch", id, rid, null);

                  if (sid != null && st2.hasMoreTokens())
                    {
                      long s1 = Long.parseLong(hashCode, 16);
                      long s2 = Long.parseLong(st2.nextToken(), 16);
                      if (s1 != s2)
                        throwIt("serialVersionUID mismatch", id, rid, null);
                    }
                }
              catch (NumberFormatException e)
                {
                  throwIt("Invalid hashcode or svuid format: ", id, rid, e);
                }
            }

          // Low - level instantiation required here.
          return instantiateAnyWay(objectClass);
        }
      catch (Exception ex)
        {
          MARSHAL m = new MARSHAL("Unable to instantiate " + id);
          m.minor = Minor.Instantiation;
          m.initCause(ex);
          throw m;
        }
    }
  else
    throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
}
 
开发者ID:vilie,项目名称:javify,代码行数:71,代码来源:Vio.java


注:本文中的javax.rmi.CORBA.Util.loadClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。