Package org.fluxtream.core.connectors.annotations

Examples of org.fluxtream.core.connectors.annotations.Updater


    private static void extractConnectorMetadata(final BeanDefinition bd) {
        String beanClassName = bd.getBeanClassName();
        String connectorName = getConnectorName(beanClassName);
        Connector connector = new Connector();
        connector.updaterClass = getUpdaterClass(beanClassName);
        Updater updaterAnnotation = connector.updaterClass
                .getAnnotation(Updater.class);
        // set connectors' pretty name
        connector.prettyName = updaterAnnotation.prettyName();
        connector.deviceNickname = updaterAnnotation.deviceNickname().equals(Updater.DEVICE_NICKNAME_NONE)
                                 ? updaterAnnotation.prettyName()==null ? connectorName : updaterAnnotation.prettyName()
                                 : updaterAnnotation.deviceNickname();
        connector.value = updaterAnnotation.value();
        connector.updateStrategyType = updaterAnnotation
                .updateStrategyType();
        connector.hasFacets = updaterAnnotation.hasFacets();
        connector.name = connectorName;
        connector.sharedConnectorFilterClass = updaterAnnotation.sharedConnectorFilter();
        connector.deleteOrder = updaterAnnotation.deleteOrder();
        // set connectors' object types
        Class<? extends AbstractFacet>[] facetTypes = updaterAnnotation
                .objectTypes();
        if (updaterAnnotation.extractor() != AbstractFacetExtractor.class)
            connector.extractorClass = updaterAnnotation.extractor();
        if (facetTypes.length == 1) {
            connector.facetClass = facetTypes[0];
        }
        if (updaterAnnotation.userProfile() != AbstractUserProfile.class)
            connector.userProfileClass = updaterAnnotation
                    .userProfile();
        connector.defaultChannels = updaterAnnotation.defaultChannels();
        List<ObjectType> connectorObjectTypes = new ArrayList<ObjectType>();
        for (Class<? extends AbstractFacet> facetType : facetTypes) {
            final ObjectType objectType = getFacetTypeMetadata(connector, facetTypes, facetType);
            connectorObjectTypes.add(objectType);
            ObjectType.addObjectType(objectType.name(), connector, objectType);
        }

        if (connectorObjectTypes.size()>0)
            connector.objectTypes = connectorObjectTypes.toArray(new ObjectType[0]);

        connectors.put(connectorName, connector);
        connectorsByValue.put(connector.value(), connector);
        connectorsByDeviceNickname.put(connector.deviceNickname, connector);
        if (connector.prettyName != null) {
            connectorsByPrettyName.put(connector.prettyName.toLowerCase(), connector);
        }
        connector.bodytrackResponder = updaterAnnotation.bodytrackResponder();

    }
View Full Code Here


    @Override
    @Transactional(readOnly=false)
    public void saveConnectorSettings(final long apiKeyId, final String json) {
        ApiKey apiKey = guestService.getApiKey(apiKeyId);
        final Updater updaterAnnotation = apiKey.getConnector().getUpdaterClass().getAnnotation(Updater.class);
        StringBuilder sb = new StringBuilder("module=connectors component=settingsServiceImpl action=saveConnectorSettings")
                .append(" apiKeyId=").append(apiKeyId);
        if (updaterAnnotation.settings()==Updater.EmptySettings.class){
            logger.warn(sb.append(" message=\"no settings class has been specified for \"" + apiKey.getConnector().getName()));
            return;
        }
        try {
            final Object settings = gson.fromJson(json, updaterAnnotation.settings());
            guestService.setApiKeySettings(apiKeyId, settings);
            final AbstractUpdater updater = beanFactory.getBean(apiKey.getConnector().getUpdaterClass());
            ((SettingsAwareUpdater)updater).connectorSettingsChanged(apiKeyId, settings);
        }
        catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.fluxtream.core.connectors.annotations.Updater

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.