Package org.apache.hivemind.internal

Examples of org.apache.hivemind.internal.ServicePoint


     * @since 1.1
     */
    public void testGetServiceMatchesPublicOnly()
    {
        MockControl spc1 = newControl(ServicePoint.class);
        ServicePoint sp1 = (ServicePoint) spc1.getMock();

        MockControl spc2 = newControl(ServicePoint.class);
        ServicePoint sp2 = (ServicePoint) spc2.getMock();

        ObjectProvider service = (ObjectProvider) newMock(ObjectProvider.class);

        // Training

        sp1.getExtensionPointId();
        spc1.setReturnValue("foo.Private");

        sp1.getServiceInterfaceClassName();
        spc1.setReturnValue(ObjectProvider.class.getName());

        sp2.getExtensionPointId();
        spc2.setReturnValue("foo.Public");

        sp2.getServiceInterfaceClassName();
        spc2.setReturnValue(ObjectProvider.class.getName());

        sp1.visibleToModule(null);
        spc1.setReturnValue(false);

        sp2.visibleToModule(null);
        spc2.setReturnValue(true);

        sp2.getService(ObjectProvider.class);
        spc2.setReturnValue(service);

        replayControls();

        RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null);
View Full Code Here


    }

    public void createInterceptor(InterceptorStack stack, Module invokingModule, List parameters)
    {
        ServicePoint servicePoint = invokingModule.getServicePoint(stack
                .getServiceExtensionPointId());
        Set methods = getInterceptedMethods(stack, parameters);
        try
        {
            PerformanceCollector counter = createMBean(servicePoint, methods);
View Full Code Here

    }

    public ServicePoint getServicePoint(String serviceId, Module module)
    {
        checkShutdown();
        ServicePoint result = (ServicePoint) _servicePoints.get(serviceId);
        if (result == null)
        {
            if( serviceId.indexOf( '.' ) == -1 )
            {
                final List possibleMatches = getMatchingServiceIds(serviceId);
                if( !possibleMatches.isEmpty() )
                {
                    final StringBuffer sb = new StringBuffer();
                    for( Iterator i = possibleMatches.iterator(); i.hasNext(); )
                    {
                        final String matching = ( String )i.next();
                        sb.append( '\"' );
                        sb.append( matching );
                        sb.append( '\"' );
                        if( i.hasNext() )
                        {
                            sb.append( ", " );
                        }
                    }
                    throw new ApplicationRuntimeException(ImplMessages.unqualifiedServicePoint(serviceId, sb.toString() ));
                }
            }
            throw new ApplicationRuntimeException(ImplMessages.noSuchServicePoint(serviceId));
        }
           

        if (!result.visibleToModule(module))
            throw new ApplicationRuntimeException(ImplMessages.serviceNotVisible(serviceId, module));

        return result;
    }
View Full Code Here

    private List getMatchingServiceIds(String serviceId)
    {
        final List possibleMatches = new LinkedList();
        for( Iterator i = _servicePoints.values().iterator(); i.hasNext(); )
        {
            final ServicePoint servicePoint = ( ServicePoint )i.next();
            if( servicePoint.getExtensionPointId().equals( servicePoint.getModule().getModuleId() + "." + serviceId ) )
            {
                possibleMatches.add( servicePoint.getExtensionPointId() );
            }
        }
        return possibleMatches;
    }
View Full Code Here

        return possibleMatches;
    }

    public Object getService(String serviceId, Class serviceInterface, Module module)
    {
        ServicePoint point = getServicePoint(serviceId, module);

        return point.getService(serviceInterface);
    }
View Full Code Here

        List servicePoints = (List) _servicePointsByInterfaceClassName.get(key);

        if (servicePoints == null)
            servicePoints = Collections.EMPTY_LIST;

        ServicePoint point = null;
        int count = 0;

        Iterator i = servicePoints.iterator();
        while (i.hasNext())
        {
            ServicePoint sp = (ServicePoint) i.next();

            if (!sp.visibleToModule(module))
                continue;

            point = sp;

            count++;
View Full Code Here

        int count = 0;

        Iterator i = servicePoints.iterator();
        while (i.hasNext())
        {
            ServicePoint point = (ServicePoint) i.next();

            if (point.visibleToModule(module))
                count++;
        }

        return count == 1;
    }
View Full Code Here

    public boolean containsService(String serviceId, Class serviceInterface, Module module)
    {
        checkShutdown();

        ServicePoint point = (ServicePoint) _servicePoints.get(serviceId);

        if (point == null)
            return false;

        return point.visibleToModule(module)
                && point.getServiceInterface().equals(serviceInterface);
    }
View Full Code Here

        checkShutdown();

        String serviceId = token.getServiceId();

        ServicePoint sp = (ServicePoint) _servicePoints.get(serviceId);

        return sp.getService(Object.class);
    }
View Full Code Here

    public Module getModule( String moduleId )
    {
        for( Iterator i = _servicePoints.values().iterator(); i.hasNext(); )
        {
            final ServicePoint servicePoint = ( ServicePoint )i.next();
           
            if( servicePoint.getModule().getModuleId().equals( moduleId ) )
            {
                return servicePoint.getModule();
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.internal.ServicePoint

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.