From 11e665cb7d83eef02ed2d741f95d27b2be1fb873 Mon Sep 17 00:00:00 2001 From: Constantin Jucovschi <jucovschi@gmail.com> Date: Wed, 23 Apr 2014 17:27:01 +0200 Subject: [PATCH] adding appjs theo --- .../bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar | 1 + OfficeBase/.classpath | 27 ++++ OfficeBase/.project | 23 +++ .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.eclipse.m2e.core.prefs | 4 + OfficeBase/pom.xml | 108 +++++++++++++ .../kwarc/sally4/officebase/SelectClient.java | 7 + .../factories/OfficeBaseFactory.java | 56 +++++++ .../officebase/impl/OfficeBaseInstance.java | 55 +++++++ .../src/main/resources/libs/mhwsettings.png | Bin 0 -> 702 bytes .../src/main/resources/mathhubworker.xsd | 5 + .../main/resources/templates/mhwsettings.html | 30 ++++ .../impl/MathHubWorkerManagerImplTest.java | 63 ++++++++ .../sally/comm/core/Heartbeatrequest.java | 2 +- .../sally/comm/core/Heartbeatresponse.java | 2 +- .../kwarc/sally/comm/core/ObjectFactory.java | 10 +- .../sally/comm/core/Registerdocument.java | 2 +- .../comm/core/Registerdocumentresponse.java | 2 +- .../kwarc/sally/comm/core/package-info.java | 2 +- .../sally/comm/select/ObjectFactory.java | 47 ++++++ .../comm/{core => select}/Onsallyframe.java | 4 +- .../kwarc/sally/comm/select/package-info.java | 9 ++ core/src/main/resources/core.xsd | 9 -- core/src/main/resources/select.xsd | 11 +- .../sally4/docmanager/impl/SallyDocImpl.java | 1 - pom.xml | 1 + theo/.gitignore | 2 + theo/app.coffee | 45 ++++++ theo/app.js | 54 +++++++ theo/content/index.html | 10 ++ theo/npm.sh | 2 + theo/sally_client.coffee | 90 +++++++++++ theo/sally_client.js | 142 ++++++++++++++++++ theo/start.sh | 2 + .../processors/EnrichMessageProperties.java | 18 ++- 35 files changed, 821 insertions(+), 30 deletions(-) create mode 120000 Felix/bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar create mode 100644 OfficeBase/.classpath create mode 100644 OfficeBase/.project create mode 100644 OfficeBase/.settings/org.eclipse.jdt.core.prefs create mode 100644 OfficeBase/.settings/org.eclipse.m2e.core.prefs create mode 100644 OfficeBase/pom.xml create mode 100644 OfficeBase/src/main/java/info/kwarc/sally4/officebase/SelectClient.java create mode 100644 OfficeBase/src/main/java/info/kwarc/sally4/officebase/factories/OfficeBaseFactory.java create mode 100644 OfficeBase/src/main/java/info/kwarc/sally4/officebase/impl/OfficeBaseInstance.java create mode 100644 OfficeBase/src/main/resources/libs/mhwsettings.png create mode 100644 OfficeBase/src/main/resources/mathhubworker.xsd create mode 100644 OfficeBase/src/main/resources/templates/mhwsettings.html create mode 100644 OfficeBase/src/test/java/info/kwarc/sally4/mathhubworker/impl/MathHubWorkerManagerImplTest.java create mode 100644 core/src/main/java/info/kwarc/sally/comm/select/ObjectFactory.java rename core/src/main/java/info/kwarc/sally/comm/{core => select}/Onsallyframe.java (95%) create mode 100644 core/src/main/java/info/kwarc/sally/comm/select/package-info.java create mode 100644 theo/.gitignore create mode 100644 theo/app.coffee create mode 100644 theo/app.js create mode 100644 theo/content/index.html create mode 100755 theo/npm.sh create mode 100644 theo/sally_client.coffee create mode 100644 theo/sally_client.js create mode 100755 theo/start.sh diff --git a/Felix/bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar b/Felix/bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar new file mode 120000 index 0000000..11ad150 --- /dev/null +++ b/Felix/bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar @@ -0,0 +1 @@ +/home/costea/workspace_sally4/sally4.git/OfficeBase/target/OfficeBase-0.0.3-SNAPSHOT.jar \ No newline at end of file diff --git a/OfficeBase/.classpath b/OfficeBase/.classpath new file mode 100644 index 0000000..6a3cba6 --- /dev/null +++ b/OfficeBase/.classpath @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" output="target/classes" path="src/main/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" output="target/test-classes" path="src/test/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry including="**/*.java" kind="src" path="src/main/resources"/> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="output" path="target/classes"/> +</classpath> diff --git a/OfficeBase/.project b/OfficeBase/.project new file mode 100644 index 0000000..f01d1fb --- /dev/null +++ b/OfficeBase/.project @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>OfficeBase</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + </natures> +</projectDescription> diff --git a/OfficeBase/.settings/org.eclipse.jdt.core.prefs b/OfficeBase/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..60105c1 --- /dev/null +++ b/OfficeBase/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/OfficeBase/.settings/org.eclipse.m2e.core.prefs b/OfficeBase/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/OfficeBase/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/OfficeBase/pom.xml b/OfficeBase/pom.xml new file mode 100644 index 0000000..c1d7c66 --- /dev/null +++ b/OfficeBase/pom.xml @@ -0,0 +1,108 @@ +<?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/xsd/maven-4.0.0.xsd"> + + <!-- 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. --> + + <modelVersion>4.0.0</modelVersion> + + <packaging>bundle</packaging> + + <groupId>info.kwarc.sally4</groupId> + <artifactId>OfficeBase</artifactId> + <version>${sally4.version}</version> + + <parent> + <groupId>info.kwarc.sally</groupId> + <artifactId>sally</artifactId> + <version>1.0</version> + <relativePath>..</relativePath> + </parent> + + + <dependencies> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>4.3.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.ipojo.annotations</artifactId> + <version>1.11.2</version> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + <version>${camel.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>core</artifactId> + <version>${sally4.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>utils</artifactId> + <version>${sally4.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>docmanager</artifactId> + <version>${sally4.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>servlet</artifactId> + <version>${sally4.version}</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <!-- BND Maven Plugin Configuration --> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> + <Private-Package>info.kwarc.sally4.officebase.impl*</Private-Package> + <Export-Package>info.kwarc.sally4.officebase*;libs*</Export-Package> + </instructions> + </configuration> + </plugin> + <!-- iPOJO Maven Plugin Configuration : nothing to do --> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-ipojo-plugin</artifactId> + <version>1.11.2</version> + <executions> + <execution> + <goals> + <goal>ipojo-bundle</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/OfficeBase/src/main/java/info/kwarc/sally4/officebase/SelectClient.java b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/SelectClient.java new file mode 100644 index 0000000..3a01499 --- /dev/null +++ b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/SelectClient.java @@ -0,0 +1,7 @@ +package info.kwarc.sally4.officebase; + +import info.kwarc.sally4.docmanager.SallyDoc; + +public interface SelectClient { + SallyDoc getDoc(); +} diff --git a/OfficeBase/src/main/java/info/kwarc/sally4/officebase/factories/OfficeBaseFactory.java b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/factories/OfficeBaseFactory.java new file mode 100644 index 0000000..03f6307 --- /dev/null +++ b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/factories/OfficeBaseFactory.java @@ -0,0 +1,56 @@ +package info.kwarc.sally4.officebase.factories; + +import info.kwarc.sally4.docmanager.SallyDoc; + +import java.util.Dictionary; +import java.util.Hashtable; + +import org.apache.felix.ipojo.ComponentInstance; +import org.apache.felix.ipojo.ConfigurationException; +import org.apache.felix.ipojo.Factory; +import org.apache.felix.ipojo.InstanceStateListener; +import org.apache.felix.ipojo.MissingHandlerException; +import org.apache.felix.ipojo.UnacceptableConfiguration; +import org.apache.felix.ipojo.annotations.Bind; +import org.apache.felix.ipojo.annotations.Component; +import org.apache.felix.ipojo.annotations.Instantiate; +import org.apache.felix.ipojo.annotations.Requires; + +@Component +@Instantiate +public class OfficeBaseFactory { + @Requires(filter="(factory.name=SelectInstance)") + Factory selectWorkflows; + + void createInstance(Factory factory, String name, String docQueue) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException { + Dictionary<String, Object> configuration = new Hashtable<String, Object>(); + Dictionary<String, Object> filters = new Hashtable<String, Object>(); + + filters.put("docQueue", "(docQueue="+docQueue+")"); + + configuration.put("requires.filters", filters); + + configuration.put("instance.name", name+" for doc:"+docQueue); + + ComponentInstance inst = factory.createComponentInstance(configuration); + inst.addInstanceStateListener(new InstanceStateListener() { + + @Override + public void stateChanged(ComponentInstance arg0, int arg1) { + if (arg1 == ComponentInstance.INVALID) { + arg0.dispose(); + } + } + }); + } + + @Bind(aggregate=true) + void newSallyDoc(SallyDoc newDoc) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException { + for (String iface : newDoc.getInterfaces()) { + if ("select".equals(iface)) { + createInstance(selectWorkflows, "SelectClient", newDoc.getDocQueue()); + return; + } + } + } +} diff --git a/OfficeBase/src/main/java/info/kwarc/sally4/officebase/impl/OfficeBaseInstance.java b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/impl/OfficeBaseInstance.java new file mode 100644 index 0000000..8f97bc7 --- /dev/null +++ b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/impl/OfficeBaseInstance.java @@ -0,0 +1,55 @@ +package info.kwarc.sally4.officebase.impl; + +import info.kwarc.sally4.core.CamelContextProvider; +import info.kwarc.sally4.core.SallyInteraction; +import info.kwarc.sally4.docmanager.SallyDoc; +import info.kwarc.sally4.marshalling.CommUtils; +import info.kwarc.sally4.officebase.SelectClient; +import info.kwarc.sally4.servlet.SallyServlet; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.spi.DataFormat; +import org.apache.felix.ipojo.annotations.Component; +import org.apache.felix.ipojo.annotations.Provides; +import org.apache.felix.ipojo.annotations.Requires; +import org.apache.felix.ipojo.annotations.Validate; + +@Component(name="SelectInstance") +@Provides(specifications=SelectClient.class) +public class OfficeBaseInstance extends RouteBuilder implements SelectClient{ + String planetaryClientNamespace = "http://kwarc.info/sally/comm/planetaryclient"; + + @Requires + SallyServlet t; + + @Requires(id="docQueue", filter="(filterThatWillNeverSucceed=1)") + SallyDoc route; + + @Requires + SallyInteraction interact; + + @Requires + CamelContextProvider camelContextProvider; + + @Validate + void doStart() { + } + + public OfficeBaseInstance() { + } + + @Override + public void configure() throws Exception { + DataFormat worker = CommUtils.getDataFormat("mathhubworker", getClass().getClassLoader()); + getContext().addComponent("alex", route.getAlexComponent()); + + from("direct:start") + .to("direct:requestAuthKey"); + } + + @Override + public SallyDoc getDoc() { + return route; + } + +} diff --git a/OfficeBase/src/main/resources/libs/mhwsettings.png b/OfficeBase/src/main/resources/libs/mhwsettings.png new file mode 100644 index 0000000000000000000000000000000000000000..310f39a0af2dbeb5a91ce4617eca569a06d290dd GIT binary patch literal 702 zcmV;v0zv(WP)<h;3K|Lk000e1NJLTq000;O000;W1^@s6;CDUv0007oNkl<ZcwW_% z0c2HC9LB$M-`!SXia`{fKxhIadPPZ~#IQ)Usw`oFlt!X3Qf<n%RbtA(2qB185K?Sf zk=nFc^YXT}RqO5DbN>Ck_j$YTdbe%?ef)ga-+kYA&O6S<e=id=&nQDkuC2<Gqy?FD zIz4pv!Bf1Mm_`yE+0__Z;#FCB@^Etd;V`)4%%653!|${B@MR8vtL)Sy4)4iCGvOnm zm!o4CdHbo<1_yBh5eG+iqVDLS`E+&?)#M>YBBgNWoT4sthDYZq-%nZ~Tp5XZ7NILJ z4u!>hvI2<-=Dcb-XUPf<?cN*>j^9bRRFV{s&eP3RgRQld&o(G8!dgjQaOYkhuAkk{ zFe$r0O0IJOAcEpN2!6r_g>a^c7Dy3l$IcA8dM~4={UB@*EFEafp?fJG@H|kpN{S^Y zPqWign97YIJ3E27g&a0+S&QEOtGIRH=<m-UR8G~0OZ<wG`EkrI%;0-|1}dZ*>(SZM zfwtD;IB>2ze6bYa0Sk;NIn|(uVii~Mf92*sGki(wH#MN;WE1)?oj?#+SQ|iHQMV;` zQkqjMmE~MGDt7SbSs$W$_bP{h8zX3H>nL6(FO}lwg1Zn0h$+sf6-tV^#^(;uHQ0=( zUcbm<uzM6OXRe^OZdv(rAOcut0d)t5IuH05y=ct!L0vrd7!=xXZYzgpnp!bFJ_gUP zfoD930VH$|1m9+JpaQy8!~m$_$*)n)D|`2y+JJ#;Blrj1XGT_;Q3{4<P^YX?Rx8gL zuw7YDesDD|axqPalmfp0Rhd)rO5pQ{c{W-GtW)wNP=rDB@-xDhN-6ODMY@>CXQPIf kMEJ5JTyd-nU5KOO7oNU9nEaAbNdN!<07*qoM6N<$g37K$mjD0& literal 0 HcmV?d00001 diff --git a/OfficeBase/src/main/resources/mathhubworker.xsd b/OfficeBase/src/main/resources/mathhubworker.xsd new file mode 100644 index 0000000..2f6b4d5 --- /dev/null +++ b/OfficeBase/src/main/resources/mathhubworker.xsd @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://kwarc.info/sally/comm/mathhubworker" elementFormDefault="qualified"> + +</xs:schema> \ No newline at end of file diff --git a/OfficeBase/src/main/resources/templates/mhwsettings.html b/OfficeBase/src/main/resources/templates/mhwsettings.html new file mode 100644 index 0000000..46ef9f3 --- /dev/null +++ b/OfficeBase/src/main/resources/templates/mhwsettings.html @@ -0,0 +1,30 @@ +<html> +<script type="text/javascript" src=""></script> +<script src='/sally/jobad/libs/js/libs.js'></script> +<link rel='stylesheet' type='text/css' href='/sally/jobad/libs/css/libs.css'> +<script src='/sally/jobad/JOBAD.min.js'></script> +<link rel='stylesheet' type='text/css' href='/sally/jobad/JOBAD.min.css'> + +<body class="bootstrap"> + +<div class="navbar navbar-inverse"> + <div class="navbar-inner"> + <a class="brand" href="#">MathHub Workers</a> + </div> +</div> + + <#list body.env?keys as e> + <form action="setmhw"> + <div class="row-fluid"> + <div class="span1">${e_index+1}.</div> + <button class="span11 btn"> + ${body.env[e].getDescription()} + </button> + <input type="hidden" name="envid" value="${e}" /> + <input type="hidden" name="id" value="${body.doc_queue_id}" /> + </div> + </form> + </#list> + +</body> +</html> \ No newline at end of file diff --git a/OfficeBase/src/test/java/info/kwarc/sally4/mathhubworker/impl/MathHubWorkerManagerImplTest.java b/OfficeBase/src/test/java/info/kwarc/sally4/mathhubworker/impl/MathHubWorkerManagerImplTest.java new file mode 100644 index 0000000..947cfca --- /dev/null +++ b/OfficeBase/src/test/java/info/kwarc/sally4/mathhubworker/impl/MathHubWorkerManagerImplTest.java @@ -0,0 +1,63 @@ +package info.kwarc.sally4.mathhubworker.impl; +/* + +import info.kwarc.sally4.docmanager.SallyDoc; +import info.kwarc.sally4.docmanager.impl.SallyDocImpl; +import info.kwarc.sally4.docmanager.mocks.MockDocumentManager; +import info.kwarc.sally4.docmanager.mocks.MockGlobalContextProvider; +import info.kwarc.sally4.mathhubworker.routes.LMHWorkflowInstance; + +import org.apache.camel.CamelContext; +import org.apache.camel.EndpointInject; +import org.apache.camel.Exchange; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; +public class MathHubWorkerManagerImplTest extends CamelTestSupport{ + MockDocumentManager man; + MathHubWorkerManagerImpl workerManager; + + @EndpointInject(uri="sallyservlet:///planetary/mhwsettings") + ProducerTemplate starter; + + @EndpointInject(uri="mock:result") + MockEndpoint result; + + public MathHubWorkerManagerImplTest() { + } + + @Test + public void test() throws Exception { + LMHWorkflow lmhWorkflow = new LMHWorkflow(); + + SallyDoc alexRoute = new SallyDocImpl("lmhqueue", "e1", "u1", "", new String[]{"lmhworker"}); + LMHWorkflowInstance lmhInstance = new LMHWorkflowInstance(alexRoute, lmhWorkflow); + man.addWorkflowInstances(lmhInstance); + + starter.sendBody(""); + for (Exchange e: result.getExchanges()) { + System.out.println(e.getIn().getBody(String.class)); + } + } + + @Test + public void test2() throws Exception { + LMHWorkflow lmhWorkflow = new LMHWorkflow(); + SallyDoc alexRoute = new SallyDocImpl("q1", "e1", "u1", "", new String[]{"lmhworker"}); + LMHWorkflowInstance lmhInstance = new LMHWorkflowInstance(alexRoute, lmhWorkflow); + man.addWorkflowInstances(lmhInstance); + starter.sendBody(""); + } + + @Override + protected CamelContext createCamelContext() throws Exception { + man = new MockDocumentManager(); + workerManager = new MathHubWorkerManagerImpl(); + workerManager.docManager = man; + workerManager.camelContextProvider = new MockGlobalContextProvider(); + workerManager.start(); + return workerManager.getContext(); + } +} +*/ \ No newline at end of file diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java index 8b226e0..7d0edcb 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java index eac507c..1abd0a2 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java b/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java index 1469041..cb668ad 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // @@ -52,14 +52,6 @@ public class ObjectFactory { return new Registerdocumentresponse(); } - /** - * Create an instance of {@link Onsallyframe } - * - */ - public Onsallyframe createOnsallyframe() { - return new Onsallyframe(); - } - /** * Create an instance of {@link Heartbeatrequest } * diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java index bf4a06f..49fcd68 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java index 34e07e5..6d75813 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/package-info.java b/core/src/main/java/info/kwarc/sally/comm/core/package-info.java index 266de15..475a5c5 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/package-info.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/package-info.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // @javax.xml.bind.annotation.XmlSchema(namespace = "http://kwarc.info/sally/comm/core", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) diff --git a/core/src/main/java/info/kwarc/sally/comm/select/ObjectFactory.java b/core/src/main/java/info/kwarc/sally/comm/select/ObjectFactory.java new file mode 100644 index 0000000..e7900c5 --- /dev/null +++ b/core/src/main/java/info/kwarc/sally/comm/select/ObjectFactory.java @@ -0,0 +1,47 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.04.23 at 01:50:46 PM CEST +// + + +package info.kwarc.sally.comm.select; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the info.kwarc.sally.comm.select package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: info.kwarc.sally.comm.select + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Onsallyframe } + * + */ + public Onsallyframe createOnsallyframe() { + return new Onsallyframe(); + } + +} diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Onsallyframe.java b/core/src/main/java/info/kwarc/sally/comm/select/Onsallyframe.java similarity index 95% rename from core/src/main/java/info/kwarc/sally/comm/core/Onsallyframe.java rename to core/src/main/java/info/kwarc/sally/comm/select/Onsallyframe.java index 1a288bb..a2f1b22 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Onsallyframe.java +++ b/core/src/main/java/info/kwarc/sally/comm/select/Onsallyframe.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 01:50:46 PM CEST // -package info.kwarc.sally.comm.core; +package info.kwarc.sally.comm.select; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/core/src/main/java/info/kwarc/sally/comm/select/package-info.java b/core/src/main/java/info/kwarc/sally/comm/select/package-info.java new file mode 100644 index 0000000..bd80b18 --- /dev/null +++ b/core/src/main/java/info/kwarc/sally/comm/select/package-info.java @@ -0,0 +1,9 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.04.23 at 01:50:46 PM CEST +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://kwarc.info/sally/comm/select") +package info.kwarc.sally.comm.select; diff --git a/core/src/main/resources/core.xsd b/core/src/main/resources/core.xsd index fbfdd0e..4734e25 100644 --- a/core/src/main/resources/core.xsd +++ b/core/src/main/resources/core.xsd @@ -23,15 +23,6 @@ </xs:complexType> </xs:element> - <xs:element name="onsallyframe"> - <xs:complexType> - <xs:sequence> - <xs:element name="posx" type="xs:int" /> - <xs:element name="posy" type="xs:int" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <xs:element name="heartbeatrequest"> <xs:complexType> </xs:complexType> diff --git a/core/src/main/resources/select.xsd b/core/src/main/resources/select.xsd index 3fc8398..488b0b2 100644 --- a/core/src/main/resources/select.xsd +++ b/core/src/main/resources/select.xsd @@ -1,6 +1,15 @@ <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://kwarc.info/sally/comm/select"> - + <xs:element name="onsallyframe"> + <xs:complexType> + <xs:sequence> + <xs:element name="posx" type="xs:int" /> + <xs:element name="posy" type="xs:int" /> + </xs:sequence> + </xs:complexType> + </xs:element> + + </xs:schema> \ No newline at end of file diff --git a/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java b/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java index 07c51d4..f06534a 100644 --- a/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java +++ b/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java @@ -92,7 +92,6 @@ public class SallyDocImpl extends RouteBuilder implements SallyDoc { @Override public ProducerConsumerSplitterComponent getAlexComponent() { - log.info("will start on queue "+docStateQueue); return new ProducerConsumerSplitterComponent("activemq:queue:"+docStateQueue, "activemq:queue:"+docQueue); } diff --git a/pom.xml b/pom.xml index 6097288..57f92a8 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ <module>planetary</module> <module>servlet</module> <module>MathHubWorker</module> + <module>OfficeBase</module> <module>activemq</module> </modules> diff --git a/theo/.gitignore b/theo/.gitignore new file mode 100644 index 0000000..3637965 --- /dev/null +++ b/theo/.gitignore @@ -0,0 +1,2 @@ +node +node_modules \ No newline at end of file diff --git a/theo/app.coffee b/theo/app.coffee new file mode 100644 index 0000000..a8efa5d --- /dev/null +++ b/theo/app.coffee @@ -0,0 +1,45 @@ +appjs = require('appjs'); +async = require "async" + +http = require('http') +express = require('express'); +connect = require('connect') + +SallyClient = (require "./sally_client").SallyClient + +stomp_args = + port : 61613, + host: 'localhost', + login: 'webclient', + passcode: 'webclient', +# debug: true, + +handler = (body, msg) => + console.log(msg); + +sally = new SallyClient stomp_args, handler +sally.connect ["theo"], (body, msg)-> + console.log("connected "); + +createNewWindow = (body) -> + window = appjs.createWindow(body.url, { + width : 640, + height : 460, + }); + + window.on('create', () -> + window.frame.show(); + window.frame.center(); + ) + + window.on('ready', () -> + window.process = process; + window.module = module; + ); + + window.on('close', () -> + console.log("Window Closed"); + ); + +#process.on 'SIGINT', () -> +# client.disconnect() diff --git a/theo/app.js b/theo/app.js new file mode 100644 index 0000000..3739a93 --- /dev/null +++ b/theo/app.js @@ -0,0 +1,54 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + var SallyClient, appjs, async, connect, createNewWindow, express, handler, http, sally, stomp_args, + _this = this; + + appjs = require('appjs'); + + async = require("async"); + + http = require('http'); + + express = require('express'); + + connect = require('connect'); + + SallyClient = (require("./sally_client")).SallyClient; + + stomp_args = { + port: 61613, + host: 'localhost', + login: 'webclient', + passcode: 'webclient' + }; + + handler = function(body, msg) { + return console.log(msg); + }; + + sally = new SallyClient(stomp_args, handler); + + sally.connect(["theo"], function(body, msg) { + return console.log("connected "); + }); + + createNewWindow = function(body) { + var window; + window = appjs.createWindow(body.url, { + width: 640, + height: 460 + }); + window.on('create', function() { + window.frame.show(); + return window.frame.center(); + }); + window.on('ready', function() { + window.process = process; + return window.module = module; + }); + return window.on('close', function() { + return console.log("Window Closed"); + }); + }; + +}).call(this); diff --git a/theo/content/index.html b/theo/content/index.html new file mode 100644 index 0000000..ef5f9f1 --- /dev/null +++ b/theo/content/index.html @@ -0,0 +1,10 @@ +<!doctype html> +<html> + <head> + <title>Hello World!</title> + <link rel="stylesheet" href="style.css"> + </head> + <body> + <h1>Hello World!</h1> + </body> +</html> diff --git a/theo/npm.sh b/theo/npm.sh new file mode 100755 index 0000000..0364840 --- /dev/null +++ b/theo/npm.sh @@ -0,0 +1,2 @@ +#!/bin/bash +node/bin/npm install $1 \ No newline at end of file diff --git a/theo/sally_client.coffee b/theo/sally_client.coffee new file mode 100644 index 0000000..e9f8a18 --- /dev/null +++ b/theo/sally_client.coffee @@ -0,0 +1,90 @@ +Stomp = require "stomp" +xml2js = require("xml2js"); +EventEmitter = require('events').EventEmitter +builder = new xml2js.Builder() + +createRegisterDocument = (docQueue, theoQueue, interfaces) -> + { + "registerdocument" : + '$' : + "xmlns" : "http://kwarc.info/sally/comm/core" + "documentqueue" : [ docQueue ], + "environmentid" : [ process.env.SALLYENVID ], + "interfaces" : interfaces + } + +connections = {}; + +class SallyClient + constructor : (@config, @msgHandler) -> + if connections[config.stompUrl]? + @stompClient = connections[config.stompUrl] + else + @stompClient = new Stomp.Stomp(config) + connections[config.stompUrl] = @stompClient + @stompClient.connect() + + @stompClient.on "connected", => + @stompClient.connection_div.emit("onConnected"); + + + registerDocument : (interfaces, callback) => + msg = createRegisterDocument(@privateQueue, @privateQueue+"_theo", interfaces) + @send("/queue/sally_register", msg, (msg) => + @sally_queue = msg["registerdocumentresponse"]["sallyqueue"]; + callback(); + ) + + connect : (@interfaces, callback) -> + client = @stompClient + if client.connected + return callback(); + if not client.connection_div? + client.connection_div = new EventEmitter(); + + client.connection_div.on("onConnected", (e) => + @privateQueue = "theo_"+Math.floor(Math.random()*100000); + @stompClient.subscribe({destination : "/queue/"+@privateQueue}, @stompMsgHandler) + @registerDocument(@interfaces, callback) + ) + + sendSally : (msg, callback, headers) -> + @send(@sally_queue, msg, callback, headers) + + send : (destination, msg, callback, headers) -> + if typeof msg == "object" + msg = builder.buildObject(msg) + + if callback? + corrid = Math.random(); + queue_post = "/temp-queue/editor_exchange"+corrid; + sub = @stompClient.subscribe({destination : queue_post}, (msg) => + xml2js.parseString msg, (err, body) => + if (not body.html?) and callback(body, msg) == true + return; + @stompClient.unsubscribe({destination : queue_post}); + ) + + headers ?= {}; + headers["reply-to"] = queue_post; + headers["correlation-id"] = corrid; + + headers["destination"] = destination; + headers["body"] = msg; + @stompClient.send(headers) + + stompMsgHandler : (msg, msgHeaders) => + msg = msg[0]; + + body = xml2js.parseString msg, (err,body) => + if body["heartbeatrequest"]? and body["heartbeatrequest"]["$"]["xmlns"] == "http://kwarc.info/sally/comm/core" + @send(msgHeaders["reply-to"], {"heartbeatresponse" : {"$" : { "xmlns" : "http://kwarc.info/sally/comm/core"}}}, null, + {"correlation-id" : msgHeaders["correlation-id"]}) + return; + + @msgHandler(body, msg, (sendBack) => + @send(msgHeaders["reply-to"], sendBack, null, + {"correlation-id" : msgHeaders["correlation-id"]}) + ); + +exports.SallyClient = SallyClient \ No newline at end of file diff --git a/theo/sally_client.js b/theo/sally_client.js new file mode 100644 index 0000000..280ad82 --- /dev/null +++ b/theo/sally_client.js @@ -0,0 +1,142 @@ +// Generated by CoffeeScript 1.6.3 +var EventEmitter, SallyClient, Stomp, builder, connections, createRegisterDocument, xml2js, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + +Stomp = require("stomp"); + +xml2js = require("xml2js"); + +EventEmitter = require('events').EventEmitter; + +builder = new xml2js.Builder(); + +createRegisterDocument = function(docQueue, theoQueue, interfaces) { + return { + "registerdocument": { + '$': { + "xmlns": "http://kwarc.info/sally/comm/core" + }, + "documentqueue": [docQueue], + "environmentid": [process.env.SALLYENVID], + "interfaces": interfaces + } + }; +}; + +connections = {}; + +SallyClient = (function() { + function SallyClient(config, msgHandler) { + var _this = this; + this.config = config; + this.msgHandler = msgHandler; + this.stompMsgHandler = __bind(this.stompMsgHandler, this); + this.registerDocument = __bind(this.registerDocument, this); + if (connections[config.stompUrl] != null) { + this.stompClient = connections[config.stompUrl]; + } else { + this.stompClient = new Stomp.Stomp(config); + connections[config.stompUrl] = this.stompClient; + this.stompClient.connect(); + this.stompClient.on("connected", function() { + return _this.stompClient.connection_div.emit("onConnected"); + }); + } + } + + SallyClient.prototype.registerDocument = function(interfaces, callback) { + var msg, + _this = this; + msg = createRegisterDocument(this.privateQueue, this.privateQueue + "_theo", interfaces); + return this.send("/queue/sally_register", msg, function(msg) { + _this.sally_queue = msg["registerdocumentresponse"]["sallyqueue"]; + return callback(); + }); + }; + + SallyClient.prototype.connect = function(interfaces, callback) { + var client, + _this = this; + this.interfaces = interfaces; + client = this.stompClient; + if (client.connected) { + return callback(); + } + if (client.connection_div == null) { + client.connection_div = new EventEmitter(); + } + return client.connection_div.on("onConnected", function(e) { + _this.privateQueue = "theo_" + Math.floor(Math.random() * 100000); + _this.stompClient.subscribe({ + destination: "/queue/" + _this.privateQueue + }, _this.stompMsgHandler); + return _this.registerDocument(_this.interfaces, callback); + }); + }; + + SallyClient.prototype.sendSally = function(msg, callback, headers) { + return this.send(this.sally_queue, msg, callback, headers); + }; + + SallyClient.prototype.send = function(destination, msg, callback, headers) { + var corrid, queue_post, sub, + _this = this; + if (typeof msg === "object") { + msg = builder.buildObject(msg); + } + if (callback != null) { + corrid = Math.random(); + queue_post = "/temp-queue/editor_exchange" + corrid; + sub = this.stompClient.subscribe({ + destination: queue_post + }, function(msg) { + return xml2js.parseString(msg, function(err, body) { + if ((body.html == null) && callback(body, msg) === true) { + return; + } + return _this.stompClient.unsubscribe({ + destination: queue_post + }); + }); + }); + if (headers == null) { + headers = {}; + } + headers["reply-to"] = queue_post; + headers["correlation-id"] = corrid; + } + headers["destination"] = destination; + headers["body"] = msg; + return this.stompClient.send(headers); + }; + + SallyClient.prototype.stompMsgHandler = function(msg, msgHeaders) { + var body, + _this = this; + msg = msg[0]; + return body = xml2js.parseString(msg, function(err, body) { + if ((body["heartbeatrequest"] != null) && body["heartbeatrequest"]["$"]["xmlns"] === "http://kwarc.info/sally/comm/core") { + _this.send(msgHeaders["reply-to"], { + "heartbeatresponse": { + "$": { + "xmlns": "http://kwarc.info/sally/comm/core" + } + } + }, null, { + "correlation-id": msgHeaders["correlation-id"] + }); + return; + } + return _this.msgHandler(body, msg, function(sendBack) { + return _this.send(msgHeaders["reply-to"], sendBack, null, { + "correlation-id": msgHeaders["correlation-id"] + }); + }); + }); + }; + + return SallyClient; + +})(); + +exports.SallyClient = SallyClient; diff --git a/theo/start.sh b/theo/start.sh new file mode 100755 index 0000000..351fba8 --- /dev/null +++ b/theo/start.sh @@ -0,0 +1,2 @@ +coffee -c app.coffee +node/bin/node --harmony app.js \ No newline at end of file diff --git a/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java b/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java index 3e27ff2..447a3d2 100644 --- a/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java +++ b/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java @@ -7,6 +7,8 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.slf4j.Logger; +import com.sun.xml.txw2.annotation.XmlNamespace; + public class EnrichMessageProperties implements Processor { static final public String MessageType = "XMLMessageType"; @@ -15,14 +17,15 @@ public class EnrichMessageProperties implements Processor { Logger log; Pattern xmlNamespace = Pattern.compile("<(\\w+)\\s+xmlns=\"([\\w/:.]+)\"/>"); + Pattern xmlNamespace2 = Pattern.compile("<((\\w+):)?(\\w+)\\s+xmlns(:(\\w+))?=\"([\\w/:.]+)\">"); public void process(Exchange exchange) throws Exception { XMLMessageWithTypeInfo result = new XMLMessageWithTypeInfo(); String body = exchange.getIn().getBody(String.class); - Matcher m = xmlNamespace.matcher(body); + Matcher m = xmlNamespace2.matcher(body); if (m.find()) { - String msgType = m.group(1); - String namespace = m.group(2); + String msgType = m.group(3); + String namespace = m.group(6); result.setXmlMessageNamespace(namespace); result.setXmlMessageType(msgType); exchange.getIn().setBody(result); @@ -31,4 +34,13 @@ public class EnrichMessageProperties implements Processor { } } + public static void main(String[] args) { + String t = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ns2:onsallyframe xmlns:ns2=\"http://kwarc.info/sally/comm/select\">"; + Pattern xmlNamespace2 = Pattern.compile(""); + Matcher m = xmlNamespace2.matcher(t); + if (m.find()) { + System.out.println(m.group(3)); + System.out.println(m.group(6)); + } + } } -- GitLab