Package java.beans

Examples of java.beans.PersistenceDelegate


   */
  public static <C> void addDelegateForConstructor(
      Class<? super C> classToBePersisted,
      final IConstructorParameterProvider<C> parameterProvider) {

    PersistenceDelegate delegate = new DefaultPersistenceDelegate() {

      @Override
      @SuppressWarnings("unchecked")
      // no way of checking it here
      protected Expression instantiate(Object oldInstance, Encoder out) {
View Full Code Here


            e.setExceptionListener(new ExceptionListener() {
                public void exceptionThrown(Exception e) {
                    throw new EmsException("Could not encode connection settings",e);
                }
            });
            e.setPersistenceDelegate(File.class,new PersistenceDelegate() {
                protected Expression instantiate(Object oldInstance, Encoder out) {
                    File f = (File) oldInstance;
                    return new Expression(oldInstance, oldInstance.getClass(),"new", new Object[]{ f.getAbsolutePath() });
                }
View Full Code Here

    protected Object getObject() {
        return new GrandParent().create().create();
    }

    protected void initialize(XMLEncoder encoder) {
        encoder.setPersistenceDelegate(Parent.class, new PersistenceDelegate() {
            protected Expression instantiate(Object old, Encoder out) {
                Parent parent = (Parent) old;
                return new Expression(old, parent.getParent(), "create", new Object[] {});
            }
        });
        encoder.setPersistenceDelegate(Child.class, new PersistenceDelegate() {
            protected Expression instantiate(Object old, Encoder out) {
                Child child = (Child) old;
                return new Expression(old, child.getParent(), "create", new Object[] {});
            }
        });
View Full Code Here

    private static void test(Class<?> type, PersistenceDelegate pd) {
        Encoder encoder1 = new Encoder();
        Encoder encoder2 = new XMLEncoder(System.out);

        PersistenceDelegate pd1 = encoder1.getPersistenceDelegate(type);
        PersistenceDelegate pd2 = encoder2.getPersistenceDelegate(type);

        encoder1.setPersistenceDelegate(type, pd);

        if (pd1 == encoder1.getPersistenceDelegate(type))
            throw new Error("first persistence delegate is not changed");
View Full Code Here

    }

    protected void initialize(XMLEncoder encoder) {
        encoder.setPersistenceDelegate(
                ImmutableList.class,
                new PersistenceDelegate() {
                    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
                        return oldInstance.equals(newInstance);
                    }

                    protected Expression instantiate(Object oldInstance, Encoder out) {
View Full Code Here

        for (int i = 0; i < obs.length; i++) {
            obs[i] = new int[1000];
        }
        System.gc();
        System.gc();
        PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class);
        if (!(pd instanceof MyPersistenceDelegate))
            throw new Error("persistence delegate has been lost");
    }
View Full Code Here

        Component component = new Component();
        return component.create(component);
    }

    protected void initialize(XMLEncoder encoder) {
        encoder.setPersistenceDelegate(Container.class, new PersistenceDelegate() {
            protected Expression instantiate(Object oldInstance, Encoder out) {
                Container container = (Container) oldInstance;
                Component component = container.getComponent();
                return new Expression(container, component, "create", new Object[] {component});
            }
View Full Code Here

            e.setExceptionListener(new ExceptionListener() {
                public void exceptionThrown(Exception e) {
                    throw new EmsException("Could not encode connection settings",e);
                }
            });
            e.setPersistenceDelegate(File.class,new PersistenceDelegate() {
                protected Expression instantiate(Object oldInstance, Encoder out) {
                    File f = (File) oldInstance;
                    return new Expression(oldInstance, oldInstance.getClass(),"new", new Object[]{ f.getAbsolutePath() });
                }
View Full Code Here

        }
    }

    @Override
    public PersistenceDelegate find(Class<?> type) {
        PersistenceDelegate delegate;
        synchronized (this.registry) {
            delegate = this.registry.get(type);
        }
        return (delegate != null) ? delegate : super.find(type);
    }
View Full Code Here

TOP

Related Classes of java.beans.PersistenceDelegate

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.