Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
61 changes: 61 additions & 0 deletions jvm-serializers-protowar/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0"?>
<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>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-protowar</artifactId>
<version>1.0-SNAPSHOT</version>
<name>jvm-serializers-protowar</name>
<description>protowar of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... </description>
<url>http://psychosynthintelligence/protowar</url>
<scm>
<tag>HEAD</tag>
</scm>
<!-- dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
-->
<repositories>
<repository>
<id>jvm-serializers-legacy</id>
<name>jvm-serializers-Repo</name>
<url> file://${basedir}/../src/main/repository </url>
<layout>default</layout>
</repository>
</repositories>
<dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<fork>true</fork>
<meminitial>1024m</meminitial>
<maxmem>1024m</maxmem>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>2.4.1</version>
</plugin>
</plugins>
</reporting>
</project>
24 changes: 24 additions & 0 deletions jvm-serializers-protowar/pom.xml.~1~
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-protowar</artifactId>
<version>1.0-SNAPSHOT</version>
<name>jvm-serializers-protowar</name><description>protowar of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... </description>
<url>http://psychosynthintelligence/protowar</url><scm><tag>HEAD</tag></scm>
<!-- dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
--> <repositories> <repository> <id>jvm-serializers-legacy</id> <name>jvm-serializers-Repo</name> <url> file://${basedir}/../src/main/repository </url> <layout>default</layout> </repository> </repositories> <dependencies> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> <fork>true</fork> <meminitial>1024m</meminitial> <maxmem>1024m</maxmem> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>javacc-maven-plugin</artifactId> <version>2.4.1</version> </plugin> </plugins> </reporting> </project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package jvm-serializers.protowar;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.protowar;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import serializers.ObjectSerializer;
import serializers.ProtobufSerializer;
import serializers.protobuf.MediaContentHolder.MediaContent;
import serializers.protobuf.MediaContentHolder.MediaServer;

import com.google.protobuf.Message;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Descriptors.MethodDescriptor;

class ProtoServerHandler extends MediaServer
{
private final ObjectSerializer<MediaContent> _serializer = new ProtobufSerializer();

@Override
public void updateMedia (RpcController controller, MediaContent request, RpcCallback<MediaContent> done)
{
try
{
//System.out.println(request.getMedia().getUri());
done.run(_serializer.create());
}
catch (Exception e)
{
e.printStackTrace();
}
}

void handle(final OutputStream os, final InputStream is) throws IOException
{
RpcCallback<Message> done = new RpcCallback<Message>()
{
DataOutputStream dos = new DataOutputStream(os);

public void run (Message content)
{
try
{
byte[] array = _serializer.serialize((MediaContent) content);
dos.writeInt(array.length);
dos.write(array);
dos.flush();
}
catch (Exception e)
{
e.printStackTrace();
}
}
};
DataInputStream dis = new DataInputStream(is);
int index = dis.readInt();
MethodDescriptor method = getDescriptor().getMethods().get(index);
byte[] array = new byte[dis.readInt()];
dis.readFully(array);
Message request = getRequestPrototype(method).newBuilderForType().mergeFrom(array).build();
callMethod(method, null, request, done);
}
}
50 changes: 50 additions & 0 deletions jvm-serializers-protowar/src/main/java/org/protowar/ProtoWar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.protowar;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class ProtoWar
*/
public class ProtoWar extends HttpServlet
{
private static final long serialVersionUID = 1L;

private ProtoServerHandler _handler = new ProtoServerHandler();

/**
* Default constructor.
*/
public ProtoWar ()
{
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doIt(request, response);
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doIt(request, response);
}

private void doIt (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
_handler.handle(response.getOutputStream(), request.getInputStream());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package jvm-serializers.protowar;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}

/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
61 changes: 61 additions & 0 deletions jvm-serializers-scala_media_container/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0"?>
<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>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-scala_media_container</artifactId>
<version>1.0-SNAPSHOT</version>
<name>jvm-serializers-scala_media_container</name>
<description>scala_media_container of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... </description>
<url>http://psychosynthintelligence/scala_media_container</url>
<scm>
<tag>HEAD</tag>
</scm>
<!-- dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
-->
<repositories>
<repository>
<id>jvm-serializers-legacy</id>
<name>jvm-serializers-Repo</name>
<url> file://${basedir}/../src/main/repository </url>
<layout>default</layout>
</repository>
</repositories>
<dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<fork>true</fork>
<meminitial>1024m</meminitial>
<maxmem>1024m</maxmem>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>2.4.1</version>
</plugin>
</plugins>
</reporting>
</project>
24 changes: 24 additions & 0 deletions jvm-serializers-scala_media_container/pom.xml.~1~
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>jvm-serializers</groupId>
<artifactId>jvm-serializers-scala_media_container</artifactId>
<version>1.0-SNAPSHOT</version>
<name>jvm-serializers-scala_media_container</name><description>scala_media_container of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... </description>
<url>http://psychosynthintelligence/scala_media_container</url><scm><tag>HEAD</tag></scm>
<!-- dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
--> <repositories> <repository> <id>jvm-serializers-legacy</id> <name>jvm-serializers-Repo</name> <url> file://${basedir}/../src/main/repository </url> <layout>default</layout> </repository> </repositories> <dependencies> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> <fork>true</fork> <meminitial>1024m</meminitial> <maxmem>1024m</maxmem> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>javacc-maven-plugin</artifactId> <version>2.4.1</version> </plugin> </plugins> </reporting> </project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package jvm-serializers.scala_media_container;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package serializers.scala

@serializable
case class Image(uri: String, title: String, width: Int, height: Int, size: Size.Value)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package serializers.scala

@serializable
class Media (val uri: String, val title: String,
val width: Int, val height: Int, val format: String,
val duration: Long, val size: Long,
val bitrate: Int,
val copyright: Option[String],
val player: Player.Value){

def this(uri: String, title: String,
width: Int, height: Int, format: String,
duration: Long, size: Long,
bitrate: Int,
player: Player.Value) = this(uri, title, width, height, format, duration, size, bitrate, None, player)

private var _persons: List[String] = Nil
def persons = _persons

def addPerson(persons: String){
_persons = persons :: _persons
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package serializers.scala
@serializable
class MediaContent (val media: Media){
var _images: List[Image] = Nil
def images = _images

def addImage(image: Image){
_images = image :: _images
}
}
Loading