Tabnine Logo
LocalBeanProxyFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
LocalBeanProxyFactory
in
org.apache.openejb.util.proxy

Best Java code snippets using org.apache.openejb.util.proxy.LocalBeanProxyFactory (Showing top 20 results out of 315)

origin: org.apache.openejb/openejb-core

public static Class createProxy(final Class<?> classToProxy, final ClassLoader cl, final Class... interfaces) {
  return createProxy(classToProxy, cl, classToProxy.getName() + "$$LocalBeanProxy", interfaces);
}
origin: org.apache.tomee/openejb-core

public static InvocationHandler getInvocationHandler(final Object proxy) {
  if (LocalBeanProxyFactory.isProxy(proxy.getClass())) {
    return LocalBeanProxyFactory.getInvocationHandler(proxy);
  }
  checkDefaultFactory();
  return defaultFactory.getInvocationHandler(proxy);
}
origin: org.apache.openejb/openejb-core

public static Object newProxyInstance(final ClassLoader classLoader, final InvocationHandler handler, final Class classToSubclass, final Class... interfaces) throws IllegalArgumentException {
  try {
    final Class proxyClass = createProxy(classToSubclass, classLoader, interfaces);
    return constructProxy(proxyClass, handler);
  } catch (final Throwable e) {
    throw new InternalError("LocalBeanProxyFactory.newProxyInstance: " + Debug.printStackTrace(e));
  }
}
origin: org.apache.openejb/openejb-core

/**
 * Gets the string to use for CHECKCAST instruction, returning the correct value for any type, including primitives and arrays
 *
 * @param returnType The type to cast to with CHECKCAST
 * @return CHECKCAST parameter
 */
static String getCastType(final Class<?> returnType) {
  if (returnType.isPrimitive()) {
    return getWrapperType(returnType);
  } else {
    return getAsmTypeAsString(returnType, false);
  }
}
origin: org.apache.openejb/openejb-core

final MethodVisitor mv = cw.visitMethod(modifier, method.getName(), getMethodSignatureAsString(returnType, parameterTypes), null, null);
mv.visitCode();
createArrayDefinition(mv, parameterTypes.length, Class.class);
  pushIntOntoStack(mv, i);
    final String wrapperType = getWrapperType(parameterType);
    mv.visitFieldInsn(GETSTATIC, wrapperType, "TYPE", "Ljava/lang/Class;");
  } else {
    mv.visitLdcInsn(Type.getType(getAsmTypeAsString(parameterType, true)));
createArrayDefinition(mv, parameterTypes.length, Object.class);
  pushIntOntoStack(mv, i);
    final String wrapperType = getWrapperType(parameterType);
    mv.visitVarInsn(getVarInsn(parameterType), index);
    mv.visitMethodInsn(INVOKESTATIC, wrapperType, "valueOf", "(" + getPrimitiveLetter(parameterType) + ")L" + wrapperType + ";", false);
    mv.visitInsn(AASTORE);
mv.visitTypeInsn(CHECKCAST, getCastType(returnType));
  mv.visitMethodInsn(INVOKEVIRTUAL, getWrapperType(returnType), getPrimitiveMethod(returnType), "()" + getPrimitiveLetter(returnType), false);
  mv.visitInsn(getReturnInsn(returnType));
} else {
  mv.visitInsn(POP);
origin: org.apache.openejb/openejb-core

public static Object proxy(final BeanContext beanContext, final Class<?>[] itfs) {
  if (beanContext.isLocalbean()) {
    return LocalBeanProxyFactory.newProxyInstance(itfs[0].getClassLoader(), new Handler(beanContext), itfs[0], IntraVmProxy.class, Serializable.class);
  }
  return Proxy.newProxyInstance(itfs[0].getClassLoader(), itfs, new Handler(beanContext));
}
origin: org.apache.openejb/openejb-core

@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
  if (xaResource != null && xaResourceWrapper != null) {
    xaResource = xaResourceWrapper.wrap(xaResource, container.getContainerID().toString());
  }
  final EndpointHandler endpointHandler = new EndpointHandler(container, beanContext, instanceFactory, xaResource);
  try {
    return (MessageEndpoint) LocalBeanProxyFactory.constructProxy(proxy, endpointHandler);
  } catch (final InternalError e) { // should be useless
    //try to create the proxy with tccl once again.
    try {
      return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(Thread.currentThread().getContextClassLoader(), endpointHandler, beanContext.getBeanClass(), interfaces));
    } catch (final InternalError ie) {
      try {
        return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(classLoader, endpointHandler, beanContext.getBeanClass(), interfaces));
      } catch (final InternalError ie2) {
        // no-op
      }
    }
    throw e;
  }
}
origin: org.apache.openejb/openejb-core

