From 2bd12eeb21785924346b1114272c9306a2dc7b25 Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 3 Jul 2008 01:03:50 +0000 Subject: Simple picture gallery just showing list of pictures from a album stored as project resource git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@673556 13f79535-47bb-0310-9956-ffa450edef68 --- .../photo-gallery/src/main/java/launch/Launch.java | 2 +- .../src/main/java/services/Album.java | 29 +++++ .../src/main/java/services/AlbumImpl.java | 95 ++++++++++++++ .../photo-gallery/src/main/resources/gallery.html | 57 +++++++++ .../src/main/resources/gallery/boston/dsc00368.jpg | Bin 0 -> 32808 bytes .../src/main/resources/gallery/boston/dsc00369.jpg | Bin 0 -> 35980 bytes .../src/main/resources/gallery/boston/dsc00370.jpg | Bin 0 -> 44614 bytes .../src/main/resources/gallery/boston/dsc00371.jpg | Bin 0 -> 40745 bytes .../src/main/resources/gallery/boston/dsc00373.jpg | Bin 0 -> 76470 bytes .../src/main/resources/gallery/boston/dsc00375.jpg | Bin 0 -> 34834 bytes .../src/main/resources/gallery/boston/dsc00376.jpg | Bin 0 -> 38797 bytes .../src/main/resources/gallery/boston/dsc00377.jpg | Bin 0 -> 35776 bytes .../src/main/resources/gallery/boston/dsc00378.jpg | Bin 0 -> 35248 bytes .../src/main/resources/gallery/boston/dsc00379.jpg | Bin 0 -> 55042 bytes .../src/main/resources/gallery/boston/dsc00380.jpg | Bin 0 -> 55236 bytes .../src/main/resources/photo-gallery.composite | 41 ++---- .../src/main/resources/uiservices/gallery.html | 141 --------------------- 17 files changed, 194 insertions(+), 171 deletions(-) create mode 100644 java/sca/samples/photo-gallery/src/main/java/services/Album.java create mode 100644 java/sca/samples/photo-gallery/src/main/java/services/AlbumImpl.java create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery.html create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg create mode 100644 java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg delete mode 100644 java/sca/samples/photo-gallery/src/main/resources/uiservices/gallery.html (limited to 'java/sca') diff --git a/java/sca/samples/photo-gallery/src/main/java/launch/Launch.java b/java/sca/samples/photo-gallery/src/main/java/launch/Launch.java index 858fdb6bf2..e1a96f9309 100644 --- a/java/sca/samples/photo-gallery/src/main/java/launch/Launch.java +++ b/java/sca/samples/photo-gallery/src/main/java/launch/Launch.java @@ -25,7 +25,7 @@ public class Launch { public static void main(String[] args) throws Exception { System.out.println("Starting ..."); SCADomain scaDomain = SCADomain.newInstance("photo-gallery.composite"); - System.out.println("store.composite ready for big business !!!"); + System.out.println("photo.gallery.composite ready for big business !!!"); System.in.read(); System.out.println("Stopping ..."); scaDomain.close(); diff --git a/java/sca/samples/photo-gallery/src/main/java/services/Album.java b/java/sca/samples/photo-gallery/src/main/java/services/Album.java new file mode 100644 index 0000000000..5257d0e703 --- /dev/null +++ b/java/sca/samples/photo-gallery/src/main/java/services/Album.java @@ -0,0 +1,29 @@ +/* + * 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 org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Album { + + public String[] getPictures(); + +} diff --git a/java/sca/samples/photo-gallery/src/main/java/services/AlbumImpl.java b/java/sca/samples/photo-gallery/src/main/java/services/AlbumImpl.java new file mode 100644 index 0000000000..dd2b086e29 --- /dev/null +++ b/java/sca/samples/photo-gallery/src/main/java/services/AlbumImpl.java @@ -0,0 +1,95 @@ +/* + * 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 java.io.File; +import java.io.FilenameFilter; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; + +public class AlbumImpl implements Album { + private String gallery; + private String album; + private String location; + private List pictures = new ArrayList(); + + @Property + public void setGallery(String gallery) { + this.gallery = gallery; + this.location = null; + } + @Property + public void setAlbum(String album) { + this.album = album; + this.location = null; + } + + protected String getLocation() { + if (location == null) { + location = gallery + "/" + album + "/"; + } + return location; + + } + + @Init + public void init() { + try { + URL albumURL = this.getClass().getClassLoader().getResource(getLocation()); + if(albumURL != null) { + File album = new File(albumURL.toURI()); + if (album.isDirectory() && album.exists()) { + String[] listPictures = album.list(new ImageFilter(".jpg")); + for(String image : listPictures) { + image = getLocation() + image; + pictures.add(image); + } + } + } + } catch (Exception e) { + // FIXME: ignore for now + e.printStackTrace(); + } + } + + public String[] getPictures() { + String[] pictureArray = new String[pictures.size()]; + pictures.toArray(pictureArray); + return pictureArray; + } + + /** + * Inner fileFilter class + */ + private class ImageFilter implements FilenameFilter { + String afn; + ImageFilter(String afn) { this.afn = afn; } + public boolean accept(File dir, String name) { + // Strip path information: + String f = new File(name).getName(); + return f.indexOf(afn) != -1; + } + } ///:~ + +} diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery.html b/java/sca/samples/photo-gallery/src/main/resources/gallery.html new file mode 100644 index 0000000000..2a7b32f6ed --- /dev/null +++ b/java/sca/samples/photo-gallery/src/main/resources/gallery.html @@ -0,0 +1,57 @@ + + + +Photo Gallery + + + + + + + + +

Photo Gallery

+ + + diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg new file mode 100644 index 0000000000..9437b321e2 Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg new file mode 100644 index 0000000000..07f37ec505 Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg new file mode 100644 index 0000000000..2193784271 Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg new file mode 100644 index 0000000000..1532ee2c1b Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg new file mode 100644 index 0000000000..17ffd73aec Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg new file mode 100644 index 0000000000..19e9ec37df Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg new file mode 100644 index 0000000000..022416dbce Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg new file mode 100644 index 0000000000..c78a974714 Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg new file mode 100644 index 0000000000..a98070925a Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg new file mode 100644 index 0000000000..dc83889116 Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg new file mode 100644 index 0000000000..0e33548135 Binary files /dev/null and b/java/sca/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg differ diff --git a/java/sca/samples/photo-gallery/src/main/resources/photo-gallery.composite b/java/sca/samples/photo-gallery/src/main/resources/photo-gallery.composite index 4f4a9d2e3d..0bb3c4b4db 100644 --- a/java/sca/samples/photo-gallery/src/main/resources/photo-gallery.composite +++ b/java/sca/samples/photo-gallery/src/main/resources/photo-gallery.composite @@ -22,43 +22,26 @@ targetNamespace="http://photo-gallery" name="photo-gallery"> - - + + - + - - - - - - - + - - - USD - + + + gallery + boston + - - - - - - - - - - + + + - - - - - diff --git a/java/sca/samples/photo-gallery/src/main/resources/uiservices/gallery.html b/java/sca/samples/photo-gallery/src/main/resources/uiservices/gallery.html deleted file mode 100644 index 095570f949..0000000000 --- a/java/sca/samples/photo-gallery/src/main/resources/uiservices/gallery.html +++ /dev/null @@ -1,141 +0,0 @@ - - - -Store - - - - - - - - -

Store

-
-

Catalog

-
-
-
- -
- -
- -

Your Shopping Cart

-
-
-
-
-
- - - (feed) -
-
- - -- cgit v1.2.3