Author: matthijsh
Date: Thu Dec 22 14:48:49 2011
New Revision: 1873

Log:
[SANDBOX] Added amdatu-test

Added:
   sandbox/matthijsh/amdatu-test/
   sandbox/matthijsh/amdatu-test/pom.xml
   sandbox/matthijsh/amdatu-test/test1-gadget/
   sandbox/matthijsh/amdatu-test/test1-gadget/pom.xml
   sandbox/matthijsh/amdatu-test/test1-gadget/src/
   sandbox/matthijsh/amdatu-test/test1-gadget/src/main/
   sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/
   sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/
   sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/
   sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/
   
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/
   
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/
   
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/osgi/
   
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/osgi/Activator.java
   
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/service/
   
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/service/Test1GadgetDefinition.java
   
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/service/Test1GadgetImpl.java
   sandbox/matthijsh/amdatu-test/test1-gadget/src/test/
   sandbox/matthijsh/amdatu-test/test1-gadget/src/test/java/
   sandbox/matthijsh/amdatu-test/test1-gadget/src/test/resources/
   sandbox/matthijsh/amdatu-test/test1-service/
   sandbox/matthijsh/amdatu-test/test1-service/pom.xml
   sandbox/matthijsh/amdatu-test/test1-service/src/
   sandbox/matthijsh/amdatu-test/test1-service/src/main/
   sandbox/matthijsh/amdatu-test/test1-service/src/main/java/
   sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/
   sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/
   sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/
   
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/
   
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/
   
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/Test1Service.java
   
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/osgi/
   
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/osgi/Activator.java
   
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/service/
   
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/service/Test1ServiceImpl.java
   sandbox/matthijsh/amdatu-test/test1-service/src/main/resources/
   sandbox/matthijsh/amdatu-test/test1-service/src/test/
   sandbox/matthijsh/amdatu-test/test1-service/src/test/java/
   sandbox/matthijsh/amdatu-test/test1-service/src/test/resources/

Added: sandbox/matthijsh/amdatu-test/pom.xml
==============================================================================
--- (empty file)
+++ sandbox/matthijsh/amdatu-test/pom.xml       Thu Dec 22 14:48:49 2011
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright (c) 2010, 2011 The Amdatu Foundation
+
+  Licensed 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.verning permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.amdatu</groupId>
+    <artifactId>amdatu</artifactId>
+    <version>5-SNAPSHOT</version>    
+    <relativePath>../amdatu-parent/pom.xml</relativePath>
+  </parent>
+  <groupId>org.amdatu.test</groupId>
+  <artifactId>org.amdatu.test</artifactId>
+  <version>0.1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <name>Amdatu Test</name>
+  <description>Test project</description>
+
+  <modules>
+  <module>test1-service</module>
+  <module>test1-gadget</module>
+  </modules>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>2.6</version>
+        <configuration>
+          <!-- Aggregation is not yet supported in 2.6. A highly popular JIRA 
issue has
+               been created to resolve this issue: 
http://jira.codehaus.org/browse/MCHECKSTYLE-62
+               <aggregate>true</aggregate>
+          -->
+
+          <linkXref>true</linkXref>
+          <configLocation>target/amdatu_checks.xml</configLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
+  
+  <build>
+    <plugins>
+          <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-antrun-plugin</artifactId>
+          <version>1.6</version>
+          <dependencies>
+            <dependency>
+              <groupId>ant-contrib</groupId>
+              <artifactId>ant-contrib</artifactId>
+              <version>1.0b3</version>
+              <exclusions>
+                <exclusion>
+                  <groupId>ant</groupId>
+                  <artifactId>ant</artifactId>
+                </exclusion>
+              </exclusions>
+            </dependency>
+            <dependency>
+              <groupId>org.apache.ant</groupId>
+              <artifactId>ant-nodeps</artifactId>
+              <version>1.8.1</version>
+            </dependency>
+          </dependencies>
+          <executions>
+            <execution>
+              <phase>install</phase>
+              <goals>
+                <goal>run</goal>
+              </goals>
+              <configuration>
+                <target>
+                  <taskdef resource="net/sf/antcontrib/antcontrib.properties" 
classpathref="maven.compile.classpath" />
+                  <available 
file="${project.build.directory}/${project.build.finalName}.jar" 
property="fileExists" value="true" />
+                  <if>
+                    <isset property="fileExists" />
+                    <then>
+                      <if>
+                        <isset property="amdatu.deploy.directory" />
+                        <then>
+                          <copy 
file="${project.build.directory}/${project.build.finalName}.jar" 
tofile="${amdatu.deploy.directory}/${project.artifactId}-${project.version}.jar"
 overwrite="true" />