if (parameterType.getComponentType().isPrimitive()) {
  final Class<?> componentType = parameterType.getComponentType();
  return "[" + getPrimitiveLetter(componentType);
} else {
  return "[" + getAsmTypeAsString(parameterType.getComponentType(), true);
  return getPrimitiveLetter(parameterType);
} else {
  String className = parameterType.getCanonicalName();
origin: org.apache.openejb/openejb-cxf-rs

private Collection<Class<?>> getContextTypes(final Object resourceObject) {
  if (!ProxyManager.isProxyClass(resourceObject.getClass())
    && !LocalBeanProxyFactory.isProxy(resourceObject.getClass())) {
    return Collections.emptySet();
  }
  final InvocationHandler handler = ProxyManager.getInvocationHandler(resourceObject);
  if (!(handler instanceof BeanContextInvocationHandler)) {
    return Collections.emptySet();
  }
  final BeanContext beanContext = ((BeanContextInvocationHandler) handler).getBeanContext();
  if (beanContext == null) {
    return Collections.emptySet();
  }
  return contextTypes.get(beanContext.getBeanClass());
}
origin: org.apache.tomee/openejb-core

  return LocalBeanProxyFactory.constructProxy(di.get(BeanContext.ProxyClass.class).getProxy(), handler);
} else {
  final List<Class> interfaces = new ArrayList<Class>();
origin: org.apache.openejb/openejb-core

static String getMethodSignatureAsString(final Class<?> returnType, final Class<?>[] parameterTypes) {
  final StringBuilder builder = new StringBuilder();
  builder.append("(");
  for (final Class<?> parameterType : parameterTypes) {
    builder.append(getAsmTypeAsString(parameterType, true));
  }
  builder.append(")");
  builder.append(getAsmTypeAsString(returnType, true));
  return builder.toString();
}
origin: org.apache.openejb/openejb-core

public static Object constructProxy(final Class clazz, final InvocationHandler handler) throws IllegalStateException {
  final Object instance = Unsafe.allocateInstance(clazz);
  Unsafe.setValue(getDeclaredField(clazz, BUSSINESS_HANDLER_NAME), instance, handler);
  Unsafe.setValue(getDeclaredField(clazz, NON_BUSINESS_HANDLER_NAME), instance, NON_BUSINESS_HANDLER);
  return instance;
}
origin: org.apache.openejb/openejb-core

public static Class createProxy(final Class<?> classToProxy, final ClassLoader cl, final String proxyName, final Class... interfaces) {
  final String classFileName = proxyName.replace('.', '/');
  try {
    return cl.loadClass(proxyName);
  } catch (final Exception e) {
    // no-op
  }
  final ReentrantLock lock = LocalBeanProxyFactory.LOCK;
  lock.lock();
  try {
    try { // Try it again, another thread may have beaten this one...
      return cl.loadClass(proxyName);
    } catch (final Exception e) {
      // no-op
    }
    final byte[] proxyBytes = generateProxy(classToProxy, classFileName, interfaces);
    return Unsafe.defineClass(classToProxy, proxyName, proxyBytes);
  } catch (final Exception e) {
    throw new InternalError("LocalBeanProxyFactory.createProxy: " + Debug.printStackTrace(e));
  } finally {
    lock.unlock();
  }
}
origin: org.apache.tomee/openejb-core

final MethodVisitor mv = cw.visitMethod(modifier, method.getName(), getMethodSignatureAsString(returnType, parameterTypes), null, null);
mv.visitCode();
createArrayDefinition(mv, parameterTypes.length, Class.class);
  pushIntOntoStack(mv, i);
    final String wrapperType = getWrapperType(parameterType);
    mv.visitFieldInsn(GETSTATIC, wrapperType, "TYPE", "Ljava/lang/Class;");
  } else {
    mv.visitLdcInsn(Type.getType(getAsmTypeAsString(parameterType, true)));
createArrayDefinition(mv, parameterTypes.length, Object.class);
  pushIntOntoStack(mv, i);
    final String wrapperType = getWrapperType(parameterType);
    mv.visitVarInsn(getVarInsn(parameterType), index);
    mv.visitMethodInsn(INVOKESTATIC, wrapperType, "valueOf", "(" + getPrimitiveLetter(parameterType) + ")L" + wrapperType + ";", false);
    mv.visitInsn(AASTORE);
mv.visitTypeInsn(CHECKCAST, getCastType(returnType));
  mv.visitMethodInsn(INVOKEVIRTUAL, getWrapperType(returnType), getPrimitiveMethod(returnType), "()" + getPrimitiveLetter(returnType), false);
  mv.visitInsn(getReturnInsn(returnType));
} else {
  mv.visitInsn(POP);
origin: org.apache.openejb/openejb-core

public static Object simpleProxy(final BeanContext beanContext, final Class<?>[] itfs) {
  if (beanContext.isLocalbean()) {
    return LocalBeanProxyFactory.newProxyInstance(itfs[0].getClassLoader(), new Handler(beanContext), itfs[0]);
  }
  return Proxy.newProxyInstance(itfs[0].getClassLoader(), itfs, new Handler(beanContext));
}
origin: org.apache.tomee/openejb-core

@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
  if (xaResource != null && xaResourceWrapper != null) {
    xaResource = xaResourceWrapper.wrap(xaResource, container.getContainerID().toString());
  }
  InvocationHandler endpointHandler = null;
  if (usePool) {
    endpointHandler = new PoolEndpointHandler(container, beanContext, instanceManager, xaResource);
  } else {
    endpointHandler = new EndpointHandler(container, beanContext, instanceFactory, xaResource);
  }
  try {
    return (MessageEndpoint) LocalBeanProxyFactory.constructProxy(proxy, endpointHandler);
  } catch (final InternalError e) { // should be useless
    //try to create the proxy with tccl once again.
    try {
      return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(Thread.currentThread().getContextClassLoader(), endpointHandler, beanContext.getBeanClass(), interfaces));
    } catch (final InternalError ie) {
      try {
        return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(classLoader, endpointHandler, beanContext.getBeanClass(), interfaces));
      } catch (final InternalError ie2) {
        // no-op
      }
    }
    throw e;
  }
}
origin: org.apache.tomee/openejb-core

