binding-gdata sample - under construction

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@690599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
dougsleite 2008-08-30 22:44:34 +00:00
parent 35fc0dd985
commit c9ca42a3aa
15 changed files with 642 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.devzuz.q.maven.jdt.core.mavenClasspathContainer"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>binding-gdata</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.devzuz.q.maven.jdt.core.mavenNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,79 @@
<!--
* 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.
-->
<project name="store" default="compile">
<property name="test.class" value="launch.Launch" />
<property name="test.jar" value="sample-store.jar" />
<target name="init">
<mkdir dir="target/classes"/>
</target>
<target name="compile" depends="init">
<javac srcdir="src/main/java"
destdir="target/classes"
debug="on"
source="1.5"
target="1.5">
<classpath>
<pathelement location="../../lib/tuscany-sca-manifest.jar"/>
<fileset refid="3rdparty.jars"/>
</classpath>
</javac>
<copy todir="target/classes">
<fileset dir="src/main/resources"/>
</copy>
<jar destfile="target/${test.jar}" basedir="target/classes">
<manifest>
<attribute name="Main-Class" value="${test.class}" />
</manifest>
</jar>
</target>
<target name="run-classes">
<java classname="${test.class}"
fork="true">
<classpath>
<pathelement path="target/classes"/>
<pathelement location="../../lib/tuscany-sca-manifest.jar"/>
<fileset refid="3rdparty.jars"/>
</classpath>
</java>
</target>
<target name="run">
<java classname="${test.class}"
fork="true">
<classpath>
<pathelement path="target/classes"/>
<pathelement location="../../lib/tuscany-sca-manifest.jar"/>
<fileset refid="3rdparty.jars"/>
</classpath>
</java>
</target>
<target name="clean">
<delete quiet="true" includeemptydirs="true">
<fileset dir="target"/>
</delete>
</target>
<fileset id="3rdparty.jars" dir="../../lib">
<include name="saxon-9.0.0.2.jar"/>
</fileset>
</project>

View file

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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.
--><project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-sca</artifactId>
<version>1.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sample-store</artifactId>
<name>Apache Tuscany SCA Getting Started Binding GData</name>
<repositories>
<repository>
<id>apache.incubator</id>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-data-api</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-widget-runtime</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-http-runtime</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-tomcat</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>gdata-client</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>gdata-core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>gdata-calendar</groupId>
<artifactId>gdata-calendar</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-gdata-runtime</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
</build>
</project>

View file

@ -0,0 +1,34 @@
/*
* 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 launch;
import org.apache.tuscany.sca.host.embedded.SCADomain;
public class Launch {
public static void main(String[] args) throws Exception {
System.out.println("Starting ...");
SCADomain scaDomain = SCADomain.newInstance("calendar.composite");
System.out.println("calendar.composite ready!!!");
System.in.read();
System.out.println("Stopping ...");
scaDomain.close();
System.out.println();
}
}

View file

@ -0,0 +1,33 @@
/*
* Copyright 2008 douglas.
*
* 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.
* under the License.
*/
package services;
import com.google.gdata.data.BaseEntry;
import java.util.List;
import org.osoa.sca.annotations.Remotable;
/**
*
* @author douglas
*/
@Remotable
public interface Controler {
public void createEvent(String name, String location, String startTime, String endTime, String description);
public List<BaseEntry> getEntries();
}

View file