+                        </then>
+                        <else>
+                          <echo message="Property amdatu.deploy.directory not 
defined, skipping copy to deploy dir task" />
+                        </else>
+                      </if>
+                    </then>
+                  </if>
+                </target>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+       </build>
+
+</project>
\ No newline at end of file

Added: sandbox/matthijsh/amdatu-test/test1-gadget/pom.xml
==============================================================================
--- (empty file)
+++ sandbox/matthijsh/amdatu-test/test1-gadget/pom.xml  Thu Dec 22 14:48:49 2011
@@ -0,0 +1,130 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <artifactId>org.amdatu.test</artifactId>
+               <groupId>org.amdatu.test</groupId>
+               <version>0.1.0-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <groupId>org.amdatu.test.test1.gadget</groupId>
+       <artifactId>org.amdatu.test.test1.gadget</artifactId>
+       <packaging>bundle</packaging>
+       <name>Amdatu Test - Test 1 (Gadget)</name>
+       <description>Test one (Gadget)</description>
+
+       <properties>
+               <amdatu.opensocial.version>0.2.0-RC1</amdatu.opensocial.version>
+       </properties>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.amdatu.test.test1</groupId>
+                       <artifactId>org.amdatu.test.test1.service</artifactId>
+                       <version>0.1.0-SNAPSHOT</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.amdatu.opensocial</groupId>
+                       
<artifactId>org.amdatu.opensocial.gadgetmanagement</artifactId>
+                       <version>${amdatu.opensocial.version}</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.amdatu.opensocial</groupId>
+                       <artifactId>org.amdatu.opensocial.shindig</artifactId>
+                       <version>0.2.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.amdatu.web</groupId>
+                       <artifactId>org.amdatu.web.dispatcher</artifactId>
+                       <version>0.2.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.amdatu.web</groupId>
+                       <artifactId>org.amdatu.web.httpcontext</artifactId>
+                       <version>0.2.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.amdatu.web</groupId>
+                       <artifactId>org.amdatu.web.jsp</artifactId>
+                       <version>0.2.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.amdatu.web</groupId>
+                       <artifactId>org.amdatu.web.resource</artifactId>
+                       <version>0.2.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.amdatu.core</groupId>
+                       <artifactId>org.amdatu.core.tenant</artifactId>
+                       <version>0.2.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+                       <type>bundle</type>
+               </dependency>
+               <dependency>
+         <groupId>org.json</groupId>
+           <artifactId>json</artifactId>
+               <version>20090211</version>
+       </dependency>
+       </dependencies>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <artifactId>maven-source-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               
<Bundle-Activator>org.amdatu.test.test1.gadget.osgi.Activator</Bundle-Activator>
+                                               
<Bundle-SymbolicName>org.amdatu.test.test1.gadget</Bundle-SymbolicName>
+                               
<Embed-Dependency>*;scope=compile</Embed-Dependency>
+                                               
<Embed-Transitive>true</Embed-Transitive>
+                                               <Import-Package>
+                                                       *
+                                               </Import-Package>
+                                               <Export-Package>
+                                                       
org.amdatu.test.test1.gadget
+                                               </Export-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <profiles>
+               <profile>
+                       <!-- Profile that will copy the jar to the configured 
amdatu.deploy.directory 
+                               when the deploy profile is activated -->
+                       <id>deploy</id>
+                       <activation>
+                               <activeByDefault>false</activeByDefault>
+                       </activation>
+                       <build>
+                               <defaultGoal>install</defaultGoal>
+                               <plugins>
+                                       <plugin>
+                                               
<groupId>org.apache.maven.plugins</groupId>
+                                               
<artifactId>maven-antrun-plugin</artifactId>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+
+</project>
\ No newline at end of file

