Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.as.ejb3.iiop.stub;
 

Author(s):
Stuart Douglas
    @Override
    public PresentationManager.StubFactory makeDynamicStubFactory(final PresentationManager pmfinal PresentationManager.ClassData classDatafinal ClassLoader classLoader) {
        final Class<?> myClass = classData.getMyClass();
        Class<?> theClass = makeStubClass(myClass);
        return new StubFactory(classDatatheClass);
    }

    
Makes a dynamic stub class, if it does not already exist.

Parameters:
myClass The class to create a stub for
Returns:
The dynamic stub class
    public static Class<?> makeStubClass(final Class<?> myClass) {
        final String stubClassName = myClass + "_Stub";
        ClassLoader cl = SecurityActions.getContextClassLoader();
        if (cl == null) {
            cl = myClass.getClassLoader();
        }
        if (cl == null) {
            throw ..couldNotFindClassLoaderForStub(stubClassName);
        }
        Class<?> theClass;
        try {
            theClass = cl.loadClass(stubClassName);
        } catch (ClassNotFoundException e) {
            try {
                final ClassFile clazz = IIOPStubCompiler.compile(myClassstubClassName);
                theClass = clazz.define(cl);
            } catch (RuntimeException ex) {
                //there is a possibility that another thread may have defined the same class in the meantime
                try {
                    theClass = cl.loadClass(stubClassName);
                } catch (ClassNotFoundException e1) {
                    ..dynamicStubCreationFailed(stubClassNameex);
                    throw ex;
                }
            }
        }
        return theClass;
    }
    private static final class StubFactory extends StubFactoryBase {
        private final Class<?> clazz;
        protected StubFactory(PresentationManager.ClassData classDatafinal Class<?> clazz) {
            super(classData);
            this. = clazz;
        }
        @Override
        public org.omg.CORBA.Object makeStub() {
            try {
                return (org.omg.CORBA.Object.newInstance();
            } catch (InstantiationException e) {
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        }
    }
New to GrepCode? Check out our FAQ X