Package net.sf.cglib.proxy

Examples of net.sf.cglib.proxy.Enhancer.create()


        throws NullPointerException, MalformedURLException {
        final Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(HashMap.class);
        enhancer.setCallback(new DelegatingHandler(new HashMap()));
        enhancer.setUseFactory(true); // true by default
        final Map orig = (Map)enhancer.create();
        final URL url = new URL("http://xstream.codehaus.org");
        orig.put("URL", url);
        final String xml = ""
            + "<CGLIB-enhanced-proxy>\n"
            + "  <type>java.util.HashMap</type>\n"
View Full Code Here


        throws NullPointerException, MalformedURLException {
        final Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(HashMap.class);
        enhancer.setCallback(new DelegatingHandler(new HashMap()));
        enhancer.setUseFactory(false);
        final Map orig = (Map)enhancer.create();
        final URL url = new URL("http://xstream.codehaus.org");
        orig.put("URL", url);
        final String xml = ""
            + "<CGLIB-enhanced-proxy>\n"
            + "  <type>java.util.HashMap</type>\n"
View Full Code Here

        throws NullPointerException {
        final Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(HashMap.class);
        enhancer.setCallback(NoOp.INSTANCE);
        enhancer.setInterfaces(new Class[]{Runnable.class});
        final Map orig = (Map)enhancer.create();
        final String xml = ""
            + "<CGLIB-enhanced-proxy>\n"
            + "  <type>java.util.HashMap</type>\n"
            + "  <interfaces>\n"
            + "    <java-class>java.lang.Runnable</java-class>\n"
View Full Code Here

    public void testSupportsProxiesWithMultipleInterfaces() throws NullPointerException {
        final Enhancer enhancer = new Enhancer();
        enhancer.setCallback(NoOp.INSTANCE);
        enhancer.setInterfaces(new Class[]{Map.class, Runnable.class});
        final Map orig = (Map)enhancer.create();
        final String xml = ""
            + "<CGLIB-enhanced-proxy>\n"
            + "  <type>java.lang.Object</type>\n"
            + "  <interfaces>\n"
            + "    <java-class>java.util.Map</java-class>\n"
View Full Code Here

                return i < 3 ? i++ : i;
            }
        });
        enhancer.setInterfaces(new Class[]{Runnable.class});
        enhancer.setUseFactory(true);
        final Runnable orig = (Runnable)enhancer.create();
        final String xml = xstream.toXML(orig);
        final Factory deserialized = (Factory)xstream.fromXML(xml);
        assertTrue("Not a Runnable anymore", deserialized instanceof Runnable);
        Callback[] callbacks = deserialized.getCallbacks();
        assertEquals(4, callbacks.length);
View Full Code Here

                return i < 3 ? i++ : i;
            }
        });
        enhancer.setInterfaces(new Class[]{Runnable.class});
        enhancer.setUseFactory(false);
        final Runnable orig = (Runnable)enhancer.create();
        try {
            xstream.toXML(orig);
            fail("Thrown " + ConversionException.class.getName() + " expected");
        } catch (final ConversionException e) {
           
View Full Code Here

    public void testSupportProxiesWithMultipleCallbackSetToNull() throws NullPointerException {
        final Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(HashMap.class);
        enhancer.setCallback(NoOp.INSTANCE);
        final HashMap orig = (HashMap)enhancer.create();
        ((Factory)orig).setCallback(0, null);
        final String xml = ""
            + "<CGLIB-enhanced-proxy>\n"
            + "  <type>java.util.HashMap</type>\n"
            + "  <interfaces/>\n"
View Full Code Here

        throws NullPointerException, NoSuchFieldException, IllegalAccessException {
        final Enhancer enhancer = new Enhancer();
        enhancer.setCallback(NoOp.INSTANCE);
        enhancer.setInterfaces(new Class[]{Runnable.class});
        enhancer.setSerialVersionUID(new Long(20060804L));
        final Runnable orig = (Runnable)enhancer.create();
        final String xml = ""
            + "<CGLIB-enhanced-proxy>\n"
            + "  <type>java.lang.Object</type>\n"
            + "  <interfaces>\n"
            + "    <java-class>java.lang.Runnable</java-class>\n"
View Full Code Here

        throws NullPointerException, MalformedURLException {
        final Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(HashMap.class);
        enhancer.setCallback(new InterceptingHandler());
        enhancer.setUseFactory(true);
        final Map orig = (Map)enhancer.create();
        orig.put("URL", new URL("http://xstream.codehaus.org"));
        final StringBuffer xml = new StringBuffer(""
            + "<CGLIB-enhanced-proxy>\n"
            + "  <type>java.util.HashMap</type>\n"
            + "  <interfaces/>\n"
View Full Code Here

        ClassWithProxyMember expected = new ClassWithProxyMember();
        xstream.alias("with-proxy", ClassWithProxyMember.class);
        final Enhancer enhancer = new Enhancer();
        enhancer.setCallback(NoOp.INSTANCE);
        enhancer.setInterfaces(new Class[]{Map.class, Runnable.class});
        final Map orig = (Map)enhancer.create();
        expected.runnable = (Runnable)orig;
        expected.map = orig;
        final String xml = ""
            + "<with-proxy>\n"
            + "  <runnable class=\"CGLIB-enhanced-proxy\">\n"
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.