Package org.openrdf.sail

Examples of org.openrdf.sail.Sail


        this.kiwiConfig = kiwiConfig;
    }
   
    @Override
    protected Sail createSail() throws SailException {
        Sail store = new SailWrapper(new KiWiStore(kiwiConfig)) {
            @Override
            public void shutDown() throws SailException {
                try {
                    ((KiWiStore)getBaseSail()).getPersistence().dropDatabase();
                } catch (SQLException e) {
View Full Code Here


     * @see org.openrdf.repository.RepositoryConnectionTest#createRepository()
     */
    @Override
    protected Repository createRepository() throws Exception {
        config.setDefaultContext(null);
        Sail store = new SailWrapper(new KiWiStore(config)) {
            @Override
            public void shutDown() throws SailException {
                try {
                    ((KiWiStore)getBaseSail()).getPersistence().dropDatabase();
                } catch (SQLException e) {
View Full Code Here

        final KiWiStore sail = new KiWiStore(config);
        KiWiTransactionalSail tsail = new KiWiTransactionalSail(sail);
        rsail = new KiWiReasoningSail(tsail, new ReasoningConfiguration());

        Sail wsail = new SailWrapper(rsail) {
            @Override
            public void shutDown() throws SailException {
                rsail.getEngine().shutdown(true);

                try {
View Full Code Here

                    log.info("- notifying plugin: {} (DISABLED)", provider.getName());
                }
            }

            // wrap all standard sails
            Sail standardSail = notifyingSail;
            for(StandardSailProvider provider : standardSailProviders) {
                if(provider.isEnabled()) {
                    log.info("- standard plugin: {}",provider.getName());
                    standardSail = provider.createSail(standardSail);
                } else {
View Full Code Here

                public void statementRemoved(Statement statement) {
                    // Do nothing.
                }
            };

            Sail baseSail = TweetStore.createSail();
            NotifyingSail b;
            if (baseSail instanceof NotifyingSail) {
                b = (NotifyingSail) baseSail;
            } else {
                b = new NotifyingSailWrapper();
View Full Code Here

    }

    private void start(final Factory<SailConnectionListener> factory) throws Exception {
        NotifyingSail baseSail = new MemoryStore();
        baseSail.initialize();
        Sail sail = new QueueingSail(baseSail, factory.create());

        try {
            // Create a persistent store.
            TweetStore store = new TweetStore(sail);
            store.setSailConnectionListenerFactory(factory);
            store.doNotRefreshCoreMetadata();
            store.initialize();

            try {
                // Create a client for communication with Twitter.
                CustomTwitterClient client = new CustomTwitterClient();

                Set<User> users = TwitLogic.findFollowList(client);
                Set<String> terms = TwitLogic.findTrackTerms();

                final Handler<Tweet> annotator
                        = createAnnotator(store, client);

                final SailConnection c = sail.getConnection();
                //c.addConnectionListener(listener);

                try {
                    Handler<Tweet> adder = new Handler<Tweet>() {
                        public boolean isOpen() {
                            return !closed && annotator.isOpen();
                        }

                        public void handle(final Tweet tweet) throws HandlerException {
                            try {
                                c.clear();
                                c.commit();
                                c.begin();
                            } catch (SailException e) {
                                throw new HandlerException(e);
                            }

                            annotator.handle(tweet);
                        }
                    };

                    // Can't use a deleter here.
                    NullHandler<Tweet> d = new NullHandler<Tweet>();

                    // TODO: optionally gather historical tweets

                    TweetReceivedLogger rLogger = new TweetReceivedLogger(client.getStatistics(), adder);

                    if (0 < users.size() || 0 < terms.size()) {
                        client.processFilterStream(users, terms, null, rLogger, d, 0);
                    } else {
                        client.processSampleStream(rLogger, d);
                    }
                } finally {
                    c.close();
                }
            } finally {
                store.shutDown();
            }
        } finally {
            sail.shutDown();
        }
    }
View Full Code Here

    }

    private JSONArray relatedTagsJSON(final Resource resource,
                                      final int limit,
                                      final int steps) throws SailException, HandlerException, JSONException {
        Sail baseSail = sail instanceof MappingSail
                ? ((MappingSail) sail).getBaseSail()
                : sail;

        Collection<Resource> results;

        SailConnection sc = baseSail.getConnection();
        try {
            sc.begin();
            //System.out.println("resource (really): " + resource);
            RelatedHashtagsInferencer inf = new RelatedHashtagsInferencer(sc, resource);
            int used = inf.compute(steps);
View Full Code Here

        response.setEntity(represent(query, args));
    }

    private String alternativesQuery(final Resource resource,
                                     final String after) throws SailException, HandlerException {
        Sail baseSail = sail instanceof MappingSail
                ? ((MappingSail) sail).getBaseSail()
                : sail;

        //SailConnection sc = sail.getConnection();
        SailConnection sc = baseSail.getConnection();
        try {
            sc.begin();
            //System.out.println("resource (really): " + resource);
            ConferenceInferencer inf = new ConferenceInferencer(sc, resource);
            int steps = 150;
View Full Code Here

        System.out.println("For more information, please see:\n"
                + "  <URL:http://wiki.github.com/joshsh/twitlogic/configuring-and-running-twitlogic>.");
    }

    private void run() throws Exception {
        Sail workingSail = new MemoryStore();
        workingSail.initialize();

        try {
            Sail streamingSail = new MockUdpTransactionSail(workingSail);

            try {
                TweetStore store = new TweetStore(streamingSail);
                store.doNotRefreshCoreMetadata();
                store.initialize();

                try {
                    // A connection with which to repeatedly clear the working store
                    final SailConnection c = workingSail.getConnection();

                    try {
                        c.begin();
                        // Offline persister
                        final TweetPersister persister = new TweetPersister(store, null);

                        try {
                            CustomTwitterClient client = new CustomTwitterClient();

                            TweetPersistedLogger pLogger = new TweetPersistedLogger(client.getStatistics(), persister);

                            // Add a "topic sniffer".
                            TopicSniffer topicSniffer = new TopicSniffer(pLogger);

                            // Add a tweet annotator.
                            Matcher matcher = new MultiMatcher(
                                    new DemoAfterthoughtMatcher());

                            final Handler<Tweet> annotator
                                    = new TweetAnnotator(matcher, topicSniffer);

                            Handler<Tweet> adder = new Handler<Tweet>() {
                                public boolean isOpen() {
                                    return annotator.isOpen();
                                }

                                public void handle(final Tweet tweet) throws HandlerException {
                                    try {
                                        c.clear();
                                        c.commit();
                                        c.begin();
                                    } catch (SailException e) {
                                        throw new HandlerException(e);
                                    }

                                     annotator.handle(tweet);
                                }
                            };
                            Handler<Tweet> deleter = new TweetDeleter(store);

                            TweetReceivedLogger rLogger = new TweetReceivedLogger(client.getStatistics(), adder);

                            client.processSampleStream(rLogger, deleter);
                        } finally {
                            persister.close();
                        }
                    } finally {
                        c.rollback();
                        c.close();
                    }
                } finally {
                    store.shutDown();
                }
            } finally {
                streamingSail.shutDown();
            }
        } finally {
            workingSail.shutDown();
        }
    }
View Full Code Here

    public Sail makeSail() throws SailException, PropertyException {
        File dir = conf.getFile(TwitLogic.NATIVESTORE_DIRECTORY);
        String indexes = conf.getString(TwitLogic.NATIVESTORE_INDEXES, null);

        LOGGER.info("instantiating NativeStore in directory: " + dir);
        Sail sail = (null == indexes)
                ? new NativeStore(dir)
                : new NativeStore(dir, indexes.trim());
        sail.initialize();

        return sail;
    }
View Full Code Here

TOP

Related Classes of org.openrdf.sail.Sail

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.