Added: 
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/osgi/Activator.java
==============================================================================
--- (empty file)
+++ 
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/osgi/Activator.java
   Thu Dec 22 14:48:49 2011
@@ -0,0 +1,70 @@
+package org.amdatu.test.test1.gadget.osgi;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.amdatu.core.tenant.Tenant;
+import org.amdatu.opensocial.gadgetmanagement.GadgetDefinitionProvider;
+import org.amdatu.test.test1.gadget.service.Test1GadgetDefinition;
+import org.amdatu.test.test1.gadget.service.Test1GadgetImpl;
+import org.amdatu.test.test1.service.Test1Service;
+import org.amdatu.web.dispatcher.DispatcherService;
+import org.amdatu.web.httpcontext.ResourceProvider;
+import org.amdatu.web.jsp.JspSupport;
+import org.amdatu.web.resource.ResourceSupport;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * @author matthijsh
+ */
+public class Activator extends DependencyActivatorBase
+{
+       
+       /**
+     * Context id of the Authorization HTTP Context.
+     */
+    public static final String CONTEXTID = "amdatu-testing";
+       
+       /**
+     * URL alias hosting the test1 gadget.
+     */
+    public static final String ALIAS = "/gadget/test1";
+    
+    /**
+     * URL alias hosting the JSPs.
+     */
+    public static final String JSP_ALIAS = ALIAS + "/jsp";
+
+    /**
+     * URL alias hosting the statics.
+     */
+    public static final String RES_ALIAS = ALIAS + "/static";
+    
+
+       @Override
+       public void init(BundleContext context, DependencyManager manager) 
throws Exception {
+               Dictionary<String, Object> properties = new Hashtable<String, 
Object>();
+        properties.put(DispatcherService.CONTEXT_ID_KEY, CONTEXTID);
+        properties.put(JspSupport.JSP_ALIAS_KEY, JSP_ALIAS);
+        properties.put(ResourceSupport.RESOURCE_ALIAS_KEY, RES_ALIAS);
+
+        
manager.add(createComponent().setInterface(ResourceProvider.class.getName(), 
properties)
+            .setImplementation(Test1GadgetImpl.class)
+            
.add(createServiceDependency().setService(LogService.class).setRequired(false))
+            
.add(createServiceDependency().setService(Test1Service.class).setRequired(true)));
+        
+        // Register a login gadget definition for each tenant
+        manager.add(createAdapterService(Tenant.class, null)
+            .setInterface(GadgetDefinitionProvider.class.getName(), null)
+            .setImplementation(Test1GadgetDefinition.class));
+       }
+       
+       @Override
+       public void destroy(BundleContext context, DependencyManager manager) 
throws Exception {
+               // TODO Auto-generated method stub
+       }
+
+}

Added: 
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/service/Test1GadgetDefinition.java
==============================================================================
--- (empty file)
+++ 
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/service/Test1GadgetDefinition.java
    Thu Dec 22 14:48:49 2011
@@ -0,0 +1,15 @@
+package org.amdatu.test.test1.gadget.service;
+
+import org.amdatu.opensocial.gadgetmanagement.GadgetCategory;
+import org.amdatu.opensocial.gadgetmanagement.GadgetDefinition;
+import org.amdatu.opensocial.gadgetmanagement.GadgetDefinitionProvider;
+import org.amdatu.test.test1.gadget.osgi.Activator;
+
+public class Test1GadgetDefinition implements GadgetDefinitionProvider {
+    public GadgetDefinition[] getDefinitions() {
+        return new GadgetDefinition[] { new GadgetDefinition(
+                Activator.ALIAS + "/jsp/Test1Gadget.jsp", // gadget URL
+            GadgetCategory.AMDATU_PLATFORM, // category
+            false)}; // default visible on the dashboard
+    }
+}
\ No newline at end of file

Added: 
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/service/Test1GadgetImpl.java
==============================================================================
--- (empty file)
+++ 
sandbox/matthijsh/amdatu-test/test1-gadget/src/main/java/org/amdatu/test/test1/gadget/service/Test1GadgetImpl.java
  Thu Dec 22 14:48:49 2011
