Package java.lang.reflect

Examples of java.lang.reflect.InvocationHandler


      if (nameCtx == null)
         nameCtx = new InitialContext(env);
      if (obj == null)
      {
         // Create a context for resolving the java: url
         InvocationHandler handler = new EncContextProxy(nameCtx, clientName);
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         Class[] ifaces = {Context.class};
         result = Proxy.newProxyInstance(loader, ifaces, handler);
      }
      return result;
View Full Code Here


      else
      {
         MBeanInfo info = server.getMBeanInfo(objectName);
         MBeanOperationInfo[] opInfo = info.getOperations();
         Class[] interfaces = {Service.class};
         InvocationHandler handler = new ServiceProxy(objectName, opInfo);
         service = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
      }

      return service;
   }
View Full Code Here

            ic = new InitialContext();

         Proxy proxy = (Proxy) ic.lookup(jndiName);

         // call findByPrimary on the target
         InvocationHandler ih = Proxy.getInvocationHandler(proxy);
         return (EJBObject) ih.invoke(proxy, GET_EJB_OBJECT, new Object[] {id});
      }
      catch (RemoteException e)
      {
         throw e;
      }
View Full Code Here

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    ProxyGenerator pg = new ProxyGenerator(Comparable.class);
    pg.generate(Type.getType("LC;"), ca);

    InvocationHandler handler = new InvocationHandler() {
      public Object invoke(Object proxy, Method method, Object[] args)
          throws Throwable {
        ProxyGeneratorTest.this.p = proxy;
        ProxyGeneratorTest.this.m = method;
        ProxyGeneratorTest.this.args = args;
View Full Code Here

            return new Injectable<Broadcaster>() {
                @Override
                public Broadcaster getValue() {
                    return (Broadcaster)Proxy.newProxyInstance(this.getClass().getClassLoader(),
                            new Class[] { Broadcaster.class },
                            new InvocationHandler() {
                        @Override
                        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                            return method.invoke(getAtmosphereResource(Broadcaster.class, true).getBroadcaster(),
                                    args);
                        }
View Full Code Here

            return new Injectable<AtmosphereResource>() {
                @Override
                public AtmosphereResource getValue() {
                    return (AtmosphereResource)Proxy.newProxyInstance(this.getClass().getClassLoader(),
                            new Class[] { AtmosphereResource.class }, new InvocationHandler() {
                        @Override
                        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                            return method.invoke(getAtmosphereResource(AtmosphereResource.class, false), args);
                        }
                    });
View Full Code Here

   
    String beanName = clazz.getName()+"Bean";
    Class beanClass = Class.forName(beanName);
    final Object bean = beanClass.newInstance();

    InvocationHandler handler = new InvocationHandler() {

       public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
         try {
        Object retValue = method.invoke(bean,args);
        if (!method.getName().equals("setDataSource") &&
View Full Code Here

  @SuppressWarnings("unchecked")
  private <T extends IComponent> T createComponentInstance(
      Class<T> componentContract, Object delegate, Class<?>[] extraInterfaces) {
    IComponentDescriptor<IComponent> componentDescriptor = (IComponentDescriptor<IComponent>) componentDescriptorRegistry
        .getComponentDescriptor(componentContract);
    InvocationHandler componentHandler;
    if (delegate != null) {
      componentHandler = createDelegatingComponentInvocationHandler(
          componentDescriptor, delegate);
    } else {
      componentHandler = createComponentInvocationHandler(componentDescriptor);
View Full Code Here

    extends BaseWstxTest
{
    public void testBundleActivation()
    {
        // Hmmh. Context is a beastly class... let's just proxy it
        InvocationHandler h = new ContextHandler();
        BundleContext ctxt = (BundleContext) Proxy.newProxyInstance(BundleContext.class.getClassLoader(), new Class[] { BundleContext.class }, h);
        WstxBundleActivator act = new WstxBundleActivator();

        // won't prove much... but at least there's noo fundamental flaw:
        act.start(ctxt);
View Full Code Here

   */
  public Object create(Class<?> api, URL url, ClassLoader loader)
  {
    if (api == null)
      throw new NullPointerException("api must not be null for HessianProxyFactory.create()");
    InvocationHandler handler = null;

    handler = new HessianProxy(url, this, api);

    return Proxy.newProxyInstance(loader,
                                  new Class[] { api,
View Full Code Here

TOP

Related Classes of java.lang.reflect.InvocationHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.