You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by th...@apache.org on 2007/02/28 12:30:00 UTC
svn commit: r512712 - in
/labs/droids/src/plugins/protocol-httpclient-crowbar: ./ lib/ src/
src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/droids/
src/java/org/apache/droids/protocol/
src/java/org/apache/droids/protocol/httpclient/ sr...
Author: thorsten
Date: Wed Feb 28 03:29:51 2007
New Revision: 512712
URL: http://svn.apache.org/viewvc?view=rev&rev=512712
Log:
Adding experimental crowbar integration. This plugin made me integrate ivy for dependecy management. See the ivy.xml for mor details
Added:
labs/droids/src/plugins/protocol-httpclient-crowbar/
labs/droids/src/plugins/protocol-httpclient-crowbar/build.xml (with props)
labs/droids/src/plugins/protocol-httpclient-crowbar/ivy.xml
labs/droids/src/plugins/protocol-httpclient-crowbar/lib/
labs/droids/src/plugins/protocol-httpclient-crowbar/plugin.xml (with props)
labs/droids/src/plugins/protocol-httpclient-crowbar/src/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/crowbar/
labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/crowbar/Http.java (with props)
Added: labs/droids/src/plugins/protocol-httpclient-crowbar/build.xml
URL: http://svn.apache.org/viewvc/labs/droids/src/plugins/protocol-httpclient-crowbar/build.xml?view=auto&rev=512712
==============================================================================
--- labs/droids/src/plugins/protocol-httpclient-crowbar/build.xml (added)
+++ labs/droids/src/plugins/protocol-httpclient-crowbar/build.xml Wed Feb 28 03:29:51 2007
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!--
+ 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="protocol-httpclient" default="droids.jar-core">
+ <import file="../build-plugin.xml"/>
+</project>
Propchange: labs/droids/src/plugins/protocol-httpclient-crowbar/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: labs/droids/src/plugins/protocol-httpclient-crowbar/build.xml
------------------------------------------------------------------------------
svn:executable = *
Added: labs/droids/src/plugins/protocol-httpclient-crowbar/ivy.xml
URL: http://svn.apache.org/viewvc/labs/droids/src/plugins/protocol-httpclient-crowbar/ivy.xml?view=auto&rev=512712
==============================================================================
--- labs/droids/src/plugins/protocol-httpclient-crowbar/ivy.xml (added)
+++ labs/droids/src/plugins/protocol-httpclient-crowbar/ivy.xml Wed Feb 28 03:29:51 2007
@@ -0,0 +1,27 @@
+<?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.
+-->
+<ivy-module version="1.0">
+ <info organisation="apache" module="droids-protocol-httpclient-crowbar">
+ <license name="Apache License, Version 2.0" url="http://www.apache.org/licenses/"/>
+ <ivyauthor name="Apache Droids - an Apache Labs lab" url="http://labs.apache.org/"/>
+ </info>
+ <dependencies>
+ <dependency org="apache" name="commons-httpclient" rev="3.0.1"/>
+ <dependency org="apache" name="commons-codec" rev="1.3"/>
+ </dependencies>
+</ivy-module>
\ No newline at end of file
Added: labs/droids/src/plugins/protocol-httpclient-crowbar/plugin.xml
URL: http://svn.apache.org/viewvc/labs/droids/src/plugins/protocol-httpclient-crowbar/plugin.xml?view=auto&rev=512712
==============================================================================
--- labs/droids/src/plugins/protocol-httpclient-crowbar/plugin.xml (added)
+++ labs/droids/src/plugins/protocol-httpclient-crowbar/plugin.xml Wed Feb 28 03:29:51 2007
@@ -0,0 +1,35 @@
+<?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.
+-->
+<plugin
+ id="protocol-httpclient-crowbar"
+ name="httpclient crowbar Protocol Plug-in"
+ version="1.0.0"
+ provider-name="droids.org">
+
+ <extension id="org.apache.droids.protocol.httpclient.crowbar"
+ name="httpclientProtocol"
+ point="org.apache.droids.api.Protocol">
+
+ <implementation id="org.apache.droids.protocol.httpclient.crowbar.Http"
+ class="org.apache.droids.protocol.httpclient.crowbar.Http">
+ <parameter name="protocolName" value="http"/>
+ </implementation>
+
+ </extension>
+
+</plugin>
Propchange: labs/droids/src/plugins/protocol-httpclient-crowbar/plugin.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: labs/droids/src/plugins/protocol-httpclient-crowbar/plugin.xml
------------------------------------------------------------------------------
svn:executable = *
Added: labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/crowbar/Http.java
URL: http://svn.apache.org/viewvc/labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/crowbar/Http.java?view=auto&rev=512712
==============================================================================
--- labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/crowbar/Http.java (added)
+++ labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/crowbar/Http.java Wed Feb 28 03:29:51 2007
@@ -0,0 +1,116 @@
+/*
+ * 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 org.apache.droids.protocol.httpclient.crowbar;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javanet.staxutils.BaseXMLOutputFactory;
+
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.XMLEventAllocator;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.droids.api.Protocol;
+import org.apache.droids.protocol.HttpBase;
+
+import com.bea.xml.stream.XMLEventAllocatorBase;
+
+public class Http extends HttpBase implements Protocol {
+ private XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ private XMLOutputFactory outputFactory = BaseXMLOutputFactory.newInstance();
+
+ private XMLEventAllocator allocator;
+
+ private XMLStreamReader parser;
+
+ private XMLEventWriter writer;
+
+ private boolean recording;
+
+ public InputStream openStream(String url) throws IOException {
+ String base = "http://127.0.0.1:10000/";
+ HttpClient client = new HttpClient();
+ PostMethod filePost = new PostMethod(base);
+ filePost.addParameter("url", url);
+ try {
+ int statusCode = client.executeMethod(filePost);
+ System.out.println(statusCode);
+ inputFactory.setEventAllocator(new XMLEventAllocatorBase());
+ allocator = inputFactory.getEventAllocator();
+ parser = inputFactory.createXMLStreamReader(filePost
+ .getResponseBodyAsStream());
+ writer = outputFactory.createXMLEventWriter(System.out);
+ // process();
+ } catch (HttpException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (XMLStreamException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println(filePost.getResponseBodyAsString());
+
+ return filePost.getResponseBodyAsStream();
+ }
+
+ private void process() throws XMLStreamException {
+ while (true) {
+ int event = parser.next();
+ switch (event) {
+ case XMLStreamConstants.END_DOCUMENT:
+ writer.flush();
+ parser.close();
+ return;
+ case XMLStreamConstants.END_ELEMENT:
+ String localName = parser.getLocalName();
+ if (localName.equals("textarea")) {
+ recording = false;
+ }
+ break;
+ case XMLStreamConstants.START_ELEMENT:
+ String name = parser.getLocalName();
+ if (name.equals("textarea"))
+ recording = true;
+ else if (recording & !name.equals("textarea"))
+ writer.add(allocator.allocate(parser));
+ break;
+ default:
+ if (recording)
+ writer.add(allocator.allocate(parser));
+ break;
+ }
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ String url = "http://www.target-x.de/open.html";
+ Http http = new Http();
+ InputStream stream = http.openStream(url);
+ }
+}
Propchange: labs/droids/src/plugins/protocol-httpclient-crowbar/src/java/org/apache/droids/protocol/httpclient/crowbar/Http.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org