You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by bd...@apache.org on 2011/02/14 14:35:08 UTC

svn commit: r1070485 - in /incubator/stanbol/trunk/commons: ./ stanboltools/ stanboltools/offline/ stanboltools/offline/src/ stanboltools/offline/src/main/ stanboltools/offline/src/main/java/ stanboltools/offline/src/main/java/org/ stanboltools/offline...

Author: bdelacretaz
Date: Mon Feb 14 13:35:07 2011
New Revision: 1070485

URL: http://svn.apache.org/viewvc?rev=1070485&view=rev
Log:
STANBOL-86 - offline mode support

Added:
    incubator/stanbol/trunk/commons/stanboltools/
    incubator/stanbol/trunk/commons/stanboltools/offline/   (with props)
    incubator/stanbol/trunk/commons/stanboltools/offline/pom.xml   (with props)
    incubator/stanbol/trunk/commons/stanboltools/offline/src/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/Activator.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OfflineMode.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OnlineMode.java   (with props)
Modified:
    incubator/stanbol/trunk/commons/pom.xml

Modified: incubator/stanbol/trunk/commons/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/pom.xml?rev=1070485&r1=1070484&r2=1070485&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/pom.xml (original)
+++ incubator/stanbol/trunk/commons/pom.xml Mon Feb 14 13:35:07 2011
@@ -22,5 +22,6 @@
         <module>testing/jarexec</module>
         <module>testing/http</module>
         <module>testing/stanbol</module>
+        <module>stanboltools/offline</module>
     </modules>
 </project>

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Feb 14 13:35:07 2011
@@ -0,0 +1,11 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+

Added: incubator/stanbol/trunk/commons/stanboltools/offline/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/offline/pom.xml?rev=1070485&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/offline/pom.xml (added)
+++ incubator/stanbol/trunk/commons/stanboltools/offline/pom.xml Mon Feb 14 13:35:07 2011
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.stanboltools.offline</artifactId>
+  <version>0.9-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Offline Utilities</name>
+  <description>
+    Offline mode utilities for Stanbol
+    </description>
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/stanboltools/offline
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/stanboltools/offline
+    </developerConnection>
+    <url>http://incubator.apache.org/stanbol/</url>
+  </scm>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-Activator>org.apache.stanbol.commons.stanboltools.offline.Activator</Bundle-Activator>
+            <Export-Package>org.apache.stanbol.commons.stanboltools.offline</Export-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.1</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.5.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>4.1.0</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/Activator.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/Activator.java?rev=1070485&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/Activator.java (added)
+++ incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/Activator.java Mon Feb 14 13:35:07 2011
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.stanbol.commons.stanboltools.offline;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Activator for the offline mnode bundle */
+public class Activator implements BundleActivator {
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    public static final String OFFLINE_MODE_PROPERTY = "org.apache.stanbol.offline.mode";
+    private ServiceRegistration serviceReg = null;
+    
+    @Override
+    public void start(BundleContext context) throws Exception {
+        final String s = System.getProperty(OFFLINE_MODE_PROPERTY);
+        Object svc = null;
+        String svcName = null;
+        
+        if("true".equals(s)) {
+            svc = new OfflineMode() {};
+            svcName = OfflineMode.class.getName();
+            log.info("OfflineMode activated by {}={}", 
+                    OFFLINE_MODE_PROPERTY, s);
+        } else {
+            svc = new OnlineMode() {};
+            svcName = OnlineMode.class.getName();
+            log.info("Offline mode is not set by {}, OnlineMode activated", 
+                    OFFLINE_MODE_PROPERTY); 
+        }
+        serviceReg = context.registerService(svcName, svc, null);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        if(serviceReg != null) {
+            serviceReg.unregister();
+            serviceReg = null;
+        }
+    }
+}

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/Activator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OfflineMode.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OfflineMode.java?rev=1070485&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OfflineMode.java (added)
+++ incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OfflineMode.java Mon Feb 14 13:35:07 2011
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.stanbol.commons.stanboltools.offline;
+
+/** Marker interface for a service that's only present if we're in offline mode */
+public interface OfflineMode {
+}

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OfflineMode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OfflineMode.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OnlineMode.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OnlineMode.java?rev=1070485&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OnlineMode.java (added)
+++ incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OnlineMode.java Mon Feb 14 13:35:07 2011
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.stanbol.commons.stanboltools.offline;
+
+/** Marker interface for a service that's only present if we're in online mode */
+public interface OnlineMode {
+}

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OnlineMode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stanbol/trunk/commons/stanboltools/offline/src/main/java/org/apache/stanbol/commons/stanboltools/offline/OnlineMode.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL