root/Explorator/trunk/vendor/plugins/active_rdf/lib/active_rdf.rb @ 483

Revision 483, 2.4 KB (checked in by samuraraujo, 8 years ago)
Line 
1
2require 'rubygems'
3
4# ActiveRDF loader
5
6# determine the directory in which we are running depending on cruby or jruby
7if RUBY_PLATFORM =~ /xjava/
8  # jruby can not follow symlinks, because java does not know the symlink concept
9  this_dir = File.dirname(File.expand_path(__FILE__))
10else
11  file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
12  this_dir = File.dirname(File.expand_path(file)) 
13end
14
15# set the load path, which uses the running directory, but has to be different if running on jruby directly from source.
16if RUBY_PLATFORM =~ /xjava/ and Gem::cache.search(/^activerdf$/).empty?
17  $: << this_dir + '/activerdf/lib/'
18  $: << this_dir + '/activerdf/lib/active_rdf/'
19else
20  $: << this_dir + '/'
21  $: << this_dir + '/active_rdf/'
22end
23
24require 'active_rdf_helpers'
25require 'active_rdf_log'
26
27$activerdflog.info "ActiveRDF started, logging level: #{$activerdflog.level}"
28
29# load standard classes that need to be loaded at startup
30require 'objectmanager/resource'
31require 'objectmanager/bnode'
32require 'objectmanager/literal'
33require 'objectmanager/namespace'
34require 'federation/connection_pool'
35require 'queryengine/query'
36require 'federation/active_rdf_adapter'
37
38def load_adapter s
39  begin
40    require s
41  rescue Exception => e
42    $activerdflog.info "could not load adapter #{s}: #{e}"
43  end
44end
45
46
47# determine whether activerdf is installed as a gem:
48if Gem::cache.search(/^activerdf$/).empty?
49        # we are not running as a gem
50        $activerdflog.info 'ActiveRDF is NOT installed as a Gem'
51        if RUBY_PLATFORM =~ /xjava/
52          load_adapter this_dir + '/activerdf/activerdf-jena/lib/activerdf_jena/init'
53          load_adapter this_dir + '/activerdf/activerdf-sparql/lib/activerdf_sparql/sparql'
54    #load_adapter this_dir + '/../activerdf-sesame/lib/activerdf_sesame/sesame'
55        else
56        #load_adapter this_dir + '/../activerdf-rdflite/lib/activerdf_rdflite/rdflite'
57        #load_adapter this_dir + '/../activerdf-rdflite/lib/activerdf_rdflite/fetching'
58        #load_adapter this_dir + '/../activerdf-rdflite/lib/activerdf_rdflite/suggesting'
59        #load_adapter this_dir + '/../activerdf-redland/lib/activerdf_redland/redland'
60        load_adapter this_dir + '/../activerdf-sparql/lib/activerdf_sparql/sparql'
61        #load_adapter this_dir + '/../activerdf-yars/lib/activerdf_yars/jars2'   
62  end
63 
64else
65        # we are running as a gem
66        require 'gem_plugin'
67        $activerdflog.info 'ActiveRDF is installed as a Gem'
68        GemPlugin::Manager.instance.load "activerdf" => GemPlugin::INCLUDE
69end
70
Note: See TracBrowser for help on using the browser.