/**
 * Gets the string to use for CHECKCAST instruction, returning the correct value for any type, including primitives and arrays
 *
 * @param returnType The type to cast to with CHECKCAST
 * @return CHECKCAST parameter
 */
static String getCastType(final Class<?> returnType) {
  if (returnType.isPrimitive()) {
    return getWrapperType(returnType);
  } else {
    return getAsmTypeAsString(returnType, false);
  }
}
origin: org.apache.tomee/openejb-core

if (parameterType.getComponentType().isPrimitive()) {
  final Class<?> componentType = parameterType.getComponentType();
  return "[" + getPrimitiveLetter(componentType);
} else {
  return "[" + getAsmTypeAsString(parameterType.getComponentType(), true);
  return getPrimitiveLetter(parameterType);
} else {
  String className = parameterType.getCanonicalName();
origin: org.apache.openejb/openejb-core

  return LocalBeanProxyFactory.constructProxy(di.get(BeanContext.ProxyClass.class).getProxy(), handler);
} else {
  final List<Class> interfaces = new ArrayList<Class>();
origin: org.apache.tomee/openejb-core

static String getMethodSignatureAsString(final Class<?> returnType, final Class<?>[] parameterTypes) {
  final StringBuilder builder = new StringBuilder();
  builder.append("(");
  for (final Class<?> parameterType : parameterTypes) {
    builder.append(getAsmTypeAsString(parameterType, true));
  }
  builder.append(")");
  builder.append(getAsmTypeAsString(returnType, true));
  return builder.toString();
}
org.apache.openejb.util.proxyLocalBeanProxyFactory

Most used methods

  • createProxy
  • isProxy
  • newProxyInstance
  • constructProxy
  • createArrayDefinition
    pushes an array of the specified size to the method visitor. The generated bytecode will leave the n
  • generateProxy
  • getAsmTypeAsString
    Converts a class to a String suitable for ASM.
  • getCastType
    Gets the string to use for CHECKCAST instruction, returning the correct value for any type, includin
  • getDeclaredField
  • getInvocationHandler
  • getMethodSignatureAsString
  • getNonPrivateMethods
  • getMethodSignatureAsString,
  • getNonPrivateMethods,
  • getPrimitiveLetter,
  • getPrimitiveMethod,
  • getReturnInsn,
  • getVarInsn,
  • getWrapperType,
  • isOverridden,
  • processMethod,
  • pushIntOntoStack

Popular in Java

  • Reading from database using SQL prepared statement
  • setScale (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • getResourceAsStream (ClassLoader)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • IsNull (org.hamcrest.core)
    Is the value null?
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now