Package org.apache.hivemind.definition

Examples of org.apache.hivemind.definition.ServicePointDefinition


            String servicePointId = unresolved.getExtensionPointId();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Trying to resolve service point " + servicePointId + " referenced by" +
                        " interceptor" + logLocation(unresolved.getExtension().getLocation()));
            }
            ServicePointDefinition servicePoint = _definition.getServicePoint(servicePointId);
            if (servicePoint == null)
            {
                _errorHandler.error(
                        LOG,
                        DefinitionMessages.unknownServicePoint(
                                IdUtils.extractModule(servicePointId),
                                IdUtils.stripModule(servicePointId)),
                        unresolved.getExtension().getLocation(),
                        null);
            } else {
                servicePoint.addInterceptor((InterceptorDefinition) unresolved.getExtension());
            }
            iter.remove();
        }
    }
View Full Code Here


    private Registry createRegistryWithInterceptedService(String serviceName, String serviceInterface, String implementationClass,
            final List interceptedMethods)
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
        ServicePointDefinition sp = helper.addServicePoint(serviceName, serviceInterface);
        helper.addSimpleServiceImplementation(sp, implementationClass, ServiceModel.SINGLETON);
       
        // Add logging interceptor
        InterceptorConstructor constructor = new AbstractServiceInterceptorConstructor(module.getLocation()) {

            public void constructServiceInterceptor(InterceptorStack interceptorStack, Module contributingModule)
            {
                ClassFactory cf = (ClassFactory) contributingModule.getService(ClassFactory.class);
                // Create the interceptor with the LoggingInterceptorClassFactory which is quite uncomfortable
                // in the moment
                LoggingInterceptorClassFactory f = new LoggingInterceptorClassFactory(cf);
                Class interceptorClass = f.constructInterceptorClass(interceptorStack, Collections.EMPTY_LIST);
                Constructor c = interceptorClass.getConstructors()[0];
                Object interceptor;
                try
                {
                    interceptor = c.newInstance(new Object[] { interceptorStack.getServiceLog(), interceptorStack.peek() });
                }
                catch (Exception e) {
                    throw new ApplicationRuntimeException(e);
                }
                interceptorStack.push(interceptor);
            }};
        InterceptorDefinition interceptor = new InterceptorDefinitionImpl(module, "hivemind.LoggingInterceptor", module.getLocation(), constructor);
        sp.addInterceptor(interceptor);
        return buildFrameworkRegistry(module);
    }
View Full Code Here

     */
    private Registry createRegistryWithRecursiveService()
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
        ServicePointDefinition sp = helper.addServicePoint("Recursive", SimpleService.class.getName());

        ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(module.getLocation())
        {
            public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
            {
View Full Code Here

    {
        Collection points = sourceModule.getServicePoints();

        for (Iterator iterSp = points.iterator(); iterSp.hasNext();)
        {
            ServicePointDefinition spd = (ServicePointDefinition) iterSp.next();
           
            // Check type. In case of the hivemind core module non xml service points exist
            if (spd instanceof XmlServicePointDefinitionImpl) {
                XmlServicePointDefinitionImpl xspd = (XmlServicePointDefinitionImpl) spd;
   
                if (xspd.getParametersSchemaId() != null) {
                    ServicePointDefinition point = sourceModule.getServicePoint(xspd.getId());
   
                    XmlServicePointDefinitionImpl xmlServicePoint = (XmlServicePointDefinitionImpl) point;
                    Schema schema = findSchema(sourceModule, xspd.getParametersSchemaId(), xspd.getLocation());
                    if (schema == null) {
                        // Error-Handling has been done in findSchema already
View Full Code Here

    private Registry createRegistry()
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);

        ServicePointDefinition sp1 = helper.addServicePoint("StartupRunnableFixture", StartupRunnableFixture.class.getName());
        helper.addSimpleServiceImplementation(sp1, StartupRunnableFixtureImpl.class.getName(), ServiceModel.SINGLETON);

        // Add service point "StartupRunnableFixture" to Startup configuration point
        helper.addContributionDefinition("hivemind.Startup", new Contribution()
        {
View Full Code Here

            ErrorLog errorLog = servicePoint.getErrorLog();
           
            _factory = (ServiceImplementationFactory) factoryPoint
                .getService(ServiceImplementationFactory.class);

            ServicePointDefinition spd = factoryPoint.getServicePointDefinition();
            if (!(spd instanceof XmlServicePointDefinitionImpl)) {
                // TODO annotations: Externalize message
                throw new ApplicationRuntimeException("ServicePoint used as ServiceImplementationFactory must be of type XmlServicePointDefinitionImpl");
            }
            XmlServicePointDefinitionImpl xmlServicePoint = (XmlServicePointDefinitionImpl) spd;
View Full Code Here

    private Registry createRegistryShutdownListener(Class implementationClass)
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);

        ServicePointDefinition sp1 = helper.addServicePoint("StringHolder", StringHolder.class.getName());
        helper.addSimpleServiceImplementation(sp1, implementationClass.getName(), ServiceModel.THREADED);

        return buildFrameworkRegistry(module);
   
View Full Code Here

    // configuration problem ... but I have no idea why.

    public void testInterceptorSort() throws Exception
    {
        ModuleDefinition module = new SimpleModule();
        ServicePointDefinition servicePoint = module.getServicePoint("Simple");
       
        InterceptorDefinition interceptor1 = new OrderedInterceptorDefinitionImpl(module, "Fred", newLocation(), new TrackerServiceInterceptorConstructor("Fred"), "Barney", null);
        servicePoint.addInterceptor(interceptor1);
        InterceptorDefinition interceptor2 = new OrderedInterceptorDefinitionImpl(module, "Barney", newLocation(), new TrackerServiceInterceptorConstructor("Barney"), null, null);
        servicePoint.addInterceptor(interceptor2);
        InterceptorDefinition interceptor3 = new OrderedInterceptorDefinitionImpl(module, "Wilma", newLocation(), new TrackerServiceInterceptorConstructor("Wilma"), null, "Barney");
        servicePoint.addInterceptor(interceptor3);
       
        Registry r =
            buildFrameworkRegistry(module);

        SimpleService s =
View Full Code Here

    /**
     * Wrapper around Javassist used to dynamically create classes such as service interceptors.
     */
    private void addClassFactory(ModuleDefinition md)
    {
        ServicePointDefinition spd = helper.addServicePoint("ClassFactory", ClassFactory.class.getName());
        helper.addSimpleServiceImplementation(spd, ClassFactoryImpl.class.getName(), ServiceModel.PRIMITIVE);
    }
View Full Code Here

     * Service used by other services to be alerted when a thread is cleaned up (typically, at the
     * end of a request or transaction).
     */
    private void addThreadEventNotifier(ModuleDefinition md)
    {
        ServicePointDefinition spd = helper.addServicePoint(
                "ThreadEventNotifier",
                ThreadEventNotifier.class.getName());
        helper.addSimpleServiceImplementation(
                spd,
                ThreadEventNotifierImpl.class.getName(),
View Full Code Here

TOP

Related Classes of org.apache.hivemind.definition.ServicePointDefinition

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.