Package org.apache.geronimo.kernel.proxy

Examples of org.apache.geronimo.kernel.proxy.ProxyManager


    }

    public Object getContent() throws IllegalStateException {
        Kernel kernel = getKernel();
        // todo HACK: this is a very bad idea
        ProxyManager proxyManager = kernel.getProxyManager();
        return proxyManager.createProxy(target, type);
    }
View Full Code Here


        GBeanData gbean = new GBeanData(name, MockGBean.getGBeanInfo());
        gbean.setAttribute("name", "Test");
        gbean.setAttribute("finalInt", new Integer(123));
        kernel.loadGBean(gbean, myCl);
        kernel.startGBean(name);
        ProxyManager mgr = kernel.getProxyManager();

        Object test = mgr.createProxy(name, myCl);
        assertTrue(test instanceof MockEndpoint);
        assertTrue(test instanceof MockParentInterface1);
        assertTrue(test instanceof MockParentInterface2);
        assertTrue(test instanceof MockChildInterface1);
        assertTrue(test instanceof MockChildInterface2);
        assertFalse(test instanceof Comparable);
        ((MockEndpoint)test).doNothing();
        assertEquals("Foo", ((MockEndpoint)test).echo("Foo"));
        ((MockParentInterface1)test).setValue("Foo");
        assertEquals("Foo", ((MockParentInterface1)test).getValue());
        ((MockParentInterface1)test).setMutableInt(6);
        assertEquals(6, ((MockParentInterface1)test).getMutableInt());
        ((MockParentInterface2)test).doNothing();
        assertEquals("Foo", ((MockParentInterface2)test).echo("Foo"));
        ((MockParentInterface2)test).setValue("Foo");
        assertEquals("Foo", ((MockParentInterface2)test).getValue());
        ((MockChildInterface1)test).getFinalInt();
        ((MockChildInterface2)test).doNothing();
        assertEquals("Foo", ((MockChildInterface2)test).doSomething("Foo"));

        test = mgr.createProxy(name, MockEndpoint.class);
        assertTrue(test instanceof MockEndpoint);
        assertFalse(test instanceof MockParentInterface1);
        assertFalse(test instanceof MockParentInterface2);
        assertFalse(test instanceof MockChildInterface1);
        assertFalse(test instanceof MockChildInterface2);
        assertFalse(test instanceof Comparable);

        test = mgr.createProxy(name, MockEndpoint.class, new Class[]{MockParentInterface2.class, MockChildInterface2.class});
        assertTrue(test instanceof MockEndpoint);
        assertTrue(test instanceof MockParentInterface1);
        assertTrue(test instanceof MockParentInterface2);
        assertTrue(test instanceof MockChildInterface1);
        assertTrue(test instanceof MockChildInterface2);
        assertFalse(test instanceof Comparable);

        test = mgr.createProxy(name, MockEndpoint.class, new Class[]{MockParentInterface1.class, MockChildInterface1.class});
        assertTrue(test instanceof MockEndpoint);
        assertTrue(test instanceof MockParentInterface1);
        assertFalse(test instanceof MockParentInterface2);
        assertTrue(test instanceof MockChildInterface1);
        assertFalse(test instanceof MockChildInterface2);
        assertFalse(test instanceof Comparable);

        test = mgr.createProxy(name, MockEndpoint.class, new Class[]{MockParentInterface1.class, MockChildInterface1.class, Comparable.class});
        assertTrue(test instanceof MockEndpoint);
        assertTrue(test instanceof MockParentInterface1);
        assertFalse(test instanceof MockParentInterface2);
        assertTrue(test instanceof MockChildInterface1);
        assertFalse(test instanceof MockChildInterface2);
        assertFalse(test instanceof Comparable);

        test = mgr.createProxy(name, null, new Class[]{MockParentInterface1.class, MockChildInterface1.class, Comparable.class});
        assertFalse(test instanceof MockEndpoint);
        assertTrue(test instanceof MockParentInterface1);
        assertFalse(test instanceof MockParentInterface2);
        assertTrue(test instanceof MockChildInterface1);
        assertFalse(test instanceof MockChildInterface2);
        assertFalse(test instanceof Comparable);

        test = mgr.createProxy(name, MockEndpoint.class, new Class[]{Comparable.class});
        assertTrue(test instanceof MockEndpoint);
        assertFalse(test instanceof MockParentInterface1);
        assertFalse(test instanceof MockParentInterface2);
        assertFalse(test instanceof MockChildInterface1);
        assertFalse(test instanceof MockChildInterface2);
        assertFalse(test instanceof Comparable);

        test = mgr.createProxy(name, null, new Class[]{Comparable.class}); // no implementable interface
        assertNull(test);

        try {
            test = mgr.createProxy(name, null, new Class[0]); // no interface
            fail();
        }catch(IllegalArgumentException e) {}

        try {
            test = mgr.createProxy(name, null, null); // no interface
            fail();
        }catch(IllegalArgumentException e) {}

        test = mgr.createProxy(name, MockGBean.class, null); // class not interface
        test = mgr.createProxy(name, MockGBean.class, new Class[]{MockEndpoint.class}); // class and interface

        if(mgr instanceof BasicProxyManager) {
            try { // two classes
                test = ((BasicProxyManager)mgr).createProxyFactory(new Class[]{MockGBean.class, Object.class}).createProxy(name);
                fail();
View Full Code Here

    /**
     * Gets the network containers.
     */
    public Object[] getContainers() {
        ProxyManager proxyManager = kernel.getProxyManager();
        AbstractNameQuery query = new AbstractNameQuery(TomcatWebContainer.class.getName());
        Set names = kernel.listGBeans(query);
        TomcatWebContainer[] results = new TomcatWebContainer[names.size()];
        int i=0;
        for (Iterator it = names.iterator(); it.hasNext(); i++) {
            AbstractName name = (AbstractName) it.next();
            results[i] = (TomcatWebContainer) proxyManager.createProxy(name, TomcatWebContainer.class.getClassLoader());
        }
        return results;
    }
View Full Code Here

    public NetworkConnector[] getConnectors(String protocol) {
        if(protocol == null) {
            return getConnectors();
        }
        List<TomcatWebConnector> result = new ArrayList<TomcatWebConnector>();
        ProxyManager proxyManager = kernel.getProxyManager();
        AbstractNameQuery query = new AbstractNameQuery(TomcatWebConnector.class.getName());
        Set<AbstractName> names = kernel.listGBeans(query);
        for (AbstractName name : names) {
            try {
                if (kernel.getAttribute(name, "protocol").equals(protocol)) {
                    result.add((TomcatWebConnector)proxyManager.createProxy(name, TomcatWebConnector.class.getClassLoader()));
                }
            } catch (Exception e) {
                log.error("Unable to check the protocol for a connector", e);
            }
        }
View Full Code Here

    /**
     * Gets the ObjectNames of any existing connectors associated with this network technology.
     */
    public NetworkConnector[] getConnectors() {
        ProxyManager proxyManager = kernel.getProxyManager();
        AbstractNameQuery query = new AbstractNameQuery(TomcatWebConnector.class.getName());
        Set names = kernel.listGBeans(query);
        TomcatWebConnector[] results = new TomcatWebConnector[names.size()];
        int i=0;
        for (Iterator it = names.iterator(); it.hasNext(); i++) {
            AbstractName name = (AbstractName) it.next();
            results[i] = (TomcatWebConnector) proxyManager.createProxy(name, TomcatWebConnector.class.getClassLoader());
        }
        return results;
    }
View Full Code Here

    public NetworkConnector[] getConnectorsForContainer(Object container, String protocol) {
        if(protocol == null) {
            return getConnectorsForContainer(container);
        }
        AbstractName containerName = kernel.getAbstractNameFor(container);
        ProxyManager mgr = kernel.getProxyManager();
        try {
            List results = new ArrayList();
            AbstractNameQuery query = new AbstractNameQuery(TomcatWebConnector.class.getName());
            Set set = kernel.listGBeans(query); // all Tomcat connectors
            for (Iterator it = set.iterator(); it.hasNext();) {
                AbstractName name = (AbstractName) it.next(); // a single Tomcat connector
                GBeanData data = kernel.getGBeanData(name);
                ReferencePatterns refs = data.getReferencePatterns(ConnectorGBean.CONNECTOR_CONTAINER_REFERENCE);
                if(containerName.equals(refs.getAbstractName())) {
                    try {
                        String testProtocol = (String) kernel.getAttribute(name, "protocol");
                        if(testProtocol != null && testProtocol.equals(protocol)) {
                            results.add(mgr.createProxy(name, TomcatWebConnector.class.getClassLoader()));
                        }
                    } catch (Exception e) {
                        log.error("Unable to look up protocol for connector '"+name+"'",e);
                    }
                    break;
View Full Code Here

    /**
     * Gets the ObjectNames of any existing connectors for the specified container.
     */
    public NetworkConnector[] getConnectorsForContainer(Object container) {
        AbstractName containerName = kernel.getAbstractNameFor(container);
        ProxyManager mgr = kernel.getProxyManager();
        try {
            List results = new ArrayList();
            AbstractNameQuery query = new AbstractNameQuery(TomcatWebConnector.class.getName());
            Set set = kernel.listGBeans(query); // all Tomcat connectors
            for (Iterator it = set.iterator(); it.hasNext();) {
                AbstractName name = (AbstractName) it.next(); // a single Tomcat connector
                GBeanData data = kernel.getGBeanData(name);
                ReferencePatterns refs = data.getReferencePatterns(ConnectorGBean.CONNECTOR_CONTAINER_REFERENCE);
                if (containerName.equals(refs.getAbstractName())) {
                    results.add(mgr.createProxy(name, TomcatWebConnector.class.getClassLoader()));
                }
            }
            return (TomcatWebConnector[]) results.toArray(new TomcatWebConnector[results.size()]);
        } catch (Exception e) {
            throw (IllegalArgumentException) new IllegalArgumentException("Unable to look up connectors for Tomcat container '"+containerName).initCause(e);
View Full Code Here

    /**
     * Gets the network containers.
     */
    public Object[] getContainers() {
        ProxyManager proxyManager = kernel.getProxyManager();
        AbstractNameQuery query = new AbstractNameQuery(TomcatWebContainer.class.getName());
        Set names = kernel.listGBeans(query);
        TomcatWebContainer[] results = new TomcatWebContainer[names.size()];
        int i=0;
        for (Iterator it = names.iterator(); it.hasNext(); i++) {
            AbstractName name = (AbstractName) it.next();
            results[i] = (TomcatWebContainer) proxyManager.createProxy(name, TomcatWebContainer.class.getClassLoader());
        }
        return results;
    }
View Full Code Here

    public NetworkConnector[] getConnectors(String protocol) {
        if(protocol == null) {
            return getConnectors();
        }
        List result = new ArrayList();
        ProxyManager proxyManager = kernel.getProxyManager();
        AbstractNameQuery query = new AbstractNameQuery(TomcatWebConnector.class.getName());
        Set names = kernel.listGBeans(query);
        for (Iterator it = names.iterator(); it.hasNext();) {
            AbstractName name = (AbstractName) it.next();
            try {
                if (kernel.getAttribute(name, "protocol").equals(protocol)) {
                    result.add(proxyManager.createProxy(name, TomcatWebConnector.class.getClassLoader()));
                }
            } catch (Exception e) {
                log.error("Unable to check the protocol for a connector", e);
            }
        }
View Full Code Here

    /**
     * Gets the ObjectNames of any existing connectors associated with this network technology.
     */
    public NetworkConnector[] getConnectors() {
        ProxyManager proxyManager = kernel.getProxyManager();
        AbstractNameQuery query = new AbstractNameQuery(TomcatWebConnector.class.getName());
        Set names = kernel.listGBeans(query);
        TomcatWebConnector[] results = new TomcatWebConnector[names.size()];
        int i=0;
        for (Iterator it = names.iterator(); it.hasNext(); i++) {
            AbstractName name = (AbstractName) it.next();
            results[i] = (TomcatWebConnector) proxyManager.createProxy(name, TomcatWebConnector.class.getClassLoader());
        }
        return results;
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.kernel.proxy.ProxyManager

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.