-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some refactoring and error management by rmb
- Loading branch information
Henry
committed
Jul 13, 2011
1 parent
c9e8660
commit 147cf1d
Showing
17 changed files
with
700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path=""/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="com.buglabs.dragonfly.jdt.BugClasspathContainerInitializer"/> | ||
<classpathentry kind="output" path=""/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>motherbug3</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.buglabs.dragonfly.BugApplicationNature</nature> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#Wed Jul 13 09:36:38 EDT 2011 | ||
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.assertIdentifier=warning | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning | ||
org.eclipse.jdt.core.compiler.source=1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: motherbug3 | ||
Bundle-Activator: motherbug3.Activator | ||
Bundle-SymbolicName: motherbug3 | ||
Bundle-Version: 1.0.0 | ||
Bundle-Vendor: interns | ||
Bug-Bundle-Type: Application | ||
BUG-API-Version: 2.0.2 | ||
Import-Package: org.osgi.service.http,org.osgi.framework,org.osgi.util | ||
.tracker,com.buglabs.application,com.buglabs.util,javax.servlet,javax | ||
.servlet.http,com.buglabs.bug.module.camera.pub,com.buglabs.bug.modul | ||
e.vonhippel.pub,com.buglabs.services.ws,gnu.io | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package motherbug3; | ||
|
||
import org.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.service.http.HttpService; | ||
import org.osgi.service.log.LogService; | ||
|
||
|
||
import com.buglabs.application.ServiceTrackerHelper; | ||
import com.buglabs.bug.module.camera.pub.ICamera2Device; | ||
import com.buglabs.bug.module.camera.pub.ICameraModuleControl; | ||
import org.osgi.util.tracker.ServiceTracker; | ||
|
||
|
||
public class Activator implements BundleActivator { | ||
private static LogService logger = null; | ||
private static final String [] services = { | ||
ICamera2Device.class.getName(), | ||
ICameraModuleControl.class.getName(), | ||
HttpService.class.getName() | ||
}; | ||
private ServiceTracker serviceTracker; | ||
public void start(BundleContext context) throws Exception { | ||
// TODO Auto-generated method stub | ||
MotherBugApp app = new MotherBugApp (context); | ||
serviceTracker = ServiceTrackerHelper.openServiceTracker(context, services, app); | ||
|
||
} | ||
|
||
public void stop(BundleContext context) throws Exception { | ||
// TODO Auto-generated method stub | ||
serviceTracker.close(); | ||
} | ||
|
||
public static Object getLogger() { | ||
// TODO Auto-generated method stub | ||
return logger; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package motherbug3; | ||
|
||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.osgi.framework.BundleContext; | ||
import org.osgi.service.http.HttpContext; | ||
|
||
/** | ||
* @author jconnolly | ||
* | ||
*/ | ||
|
||
public class CaptureHttpContext implements HttpContext { | ||
|
||
public static final String CAPTURE_ALIAS = "/servodata"; | ||
public static final String NAME = "/Resources";; | ||
private BundleContext context; | ||
|
||
public CaptureHttpContext(BundleContext context){ | ||
this.context = context; | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.osgi.service.http.HttpContext#getMimeType(java.lang.String) | ||
*/ | ||
public String getMimeType(String name) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.osgi.service.http.HttpContext#getResource(java.lang.String) | ||
*/ | ||
@SuppressWarnings("deprecation") | ||
public URL getResource(String path) { | ||
String fileName = path.substring( CAPTURE_ALIAS .length() + 1+NAME.length() ); | ||
try { | ||
return context.getDataFile( fileName ).toURL(); | ||
} | ||
catch ( MalformedURLException e ) { | ||
System.out.println( "Unable to formulate URL for " + fileName ); | ||
return null; | ||
} | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.osgi.service.http.HttpContext#handleSecurity(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) | ||
*/ | ||
public boolean handleSecurity(HttpServletRequest request, | ||
HttpServletResponse response) throws IOException { | ||
// TODO Auto-generated method stub | ||
return true; | ||
} | ||
|
||
|
||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package motherbug3; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import javax.servlet.ServletConfig; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
|
||
import org.osgi.framework.BundleContext; | ||
import org.osgi.service.cm.ConfigurationAdmin; | ||
import org.osgi.service.http.HttpService; | ||
import org.osgi.service.http.NamespaceException; | ||
import com.buglabs.application.ServiceTrackerHelper.ManagedRunnable; | ||
import com.buglabs.bug.module.camera.pub.ICamera2Device; | ||
import com.buglabs.bug.module.camera.pub.ICameraModuleControl; | ||
import com.buglabs.bug.module.vonhippel.pub.IVonHippelSerialPort; | ||
|
||
public class MotherBugApp implements ManagedRunnable { | ||
|
||
private HttpService http_service; | ||
private ICameraModuleControl camera_control; | ||
private ICamera2Device camera; | ||
private ServoServlet servlet; | ||
private BundleContext context; | ||
|
||
public MotherBugApp(BundleContext c){ | ||
context=c; | ||
} | ||
|
||
public void run(Map<Object, Object> services) { | ||
// Activator.getLogger().log(LogService.LOG_INFO, this.getClass().getName() + " has started!"); | ||
http_service = (HttpService) services.get(HttpService.class.getName()); | ||
camera = (ICamera2Device) services.get(ICamera2Device.class.getName()); | ||
camera_control = (ICameraModuleControl) services.get(ICameraModuleControl.class.getName()); | ||
servlet = new ServoServlet(context); | ||
CaptureHttpContext capcon = new CaptureHttpContext(context); | ||
|
||
servlet.setCamera(camera); | ||
servlet.setCameraModuleControl(camera_control); | ||
servlet.setBundleContext(context); | ||
servlet.setHttpService(http_service); | ||
try { | ||
http_service.registerResources(CaptureHttpContext.CAPTURE_ALIAS, CaptureHttpContext.NAME,capcon); | ||
|
||
} catch (NamespaceException e) { | ||
e.printStackTrace(); | ||
|
||
} | ||
|
||
context.registerService(ServoServlet.class.getName(), servlet, null); | ||
|
||
|
||
} | ||
|
||
public void shutdown() { | ||
if (http_service != null) { | ||
http_service.unregister(CaptureHttpContext.CAPTURE_ALIAS); | ||
} | ||
|
||
} | ||
|
||
public void init(ServletConfig config) throws ServletException { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
public ServletConfig getServletConfig() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
public void service(ServletRequest req, ServletResponse res) | ||
throws ServletException, IOException { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
public String getServletInfo() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
public void destroy() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.