@ -0,0 +1,91 @@
/*
* 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 services;
import com.google.gdata.data.BaseEntry;
import com.google.gdata.data.DateTime;
import com.google.gdata.data.Entry;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.calendar.CalendarEventEntry;
import com.google.gdata.data.extensions.When;
import com.google.gdata.data.extensions.Where;
import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.binding.gdata.collection.Collection;
import org.osoa.sca.annotations.Reference;
public class ControlerImpl implements Controler {
@Reference(name = "resources", required = true)
public Collection resources;
public ControlerImpl() {
}
public void createEvent(String name, String location, String startTime, String endTime, String description) {
CalendarEventEntry entry = new CalendarEventEntry();
//Set title
if (name != null) {
entry.setTitle(new PlainTextConstruct(name));
}
//Set location
if (location != null) {
Where where = new Where();
where.setValueString(location);
entry.addLocation(where);
}
//Set startTime and endTime
//"2008-06-05T15:00:00-08:00"
if (startTime != null && endTime != null) {
DateTime start = DateTime.parseDateTime(startTime);
DateTime end = DateTime.parseDateTime(endTime);
When eventTimes = new When();
eventTimes.setStartTime(start);
eventTimes.setEndTime(end);
entry.addTime(eventTimes);
}
//Set content
if (description != null) {
entry.setContent(new PlainTextConstruct(description));
}
// Person author = new Person("GSoC Student 2008", null, "gsocstudent2008@gmail.com");
// entry.getAuthors().add(author);
//resources.post(entry);
}
public List<BaseEntry> getEntries() {
//return (List<BaseEntry>) resources.getFeed().getEntries();
BaseEntry entry = new Entry();
entry.setTitle(new PlainTextConstruct("Entry"));
entry.setContent(new PlainTextConstruct("Conteudo"));
List<BaseEntry> list = new ArrayList<BaseEntry>();
list.add(entry);
return list;
}
}

View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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.
-->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
targetNamespace="http://calendar"
name="calendar">
<component name="Calendar">
<t:implementation.widget location="uiservices/calendar.html"/>
<service name="Widget">
<t:binding.http uri="/calendar"/>
</service>
<reference name="calendarRef" target="CalendarComponent/CalendarService">
<t:binding.jsonrpc/>
</reference>
</component>
<component name="CalendarComponent">
<implementation.java class="services.ControlerImpl"/>
<service name="CalendarService">
<interface.java interface="services.Controler"/>
<t:binding.jsonrpc/>
</service>
<reference name="resources">
<t:binding.gdata uri="http://www.google.com/calendar/feeds/gsocstudent2008@gmail.com/private/full" serviceType="cl" username="gsocstudent2008@gmail.com" password="gsoc2008"/>
</reference>
</component>
</composite>

View file

@ -0,0 +1,72 @@
<!--
* 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.
-->
<html>
<head>
<title>Calendar</title>
<script type="text/javascript" src="calendar.js"></script>
<script language="JavaScript">
//@Reference
var calendarRef = new Reference("calendarRef");
function calendar_getResponse(entries,exception) {
/*(if(exception){
alert(exception.message);
return;
}
var calendar_string = "";
for (var i=0; i<entries.size(); i++) {
var entry = entries.get(i);
calendar_string += 'Title: ' + entry.getTitle().getPlainText() + ' <br>';
}
document.getElementById('catalog').innerHTML=calendar_string;*/
}
function save() {
}
function init() {
try {
calendarRef.getEntries(calendar_getResponse);
}
catch(e){
alert(e);
}
}
</script>
</head>
<body onload="init()">
<h1>Calendar</h1>
<div id="store">
<form name="calendarForm">
<div id="calendarRef" ></div>
<br>
<input type="button" onClick="save()" value="Save">
</form>
</div>
</body>
</html>

View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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.
-->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
targetNamespace="http://calendar"
name="calendar">
<component name="Calendar">
<t:implementation.widget location="uiservices/calendar.html"/>
<service name="Widget">
<t:binding.http uri="/calendar"/>
</service>
<reference name="calendarRef" target="CalendarComponent/CalendarService">
<t:binding.jsonrpc/>
</reference>
</component>
<component name="CalendarComponent">
<implementation.java class="services.ControlerImpl"/>
<service name="CalendarService">
<interface.java interface="services.Controler"/>
<t:binding.jsonrpc/>
</service>
<reference name="resources">
<t:binding.gdata uri="http://www.google.com/calendar/feeds/gsocstudent2008@gmail.com/private/full" serviceType="cl" username="gsocstudent2008@gmail.com" password="gsoc2008"/>
</reference>
</component>
</composite>

View file

@ -0,0 +1,72 @@
<!--
* 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.
-->
<html>
<head>
<title>Calendar</title>
<script type="text/javascript" src="calendar.js"></script>
<script language="JavaScript">
//@Reference
var calendarRef = new Reference("calendarRef");
function calendar_getResponse(entries,exception) {
/*(if(exception){
alert(exception.message);
return;
}
var calendar_string = "";
for (var i=0; i<entries.size(); i++) {
var entry = entries.get(i);
calendar_string += 'Title: ' + entry.getTitle().getPlainText() + ' <br>';
}
document.getElementById('catalog').innerHTML=calendar_string;*/
}
function save() {
}
function init() {
try {
calendarRef.getEntries(calendar_getResponse);
}
catch(e){
alert(e);
}
}
</script>
</head>
<body onload="init()">
<h1>Calendar</h1>
<div id="store">
<form name="calendarForm">
<div id="calendarRef" ></div>
<br>
<input type="button" onClick="save()" value="Save">
</form>
</div>
</body>
</html>