@@ -0,0 +1,34 @@
+package org.amdatu.test.test1.gadget.service;
+
+import java.net.URL;
+
+import org.amdatu.test.test1.gadget.osgi.Activator;
+import org.amdatu.test.test1.service.Test1Service;
+import org.amdatu.web.httpcontext.ResourceProvider;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+public class Test1GadgetImpl implements ResourceProvider
+{
+
+       // Service dependencies, injected by the Felix dependency manager
+       private volatile LogService             m_logService;
+       private volatile Test1Service   m_testService;
+       private volatile BundleContext  m_bundleContext;
+
+       /**
+        * The init() method is invoked by the Felix dependency manager.
+        */
+       public void start() {
+               m_logService.log(LogService.LOG_INFO, getClass().getName() + " 
service started");
+       }
+
+       public URL getResource(String name) {
+               final String pathPrefix = Activator.ALIAS + "/";
+               if (name != null && name.startsWith(pathPrefix)) {
+                       return 
m_bundleContext.getBundle().getResource(name.substring(pathPrefix.length()));
+               }
+               return null;
+       }
+
+}

Added: sandbox/matthijsh/amdatu-test/test1-service/pom.xml
==============================================================================
--- (empty file)
+++ sandbox/matthijsh/amdatu-test/test1-service/pom.xml Thu Dec 22 14:48:49 2011
@@ -0,0 +1,94 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <artifactId>org.amdatu.test</artifactId>
+               <groupId>org.amdatu.test</groupId>
+               <version>0.1.0-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <groupId>org.amdatu.test.test1</groupId>
+       <artifactId>org.amdatu.test.test1.service</artifactId>
+       <packaging>bundle</packaging>
+       <name>Amdatu Test - Test 1 (Service)</name>
+       <description>Test one (Service)</description>
+
+       <properties>
+               <!-- Version of dependend components -->
+               <amdatu.core.version>0.2.1</amdatu.core.version>
+               <amdatu.web.version>0.2.1</amdatu.web.version>
+               <amdatu.libraries.version>0.2.0</amdatu.libraries.version>
+       </properties>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.amdatu.web</groupId>
+                       <artifactId>org.amdatu.web.jaxrs</artifactId>
+                       <version>0.2.1</version>
+                       <type>bundle</type>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.json</groupId>
+                       <artifactId>json</artifactId>
+                       <version>20090211</version>
+               </dependency>
+               <dependency>
+                       <groupId>javax.servlet</groupId>
+                       <artifactId>servlet-api</artifactId>
+                       <scope>provided</scope>
+               </dependency>
+               
+               <dependency>
+                       <groupId>org.amdatu.libraries</groupId>
+                       <artifactId>org.amdatu.libraries.utilities</artifactId>
+                       <version>0.2.0</version>
+               </dependency>
+       </dependencies>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <artifactId>maven-source-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               
<Bundle-Activator>org.amdatu.test.test1.service.osgi.Activator</Bundle-Activator>
+                                               
<Bundle-SymbolicName>org.amdatu.test.test1.service</Bundle-SymbolicName>
+                                               
<Embed-Dependency>*;scope=compile</Embed-Dependency>
+                                               
<Embed-Transitive>true</Embed-Transitive>
+                                               <Import-Package>
+                                                       *
+                                               </Import-Package>
+                                               <Export-Package>
+                                                       
org.amdatu.test.test1.service;version="1.0.0"
+                                               </Export-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <profiles>
+               <profile>
+                       <!-- Profile that will copy the jar to the configured 
amdatu.deploy.directory 
+                               when the deploy profile is activated -->
+                       <id>deploy</id>
+                       <activation>
+                               <activeByDefault>false</activeByDefault>
+                       </activation>
+                       <build>
+                               <defaultGoal>install</defaultGoal>
+                               <plugins>
+                                       <plugin>
+                                               
<groupId>org.apache.maven.plugins</groupId>
+                                               
<artifactId>maven-antrun-plugin</artifactId>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+</project>
\ No newline at end of file

Added: 
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/Test1Service.java
==============================================================================
--- (empty file)
+++ 
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/Test1Service.java
   Thu Dec 22 14:48:49 2011
@@ -0,0 +1,5 @@
+package org.amdatu.test.test1.service;
+
+public interface Test1Service {
+
+}

Added: 
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/osgi/Activator.java
==============================================================================
--- (empty file)
+++ 
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/osgi/Activator.java
 Thu Dec 22 14:48:49 2011
@@ -0,0 +1,37 @@
+package org.amdatu.test.test1.service.osgi;
+
+import org.amdatu.libraries.utilities.osgi.ServiceDependentActivator;
+import org.amdatu.test.test1.service.Test1Service;
+import org.amdatu.test.test1.service.service.Test1ServiceImpl;
+import org.amdatu.web.rest.jaxrs.JaxRsSpi;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * @author matthijsh
+ */
+public class Activator extends ServiceDependentActivator // 
DependencyActivatorBase //
+{
+
+       @Override
+       protected Class<?>[] getRequiredServices() {
+               return new Class<?>[] { JaxRsSpi.class };
+       }
+
+       @Override
+       public void initWithDependencies(BundleContext context, 
DependencyManager manager) throws Exception {
+               // Create and register the test1 service.
+               manager.add(createComponent()
+                               .setImplementation(Test1ServiceImpl.class)
+                               .setInterface(Test1Service.class.getName(), 
null)
+                               
.add(createServiceDependency().setService(LogService.class).setRequired(true)));
+
+       }
+       
+       @Override
+       public void destroy(BundleContext context, DependencyManager manager) 
throws Exception {
+               // TODO Auto-generated method stub
+       }
+
+}

Added: 
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/service/Test1ServiceImpl.java
==============================================================================
--- (empty file)
+++ 
sandbox/matthijsh/amdatu-test/test1-service/src/main/java/org/amdatu/test/test1/service/service/Test1ServiceImpl.java
       Thu Dec 22 14:48:49 2011
@@ -0,0 +1,82 @@
+package org.amdatu.test.test1.service.service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.amdatu.test.test1.service.Test1Service;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.osgi.service.log.LogService;
+
+@Path("test1")
+public class Test1ServiceImpl implements Test1Service
+{
+
+       private volatile LogService     m_logService;
+
+       // Disable HTTP caching in this REST interface
+       private static CacheControl NO_CACHE_CONTROL;
+       static {
+               NO_CACHE_CONTROL = new CacheControl();
+               NO_CACHE_CONTROL.setNoCache(true);
+       }
+
+       public void init() {
+               m_logService.log(LogService.LOG_INFO, "init");
+               System.out.println("init");
+       }
+
+       public void start() {
+               m_logService.log(LogService.LOG_INFO, "start");
+               System.out.println("start");
+       }
+
+       @GET
+       @Path("hello")
+       @Produces({ MediaType.APPLICATION_JSON })
+       public Response hello(@Context final HttpServletRequest request) {
+               JSONObject jsonObject = new JSONObject();
+               try {
+                       // String userName = getUserName(request);
+                       // if (userName != null)
+                       jsonObject.append("text", "Hello you! :))");
+               }
+               catch (JSONException e) {
+                       m_logService.log(LogService.LOG_ERROR, "Could not 
retrieve hello response", e);
+               }
+
+               return Response.ok(jsonObject.toString(), 
MediaType.APPLICATION_JSON_TYPE).cacheControl(NO_CACHE_CONTROL).build();
+       }
+
+       @GET
+       @Path("hello2")
+       @Produces({ MediaType.APPLICATION_JSON })
+       public Response hello2(@Context final HttpServletRequest request) {
+               JSONObject jsonObject = new JSONObject();
+               try {
+                       String name = request.getParameter("name");
+                       if (name != null)
+                               jsonObject.append("text", "Hello " + name + "! 
:))");
+                       else
+                               jsonObject.append("text", "Hello 'nameless'!");
+               }
+               catch (JSONException e) {
+                       m_logService.log(LogService.LOG_ERROR, "Could not 
retrieve hello2 response", e);
+               }
+
+               return Response.ok(jsonObject.toString(), 
MediaType.APPLICATION_JSON_TYPE).build();
+       }
+
+       @GET
+       @Produces({ MediaType.TEXT_PLAIN })
+       public String status() {
+               return "Test1 service for tenant online";
+       }
+
+}
\ No newline at end of file
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to