Author: [email protected] Date: Tue Mar 1 09:39:58 2011 New Revision: 854 Log:
Added: sandbox/ivol/amdatu-webapp/pom.xml sandbox/ivol/amdatu-webapp/src/ sandbox/ivol/amdatu-webapp/src/main/ sandbox/ivol/amdatu-webapp/src/main/java/ sandbox/ivol/amdatu-webapp/src/main/java/org/ sandbox/ivol/amdatu-webapp/src/main/java/org/amdatu/ sandbox/ivol/amdatu-webapp/src/main/java/org/amdatu/webapp/ sandbox/ivol/amdatu-webapp/src/main/java/org/amdatu/webapp/ProxyServlet.java sandbox/ivol/amdatu-webapp/src/main/java/org/apache/ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/FrameworkService.java sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/ProvisionActivator.java sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java sandbox/ivol/amdatu-webapp/src/main/resources/ sandbox/ivol/amdatu-webapp/src/main/webapp/ sandbox/ivol/amdatu-webapp/src/main/webapp/WEB-INF/ sandbox/ivol/amdatu-webapp/src/main/webapp/WEB-INF/framework.properties sandbox/ivol/amdatu-webapp/src/main/webapp/WEB-INF/web.xml sandbox/ivol/amdatu-webapp/src/main/webapp/index.jsp Added: sandbox/ivol/amdatu-webapp/pom.xml ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/pom.xml Tue Mar 1 09:39:58 2011 @@ -0,0 +1,130 @@ +<?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> + <parent> + <groupId>org.amdatu</groupId> + <artifactId>amdatu</artifactId> + <version>0.2.0-SNAPSHOT</version> + </parent> + <groupId>org.amdatu.webapp</groupId> + <artifactId>amdatu</artifactId> + <name>Amdatu Webapp</name> + <description>Amdatu Webapp</description> + <packaging>war</packaging> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>${org.osgi.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>${org.osgi.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <version>${org.apache.felix.main.version}</version> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.http.proxy</artifactId> + <version>2.2.0</version> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.http.bridge</artifactId> + <version>2.2.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.webconsole</artifactId> + <version>3.1.8</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <finalName>amdatu-webapp</finalName> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.6</source> + <target>1.6</target> + </configuration> + </plugin> + <plugin> + <!-- Handy plugin to test the webapp. Just run the command 'mvn jetty:run', open a browser + and navigate to localhost:8080/amdatu --> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <version>6.1.26</version> + <configuration> + <contextPath>/</contextPath> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-bundles</id> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <includeArtifactIds> + org.apache.felix.http.bridge,org.apache.felix.webconsole + </includeArtifactIds> + <stripVersion>true</stripVersion> + <outputDirectory> + ${project.build.directory}/bundles + </outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <webResources> + <resource> + <directory> + ${project.build.directory}/bundles + </directory> + <targetPath>WEB-INF/bundles</targetPath> + </resource> + <resource> + <directory>.</directory> + <targetPath>META-INF</targetPath> + <includes> + <include>LICENSE</include> + <include>NOTICE</include> + </includes> + </resource> + </webResources> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file Added: sandbox/ivol/amdatu-webapp/src/main/java/org/amdatu/webapp/ProxyServlet.java ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/src/main/java/org/amdatu/webapp/ProxyServlet.java Tue Mar 1 09:39:58 2011 @@ -0,0 +1,33 @@ +/* + Copyright (C) 2010 Amdatu.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.amdatu.webapp; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ProxyServlet extends HttpServlet { + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + System.out.println("Hello world!"); + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + System.out.println("Hello world!"); + } +} \ No newline at end of file Added: sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/FrameworkService.java ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/FrameworkService.java Tue Mar 1 09:39:58 2011 @@ -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 org.apache.felix.http.samples.bridge; + +import org.apache.felix.framework.Felix; +import org.apache.felix.framework.util.FelixConstants; +import javax.servlet.ServletContext; +import java.util.Map; +import java.util.HashMap; +import java.util.Properties; +import java.util.Arrays; + +public final class FrameworkService +{ + private final ServletContext context; + private Felix felix; + + public FrameworkService(ServletContext context) + { + this.context = context; + } + + public void start() + { + try { + doStart(); + } catch (Exception e) { + log("Failed to start framework", e); + } + } + + public void stop() + { + try { + doStop(); + } catch (Exception e) { + log("Error stopping framework", e); + } + } + + private void doStart() + throws Exception + { + Felix tmp = new Felix(createConfig()); + tmp.start(); + this.felix = tmp; + log("OSGi framework started", null); + } + + private void doStop() + throws Exception + { + if (this.felix != null) { + this.felix.stop(); + } + + log("OSGi framework stopped", null); + } + + private Map<String, Object> createConfig() + throws Exception + { + Properties props = new Properties(); + props.load(this.context.getResourceAsStream("/WEB-INF/framework.properties")); + + HashMap<String, Object> map = new HashMap<String, Object>(); + for (Object key : props.keySet()) { + + map.put(key.toString(), props.get(key)); + } + + map.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, Arrays.asList(new ProvisionActivator(this.context))); + + return map; + } + + private void log(String message, Throwable cause) + { + this.context.log(message, cause); + } +} Added: sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/ProvisionActivator.java ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/ProvisionActivator.java Tue Mar 1 09:39:58 2011 @@ -0,0 +1,90 @@ +/* + * 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.felix.http.samples.bridge; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Bundle; +import javax.servlet.ServletContext; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +public final class ProvisionActivator + implements BundleActivator +{ + private final ServletContext servletContext; + + public ProvisionActivator(ServletContext servletContext) + { + this.servletContext = servletContext; + } + + public void start(BundleContext context) + throws Exception + { + + servletContext.setAttribute(BundleContext.class.getName(), context); + + ArrayList<Bundle> installed = new ArrayList<Bundle>(); + for (URL url : findBundles()) { + this.servletContext.log("Installing bundle [" + url + "]"); + System.out.println("Installing bundle [" + url + "]"); + Bundle bundle = context.installBundle(url.toExternalForm()); + installed.add(bundle); + } + + for (Bundle bundle : installed) { + bundle.start(); + } + } + + public void stop(BundleContext context) + throws Exception + { + } + + private List<URL> findBundles() + throws Exception + { + ArrayList<URL> list = new ArrayList<URL>(); + for (Object o : this.servletContext.getResourcePaths("/WEB-INF/bundles/")) { + String name = (String) o; + System.out.println("!!!"+name); + if (name.endsWith(".jar")) { + URL url = this.servletContext.getResource(name); + if (url != null) { + list.add(url); + } + } + } + System.out.println("Found bundles:"+list); + +System.out.println("Context path="+this.servletContext.getContextPath()); + +System.out.println(servletContext.getResourceAsStream("/WEB-INF/framework.properties")); +System.out.println(servletContext.getResourceAsStream("/WEB-INF/web.xml")); +System.out.println(servletContext.getResourceAsStream("/WEB-INF/test.txt")); +System.out.println(servletContext.getResourceAsStream("/WEB-INF/testsource.txt")); +System.out.println(servletContext.getResourceAsStream("/WEB-INF/bundles/org.apache.felix.http.bridge.jar")); + +// geeft /WEB-INF/ +System.out.println(this.servletContext.getResourcePaths("/")); + + return list; + } +} Added: sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java Tue Mar 1 09:39:58 2011 @@ -0,0 +1,36 @@ +/* + * 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.felix.http.samples.bridge; + +import javax.servlet.ServletContextListener; +import javax.servlet.ServletContextEvent; + +public final class StartupListener implements ServletContextListener { + private FrameworkService service; + + public void contextInitialized(ServletContextEvent event) + { + System.out.println("Starting felix!!!"); + this.service = new FrameworkService(event.getServletContext()); + this.service.start(); + } + + public void contextDestroyed(ServletContextEvent event) + { + this.service.stop(); + } +} Added: sandbox/ivol/amdatu-webapp/src/main/webapp/WEB-INF/framework.properties ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/src/main/webapp/WEB-INF/framework.properties Tue Mar 1 09:39:58 2011 @@ -0,0 +1,162 @@ +org.osgi.framework.storage.clean = onFirstInit + +org.osgi.framework.system.packages = \ + org.osgi.framework; version=1.4.0, \ + org.osgi.framework.hooks.service, \ + org.osgi.framework.launch, \ + org.osgi.service.condpermadmin; version=1.0.0, \ + org.osgi.service.packageadmin; version=1.2.0, \ + org.osgi.service.permissionadmin; version=1.2.0, \ + org.osgi.service.startlevel; version=1.1.0, \ + org.osgi.service.url; version=1.0.0,\ + org.osgi.service.application;version="1.0", \ + org.osgi.service.cm;version="1.2", \ + org.osgi.service.component;version="1.0", \ + org.osgi.service.deploymentadmin;version="1.0", \ + org.osgi.service.deploymentadmin.spi;uses:="org.osgi.service.deploymentadmin";version="1.0", \ + org.osgi.service.device;version="1.1", \ + org.osgi.service.event;version="1.1", \ + org.osgi.service.http;version="1.2", \ + org.osgi.service.io;version="1.0", \ + org.osgi.service.log;version="1.3", \ + org.osgi.service.metatype;version="1.1", \ + org.osgi.service.monitor;version="1.0", \ + org.osgi.service.prefs;version="1.1", \ + org.osgi.service.provisioning;version="1.1", \ + org.osgi.service.upnp;version="1.1", \ + org.osgi.service.useradmin;version="1.1", \ + org.osgi.service.wireadmin;version="1.0", \ + info.dmtree.notification;version="1.0", \ + info.dmtree.notification.spi;uses:="info.dmtree.notification";version="1.0", \ + info.dmtree.registry;uses:="info.dmtree.notification";version="1.0", \ + info.dmtree.security;version="1.0", \ + info.dmtree.spi;version="1.0", \ + org.osgi.util.gsm;version="1.0", \ + org.osgi.util.measurement;version="1.0", \ + org.osgi.util.mobile;version="1.0", \ + org.osgi.util.position;uses:="org.osgi.util.measurement";version="1.0", \ + org.osgi.util.tracker;version="1.3.3", \ + org.osgi.util.xml;version="1.0",\ + javax.accessibility,\ + javax.activity,\ + javax.crypto,\ + javax.crypto.interfaces,\ + javax.crypto.spec,\ + javax.imageio,\ + javax.imageio.event,\ + javax.imageio.metadata,\ + javax.imageio.plugins.bmp,\ + javax.imageio.plugins.jpeg,\ + javax.imageio.spi,\ + javax.imageio.stream,\ + javax.management,\ + javax.management.loading,\ + javax.management.modelmbean,\ + javax.management.monitor,\ + javax.management.openmbean,\ + javax.management.relation,\ + javax.management.remote,\ + javax.management.remote.rmi,\ + javax.management.timer,\ + javax.naming,\ + javax.naming.directory,\ + javax.naming.event,\ + javax.naming.ldap,\ + javax.naming.spi,\ + javax.net,\ + javax.net.ssl,\ + javax.print,\ + javax.print.attribute,\ + javax.print.attribute.standard,\ + javax.print.event,\ + javax.rmi,\ + javax.rmi.CORBA,\ + javax.rmi.ssl,\ + javax.security.auth,\ + javax.security.auth.callback,\ + javax.security.auth.kerberos,\ + javax.security.auth.login,\ + javax.security.auth.spi,\ + javax.security.auth.x500,\ + javax.security.cert,\ + javax.security.sasl,\ + javax.sound.midi,\ + javax.sound.midi.spi,\ + javax.sound.sampled,\ + javax.sound.sampled.spi,\ + javax.sql,\ + javax.sql.rowset,\ + javax.sql.rowset.serial,\ + javax.sql.rowset.spi,\ + javax.swing,\ + javax.swing.border,\ + javax.swing.colorchooser,\ + javax.swing.event,\ + javax.swing.filechooser,\ + javax.swing.plaf,\ + javax.swing.plaf.basic,\ + javax.swing.plaf.metal,\ + javax.swing.plaf.multi,\ + javax.swing.plaf.synth,\ + javax.swing.table,\ + javax.swing.text,\ + javax.swing.text.html,\ + javax.swing.text.html.parser,\ + javax.swing.text.rtf,\ + javax.swing.tree,\ + javax.swing.undo,\ + javax.transaction,\ + javax.transaction.xa,\ + javax.xml,\ + javax.xml.datatype,\ + javax.xml.namespace,\ + javax.xml.parsers,\ + javax.xml.transform,\ + javax.xml.transform.dom,\ + javax.xml.transform.sax,\ + javax.xml.transform.stream,\ + javax.xml.validation,\ + javax.xml.xpath,\ + org.ietf.jgss,\ + org.omg.CORBA,\ + org.omg.CORBA_2_3,\ + org.omg.CORBA_2_3.portable,\ + org.omg.CORBA.DynAnyPackage,\ + org.omg.CORBA.ORBPackage,\ + org.omg.CORBA.portable,\ + org.omg.CORBA.TypeCodePackage,\ + org.omg.CosNaming,\ + org.omg.CosNaming.NamingContextExtPackage,\ + org.omg.CosNaming.NamingContextPackage,\ + org.omg.Dynamic,\ + org.omg.DynamicAny,\ + org.omg.DynamicAny.DynAnyFactoryPackage,\ + org.omg.DynamicAny.DynAnyPackage,\ + org.omg.IOP,\ + org.omg.IOP.CodecFactoryPackage,\ + org.omg.IOP.CodecPackage,\ + org.omg.Messaging,\ + org.omg.PortableInterceptor,\ + org.omg.PortableInterceptor.ORBInitInfoPackage,\ + org.omg.PortableServer,\ + org.omg.PortableServer.CurrentPackage,\ + org.omg.PortableServer.POAManagerPackage,\ + org.omg.PortableServer.POAPackage,\ + org.omg.PortableServer.portable,\ + org.omg.PortableServer.ServantLocatorPackage,\ + org.omg.SendingContext,\ + org.omg.stub.java.rmi,\ + org.w3c.dom,\ + org.w3c.dom.bootstrap,\ + org.w3c.dom.css,\ + org.w3c.dom.events,\ + org.w3c.dom.html,\ + org.w3c.dom.ls,\ + org.w3c.dom.ranges,\ + org.w3c.dom.stylesheets,\ + org.w3c.dom.traversal,\ + org.w3c.dom.views,\ + org.xml.sax,\ + org.xml.sax.ext,\ + org.xml.sax.helpers,\ + javax.servlet;javax.servlet.http;version=2.5 Added: sandbox/ivol/amdatu-webapp/src/main/webapp/WEB-INF/web.xml ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/src/main/webapp/WEB-INF/web.xml Tue Mar 1 09:39:58 2011 @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app> + + <listener> + <listener-class>org.apache.felix.http.samples.bridge.StartupListener</listener-class> + </listener> + + <listener> + <listener-class>org.apache.felix.http.proxy.ProxyListener</listener-class> + </listener> + + <servlet> + <servlet-name>proxy</servlet-name> + <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>proxy</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + +</web-app> Added: sandbox/ivol/amdatu-webapp/src/main/webapp/index.jsp ============================================================================== --- (empty file) +++ sandbox/ivol/amdatu-webapp/src/main/webapp/index.jsp Tue Mar 1 09:39:58 2011 @@ -0,0 +1,6 @@ +<html> +<body> +<h2>Amdatu webapp</h2> +<p>This is the Amdatu webapp</p> +</body> +</html> _______________________________________________ Amdatu-commits mailing list [email protected] http://lists.amdatu.org/mailman/listinfo/amdatu-commits
