[P2play-commit] SF.net SVN: p2play: [43] P2PlayServiceServer
Status: Pre-Alpha
Brought to you by:
tisoft
|
From: <ti...@us...> - 2007-03-20 12:07:03
|
Revision: 43
http://p2play.svn.sourceforge.net/p2play/?rev=43&view=rev
Author: tisoft
Date: 2007-03-20 04:55:27 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
P2PlayServiceServer/.classpath
P2PlayServiceServer/.project
P2PlayServiceServer/.settings/
P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs
P2PlayServiceServer/.settings/org.eclipse.wst.common.component
P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml
P2PlayServiceServer/pom.xml
P2PlayServiceServer/src/
P2PlayServiceServer/src/main/
P2PlayServiceServer/src/main/java/
P2PlayServiceServer/src/main/java/org/
P2PlayServiceServer/src/main/java/org/p2play/
P2PlayServiceServer/src/main/java/org/p2play/service/
P2PlayServiceServer/src/main/java/org/p2play/service/server/
P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java
P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java
P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java
P2PlayServiceServer/src/main/java/org/p2play/service/server/node/
P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java
Property Changed:
----------------
P2PlayServiceServer/
Property changes on: P2PlayServiceServer
___________________________________________________________________
Name: svn:ignore
+ target
Added: P2PlayServiceServer/.classpath
===================================================================
--- P2PlayServiceServer/.classpath (rev 0)
+++ P2PlayServiceServer/.classpath 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: P2PlayServiceServer/.project
===================================================================
--- P2PlayServiceServer/.project (rev 0)
+++ P2PlayServiceServer/.project 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>P2PlayServiceServer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ </natures>
+</projectDescription>
Added: P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,7 @@
+#Tue Mar 20 10:11:04 CET 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: P2PlayServiceServer/.settings/org.eclipse.wst.common.component
===================================================================
--- P2PlayServiceServer/.settings/org.eclipse.wst.common.component (rev 0)
+++ P2PlayServiceServer/.settings/org.eclipse.wst.common.component 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="P2PlayService">
+<wb-resource deploy-path="/" source-path="/src/main/java"/>
+</wb-module>
+</project-modules>
Added: P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
--- P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml (rev 0)
+++ P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.utility"/>
+ <installed facet="jst.utility" version="1.0"/>
+ <installed facet="jst.java" version="5.0"/>
+</faceted-project>
Added: P2PlayServiceServer/pom.xml
===================================================================
--- P2PlayServiceServer/pom.xml (rev 0)
+++ P2PlayServiceServer/pom.xml 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayServiceServer</artifactId>
+ <version>0.0.1</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayBoot</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayService</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jetty</groupId>
+ <artifactId>org.mortbay.jetty</artifactId>
+ <version>5.1.6</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ </dependency>
+ </dependencies>
+</project>
+
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server;
+
+import javax.jws.WebService;
+
+import org.p2play.service.AuthenticationService;
+import org.p2play.service.exception.AuthenticationException;
+import org.p2play.service.object.AuthenticationToken;
+
+@WebService(serviceName = "AuthenticationService", endpointInterface = "org.p2play.service.AuthenticationService")
+public class AuthenticationServiceImpl implements AuthenticationService {
+
+ public AuthenticationToken login(String user, char[] password)
+ throws AuthenticationException {
+ if (password.length > 5)
+ return new AuthenticationToken() {
+ };
+ else
+ throw new AuthenticationException("Login incorrect");
+ }
+
+}
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server;
+
+import org.codehaus.xfire.XFire;
+import org.codehaus.xfire.XFireFactory;
+import org.codehaus.xfire.annotations.AnnotationServiceFactory;
+import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
+import org.codehaus.xfire.server.http.XFireHttpServer;
+import org.p2play.service.server.node.StaticNode;
+
+public class P2PlayServiceServer {
+ public static void main(String[] args) throws Exception {
+ StaticNode.instance().init();
+
+ StaticNode.instance().getFileSystemManager();
+
+ XFire xfire = XFireFactory.newInstance().getXFire();
+ AnnotationServiceFactory factory = new AnnotationServiceFactory(
+ new Jsr181WebAnnotations(), xfire.getTransportManager());
+
+ xfire.getServiceRegistry().register(
+ factory.create(AuthenticationServiceImpl.class));
+ xfire.getServiceRegistry().register(
+ factory.create(P2PlayVfsServiceImpl.class));
+
+ new XFireHttpServer().start();
+ // http://localhost:8081/GreeterService?wsdl
+ }
+
+}
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server;
+
+import javax.jws.WebService;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.p2play.service.P2PlayVfsService;
+import org.p2play.service.object.AuthenticationToken;
+import org.p2play.service.server.node.StaticNode;
+
+@WebService(serviceName = "P2PlayVfsService", endpointInterface = "org.p2play.service.P2PlayVfsService")
+public class P2PlayVfsServiceImpl implements P2PlayVfsService {
+ private static final String[] EMPTY_STRING = new String[0];
+
+ public void addFolder(AuthenticationToken token, String newFolder)
+ throws FileSystemException {
+ FileObject fileObject = StaticNode.instance().getFileSystemManager()
+ .resolveFile("p2play://" + newFolder);
+
+ fileObject.createFolder();
+ }
+
+ public void addFolder(AuthenticationToken token, String parent,
+ String newFolder) throws FileSystemException {
+ if (!parent.endsWith("/")) {
+ parent += "/";
+ }
+ addFolder(token, parent + newFolder);
+ }
+
+ public String[] getChildren(AuthenticationToken token, String parent)
+ throws FileSystemException {
+ FileObject fileObject = StaticNode.instance().getFileSystemManager()
+ .resolveFile("p2play://" + parent);
+
+ if (fileObject == null || !fileObject.getType().hasChildren())
+ return EMPTY_STRING;
+
+ FileObject[] children = fileObject.getChildren();
+ String[] childStrings = new String[children.length];
+
+ for (int i = 0; i < children.length; i++) {
+ childStrings[i] = children[i].getName().getBaseName();
+ }
+
+ return childStrings;
+ }
+}
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server.node;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.impl.StandardFileSystemManager;
+import org.p2play.boot.pastry.NodeHandler;
+import org.p2play.boot.pastry.Pastry;
+import org.p2play.boot.vfs.PastryFileProvider;
+
+import rice.p2p.commonapi.Node;
+import rice.p2p.past.Past;
+import rice.p2p.past.PastImpl;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeImpl;
+import rice.persistence.LRUCache;
+import rice.persistence.MemoryStorage;
+import rice.persistence.StorageManagerImpl;
+
+public class StaticNode implements NodeHandler {
+ private Node node;
+
+ private Map<String, Past> pastMap = new HashMap<String, Past>();
+
+ private Map<String, Scribe> scribeMap = new HashMap<String, Scribe>();
+
+ private FileSystemManager fileSystemManager;
+
+ private static StaticNode staticNode;
+
+ public Node getNode() {
+ if (node == null)
+ throw new RuntimeException("Node not initialized!");
+ return node;
+ }
+
+ public Past getPast(String instance) {
+ Past past = pastMap.get(instance);
+
+ if (past == null) {
+ past = new PastImpl(node, new StorageManagerImpl(node
+ .getIdFactory(), new MemoryStorage(node.getIdFactory()),
+ new LRUCache(new MemoryStorage(node.getIdFactory()), 100,
+ node.getEnvironment())), 3, instance);
+
+ pastMap.put(instance, past);
+ }
+
+ return past;
+ }
+
+ public Scribe getScribe(String instance) {
+ Scribe scribe = scribeMap.get(instance);
+
+ if (scribe == null) {
+ scribe = new ScribeImpl(getNode(), instance);
+
+ scribeMap.put(instance, scribe);
+ }
+
+ return scribe;
+ }
+
+ public FileSystemManager getFileSystemManager() {
+ if (fileSystemManager == null) {
+ fileSystemManager = new StandardFileSystemManager();
+ try {
+ ((StandardFileSystemManager) fileSystemManager).init();
+ ((StandardFileSystemManager) fileSystemManager).addProvider(
+ "p2play", new PastryFileProvider(this));
+
+ FileObject root = fileSystemManager.resolveFile("p2play:///");
+ FileObject testFolder = fileSystemManager
+ .resolveFile("p2play://test");
+ FileObject testFile = fileSystemManager
+ .resolveFile("p2play://test/file");
+ FileObject testClass = fileSystemManager
+ .resolveFile("p2play://Test.class");
+
+ DataOutputStream dos = new DataOutputStream(testFile
+ .getContent().getOutputStream());
+ dos.writeUTF("test content");
+ dos.close();
+
+ DataInputStream dis = new DataInputStream(testFile.getContent()
+ .getInputStream());
+ System.out.println(dis.readUTF());
+
+ testFolder.createFolder();
+
+ testClass.createFile();
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return fileSystemManager;
+ }
+
+ public void init() {
+ if (node == null) {
+ try {
+ node = Pastry.boot(new InetSocketAddress(InetAddress
+ .getLocalHost(), 10000), InetAddress.getLocalHost(),
+ 10000);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public static StaticNode instance() {
+ if (staticNode == null) {
+ staticNode = new StaticNode();
+ staticNode.init();
+ }
+
+ return staticNode;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|