Package org.openengsb.core.api

Examples of org.openengsb.core.api.Connector


        DomainProvider authDomainProvider = createDomainProviderMock(AuthorizationDomain.class, "authorization");
        CompositeConnectorProvider compositeConnectorProvider = new CompositeConnectorProvider();
        compositeConnectorProvider.setBundleContext(bundleContext);
        ConnectorInstanceFactory cFactory = compositeConnectorProvider.createFactory(authDomainProvider);
        Connector instance = cFactory.createNewInstance("auth-admin");
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put("composite.strategy.name", "authorization");
        AffirmativeBasedAuthorizationStrategy service = new AffirmativeBasedAuthorizationStrategy();
        service.setUtilsService(serviceUtils);
        registerService(service, props, CompositeConnectorStrategy.class);
View Full Code Here


            String... domains) throws Exception {
        ConnectorInstanceFactory factory = mock(ConnectorInstanceFactory.class);
        when(factory.createNewInstance(anyString())).thenAnswer(new Answer<Connector>() {
            @Override
            public Connector answer(InvocationOnMock invocation) throws Throwable {
                Connector result = mock(connectorClass);
                String id = (String) invocation.getArguments()[0];
                when(result.getInstanceId()).thenReturn(id);
                return result;
            }
        });
        when(factory.applyAttributes(any(Connector.class), anyMap())).thenAnswer(new Answer<Connector>() {
            @Override
View Full Code Here

    @Override
    public Connector createNewInstance(String id) {
        VirtualType handler = createNewHandler(id);
        Set<Class<?>> interfaces = Collections.emptySet();
        Connector newProxyInstance = createProxy(handler, interfaces);
        handlers.put(newProxyInstance, handler);
        return newProxyInstance;
    }
View Full Code Here

        finishCreatingInstance(id, description, factory);
    }

    private void finishCreatingInstance(String id, ConnectorDescription description,
            ConnectorInstanceFactory factory) {
        Connector serviceInstance = factory.createNewInstance(id.toString());
        if (serviceInstance == null) {
            throw new IllegalStateException("Factory cannot create a new service for instance id " + id.toString());
        }
        serviceInstance = factory.applyAttributes(serviceInstance, description.getAttributes());
        if (!description.getAttributes().containsKey(Constants.SKIP_SET_DOMAIN_TYPE)) {
            serviceInstance.setDomainId(description.getDomainType());
            serviceInstance.setConnectorId(description.getConnectorType());
        }
        instances.put(id, serviceInstance);
        doRegisterServiceInstance(id, description, serviceInstance);
    }
View Full Code Here

            registrations.get(id).unregister();
            registrations.remove(id);
        }
        Class<? extends Domain> domainInterface = getDomainProvider(description.getDomainType()).getDomainInterface();
        Class<?>[] clazzes = generateInterfaceListForRegistration(domainInterface, serviceInstance);
        Connector proxiedInstance = proxyForTransformation(serviceInstance, domainInterface, clazzes);
        proxiedInstance = proxyForSecurity(id, description, proxiedInstance, clazzes);
        Map<String, Object> properties = populatePropertiesWithRequiredAttributes(id, description);
        ServiceRegistration serviceRegistration =
                bundleContext.registerService(convertClassesToNames(clazzes), proxiedInstance,
                        MapAsDictionary.wrap(properties));
View Full Code Here

        // @extract-start register-secure-service-code
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.setInterfaces(clazzes);
        proxyFactory.addAdvice(securityInterceptor);
        proxyFactory.setTarget(serviceInstance);
        Connector result = (Connector) proxyFactory.getProxy(this.getClass().getClassLoader());
        // @extract-end
        attributeStore.replaceAttributes(serviceInstance, new SecurityAttributeEntry("name", id));
        return result;
    }
View Full Code Here

        return result;
    }

    private void forceUpdateAttributes(String id, ConnectorDescription description) {
        ConnectorInstanceFactory factory = getConnectorFactoryForDescription(description);
        Connector current = instances.get(id);
        doUpdateAttributes(id, description, factory, current);
    }
View Full Code Here

    }

    private void updateAttributes(String id, ConnectorDescription description)
        throws ConnectorValidationFailedException {
        ConnectorInstanceFactory factory = getConnectorFactoryForDescription(description);
        Connector current = instances.get(id);
        Map<String, String> validationErrors = factory.getValidationErrors(current, description.getAttributes());
        if (!validationErrors.isEmpty()) {
            throw new ConnectorValidationFailedException(validationErrors);
        }
        doUpdateAttributes(id, description, factory, current);
View Full Code Here

        doUpdateAttributes(id, description, factory, current);
    }

    private void doUpdateAttributes(String id, ConnectorDescription description,
            ConnectorInstanceFactory factory, Connector current) {
        Connector connector = factory.applyAttributes(current, description.getAttributes());
        if (connector != current) {
            instances.put(id, connector);
            doRegisterServiceInstance(id, description, connector);
        }
    }
View Full Code Here

    }

    @Test
    public void testRegisterConnectorWithSameNameAfterRemoved_shouldNotFail() throws Exception {
        createDomainProviderMock(NullDomain.class, "a");
        Connector connectorMock = mock(Connector.class);
        when(connectorInstanceFactory.createNewInstance(anyString())).thenReturn(connectorMock);
        when(connectorInstanceFactory.applyAttributes(any(Connector.class), anyMap()))
                .thenAnswer(new Answer<Connector>() {
                    @Override
                    public Connector answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.Connector

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.