You can subscribe to this list here.
2007 |
Jan
(31) |
Feb
(54) |
Mar
(27) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <to...@us...> - 2007-02-15 21:12:56
|
Revision: 63 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=63&view=rev Author: tonit Date: 2007-02-15 13:12:53 -0800 (Thu, 15 Feb 2007) Log Message: ----------- transfered project to maven2/maven-bundle-plugin project Added Paths: ----------- sandbox/tonit/techne.samples.audio.samplemusic/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-15 21:11:17
|
Revision: 62 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=62&view=rev Author: tonit Date: 2007-02-15 13:11:16 -0800 (Thu, 15 Feb 2007) Log Message: ----------- transfered project to maven2/maven-bundle-plugin project Added Paths: ----------- sandbox/tonit/techne.samples.audio.player/.classpath sandbox/tonit/techne.samples.audio.player/.project sandbox/tonit/techne.samples.audio.player/pom.xml sandbox/tonit/techne.samples.audio.player/src/ sandbox/tonit/techne.samples.audio.player/src/main/ sandbox/tonit/techne.samples.audio.player/src/main/java/ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/App.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/Activator.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/MusicSource.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/PlayerControl.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomMusicPlayer.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomPlayerThread.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerImpl.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerState.java sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/SingleTrackMusicSource.java sandbox/tonit/techne.samples.audio.player/src/test/ sandbox/tonit/techne.samples.audio.player/src/test/java/ sandbox/tonit/techne.samples.audio.player/src/test/java/techne/ sandbox/tonit/techne.samples.audio.player/src/test/java/techne/AppTest.java sandbox/tonit/techne.samples.audio.player/target/ Added: sandbox/tonit/techne.samples.audio.player/.classpath =================================================================== --- sandbox/tonit/techne.samples.audio.player/.classpath (rev 0) +++ sandbox/tonit/techne.samples.audio.player/.classpath 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,13 @@ +<classpath> + <classpathentry kind="src" path="src/main/java"/> + <classpathentry kind="src" path="src/test/java" output="target/test-classes"/> + <classpathentry kind="output" path="target/classes"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="var" path="M2_REPO/org/apache/felix/org.osgi.compendium/0.9.0-incubator-SNAPSHOT/org.osgi.compendium-0.9.0-incubator-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/javazoom/org.javazoom.jl/1.0-SNAPSHOT/org.javazoom.jl-1.0-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/felix/javax.servlet/0.9.0-incubator-SNAPSHOT/javax.servlet-0.9.0-incubator-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/felix/org.apache.felix.shell/0.9.0-incubator-SNAPSHOT/org.apache.felix.shell-0.9.0-incubator-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/felix/org.osgi.core/0.9.0-incubator-SNAPSHOT/org.osgi.core-0.9.0-incubator-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/felix/org.osgi.foundation/0.9.0-incubator-SNAPSHOT/org.osgi.foundation-0.9.0-incubator-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/> +</classpath> \ No newline at end of file Added: sandbox/tonit/techne.samples.audio.player/.project =================================================================== --- sandbox/tonit/techne.samples.audio.player/.project (rev 0) +++ sandbox/tonit/techne.samples.audio.player/.project 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>techne.samples.audio.player</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: sandbox/tonit/techne.samples.audio.player/pom.xml =================================================================== --- sandbox/tonit/techne.samples.audio.player/pom.xml (rev 0) +++ sandbox/tonit/techne.samples.audio.player/pom.xml 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,51 @@ +<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> + <groupId>techne</groupId> + <artifactId>techne.samples.audio.player</artifactId> + <packaging>bundle</packaging> + <version>1.0</version> + <name>techne.samples.audio.player</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.osgi.core</artifactId> + <version>0.9.0-incubator-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>0.9.0-incubator-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.javazoom</groupId> + <artifactId>org.javazoom.jl</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-SymbolicName>techne.samples.audio</Bundle-SymbolicName> + <Export-Package>techne.audio.player</Export-Package> + <Private-Package>techne.audio.player.internal</Private-Package> + <Bundle-Activator>techne.audio.player.Activator</Bundle-Activator> + <Service-Component>techne.audio.player.internal.JavaZoomMusicPlayer;musicSource=techne.audio.player.MusicSource;provide:=techne.audio.player.PlayerControl</Service-Component> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/App.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/App.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/App.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,13 @@ +package techne; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/Activator.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/Activator.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/Activator.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,24 @@ +package techne.audio.player; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + public void start(BundleContext ctx) throws Exception { + System.out.println("Audio ON"); + try { + System.out.println("Component header: " + + ctx.getBundle().getHeaders().get("Service-Component")); + + System.out.println("LogReader wired!"); + } catch (Exception e) { + System.out.println("Cannot wire to logreader"); + } + } + + public void stop(BundleContext arg0) throws Exception { + System.out.println("Audio OFF"); + } + +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/MusicSource.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/MusicSource.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/MusicSource.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,10 @@ +package techne.audio.player; + +import java.io.InputStream; + +public interface MusicSource { + InputStream next(); + boolean hasNext(); + InputStream current(); + +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/PlayerControl.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/PlayerControl.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/PlayerControl.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,8 @@ +package techne.audio.player; + +public interface PlayerControl { + void play(); + void stop(); + void pause(); + int getState(); +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomMusicPlayer.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomMusicPlayer.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomMusicPlayer.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,82 @@ +package techne.audio.player.internal; + +import org.osgi.service.component.ComponentContext; + +import techne.audio.player.MusicSource; +import techne.audio.player.PlayerControl; + +/** + * + * Currently it just supports a single track. Later it will accept mutiple + * tracks. Those track shoudl come from a MusicSource impl. Thus, the controls + * will likely to be extended (foward,backward) + * + * + * @author tmenzel + * + */ +public class JavaZoomMusicPlayer implements PlayerControl { + private JavaZoomPlayerThread thread; + private MusicSource musicSource; + private ComponentContext context; + + public JavaZoomMusicPlayer() { + } + + protected void activate(ComponentContext context) { + this.context = context; + // reference hopefully injected already? + if (musicSource != null) { + thread = new JavaZoomPlayerThread(); + thread.setMusicSource(musicSource); + } else { + System.out.println("There is no musicSource for some reason.. :-("); + } + } + + public void deactivate(ComponentContext context) throws Exception { + if (thread != null) { + thread.changeState(PlayerState.STATE_OFF); + thread.close(); + } + System.out.println("Player Service is down"); + } + + public void pause() { + thread.changeState(PlayerState.STATE_PAUSE); + } + + public void play() { + if (thread == null) { + thread = new JavaZoomPlayerThread(); + thread.setMusicSource(musicSource); + } + + if (thread != null) { + if (!thread.isAlive()) { + System.out.println("start player thread.."); + thread.start(); + } + thread.changeState(PlayerState.STATE_PLAY); + } + } + + public void stop() { + if (thread != null) { + thread.changeState(PlayerState.STATE_IDLE); + } + } + + public MusicSource getMusicSource() { + return musicSource; + } + + public void setMusicSource(MusicSource source) { + this.musicSource = source; + } + + public int getState() { + return thread.getCurrentPlayerState(); + } + +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomPlayerThread.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomPlayerThread.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/JavaZoomPlayerThread.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,81 @@ +package techne.audio.player.internal; + +import techne.audio.player.MusicSource; + +/** + * * Thread that represents a ready to go music player To control it, use the + * PlayerControls + */ +public class JavaZoomPlayerThread extends Thread { + MusicSource musicSource; + private PlayerImpl pla; + + private int state = PlayerState.STATE_IDLE; + private int lastpos = 0; + + public synchronized void changeState(int state) { + System.out.println("SWITCHING STATE FROM " + this.state + " to " + + state + " at pos " + lastpos); + this.state = state; + if (state != PlayerState.STATE_PLAY) { + // break event + if (pla != null) { + pla.pause(); + + System.out.println("adding " + pla.getPosition() + " to " + + lastpos); + lastpos += pla.getPosition(); + } + } + } + + public void run() { + try { + while (state != PlayerState.STATE_OFF) { + if (this.state == PlayerState.STATE_PLAY) { + if (pla == null || pla.isComplete()) { + if (musicSource.hasNext()) { + pla = new PlayerImpl(musicSource.next()); + pla.play(0, Integer.MAX_VALUE); + } else { + changeState(PlayerState.STATE_IDLE); + } + } else { + // resume + System.out.println("resume at pos " + lastpos); + // resume requires re-opening stream..:-( + pla = new PlayerImpl(musicSource.current()); + pla.play(lastpos, Integer.MAX_VALUE); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println(e.getMessage()); + throw new RuntimeException(e); + } + System.out.println("MusicPlayer Thread closed!"); + } + + public void close() { + changeState(PlayerState.STATE_OFF); + pla.close(); + } + + public MusicSource getMusicSource() { + return musicSource; + } + + + + public void setMusicSource(MusicSource musicSource) { + this.musicSource = musicSource; + } + + public int getCurrentPlayerState() { + return state; + } + + +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerImpl.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerImpl.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerImpl.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,222 @@ +package techne.audio.player.internal; + +import java.io.InputStream; + +import javazoom.jl.decoder.Bitstream; +import javazoom.jl.decoder.BitstreamException; +import javazoom.jl.decoder.Decoder; +import javazoom.jl.decoder.Header; +import javazoom.jl.decoder.JavaLayerException; +import javazoom.jl.decoder.SampleBuffer; +import javazoom.jl.player.AudioDevice; +import javazoom.jl.player.FactoryRegistry; + +public class PlayerImpl { + + /** + * The MPEG audio bitstream. + */ + // javac blank final bug. + /* final */private Bitstream bitstream; + + /** + * The MPEG audio decoder. + */ + /* final */private Decoder decoder; + + /** + * The AudioDevice the audio samples are written to. + */ + private AudioDevice audio; + + /** + * Has the player been closed? + */ + private boolean closed = false; + + /** + * Has the player played back all frames from the stream? + */ + private boolean complete = false; + + private int lastPosition = 0; + + /** + * Creates a new <code>Player</code> instance. + */ + public PlayerImpl(InputStream stream) throws JavaLayerException { + bitstream = new Bitstream(stream); + decoder = new Decoder(); + + FactoryRegistry r = FactoryRegistry.systemRegistry(); + audio = r.createAudioDevice(); + + audio.open(decoder); + } + + public void play() throws JavaLayerException { + play(Integer.MAX_VALUE); + } + + public boolean play(final int start, final int end) { + boolean ret = true; + boolean res = true; + int offset = start; + try { + while (offset-- > 0 && ret) { + ret = skipFrame(); + } + res = play(end - start); + + } catch (JavaLayerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + return res; + } + + /** + * skips over a single frame + * + * @return false if there are no more frames to decode, true otherwise. + */ + protected boolean skipFrame() throws JavaLayerException { + Header h = bitstream.readFrame(); + if (h == null) + return false; + bitstream.closeFrame(); + return true; + } + + /** + * Plays a number of MPEG audio frames. + * + * @param frames + * The number of frames to play. + * @return true if the last frame was played, or false if there are more + * frames. + */ + public boolean play(int frames) throws JavaLayerException { + boolean ret = true; + + while (frames-- > 0 && ret) { + ret = decodeFrame(); + } + + if (!ret) { + // last frame, ensure all data flushed to the audio device. + AudioDevice out = audio; + if (out != null) { + out.flush(); + synchronized (this) { + complete = (!closed); + close(); + } + } + } + return ret; + } + + /** + * Cloases this player. Any audio currently playing is stopped immediately. + */ + public synchronized void close() { + AudioDevice out = audio; + if (out != null) { + closed = true; + audio = null; + // this may fail, so ensure object state is set up before + // calling this method. + out.close(); + lastPosition = out.getPosition(); + try { + bitstream.close(); + } catch (BitstreamException ex) { + } + } + } + + /** + * Returns the completed status of this player. + * + * @return true if all available MPEG audio frames have been decoded, or + * false otherwise. + */ + public synchronized boolean isComplete() { + return complete; + } + + /** + * Retrieves the position in milliseconds of the current audio sample being + * played. This method delegates to the <code> + * AudioDevice</code> that is + * used by this player to sound the decoded audio samples. + */ + public int getPosition() { + int position = lastPosition; + + AudioDevice out = audio; + if (out != null) { + position = out.getPosition(); + } + return position; + } + + /** + * Decodes a single frame. + * + * @return true if there are no more frames to decode, false otherwise. + */ + protected boolean decodeFrame() throws JavaLayerException { + try { + AudioDevice out = audio; + if (out == null) { + return false; + } + Header h = bitstream.readFrame(); + if (h == null) { + return false; + } + // sample buffer set when decoder constructed + SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, + bitstream); + + synchronized (this) { + out = audio; + if (out != null) { + out.write(output.getBuffer(), 0, output.getBufferLength()); + } + } + + bitstream.closeFrame(); + } catch (RuntimeException ex) { + throw new JavaLayerException("Exception decoding audio frame", ex); + } + /* + * catch (IOException ex) { System.out.println("exception decoding audio + * frame: "+ex); return false; } catch (BitstreamException bitex) { + * System.out.println("exception decoding audio frame: "+bitex); return + * false; } catch (DecoderException decex) { + * System.out.println("exception decoding audio frame: "+decex); return + * false; } + */ + return true; + } + + public void pause() { + AudioDevice out = audio; + if (out != null) { + closed = true; + audio = null; + // this may fail, so ensure object state is set up before + // calling this method. + out.close(); + lastPosition = out.getPosition(); + try { + bitstream.close(); + } catch (BitstreamException ex) { + } + } + } +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerState.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerState.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/PlayerState.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,9 @@ +package techne.audio.player.internal; + +public class PlayerState { + public static final int STATE_IDLE = 0; + public static final int STATE_OFF = -1; + + public static final int STATE_PLAY = 1; + public static final int STATE_PAUSE = 2; +} Added: sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/SingleTrackMusicSource.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/SingleTrackMusicSource.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/main/java/techne/audio/player/internal/SingleTrackMusicSource.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,52 @@ +package techne.audio.player.internal; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import techne.audio.player.MusicSource; + +public class SingleTrackMusicSource implements MusicSource { + boolean repeat = false; + private URL url; + // count of next() requests + int count = 0; + + public SingleTrackMusicSource(URL url) { + this.url = url; + } + + public boolean hasNext() { + return (repeat || count == 0); + } + + public InputStream next() { + synchronized (this) { + if (count == 0) { + count++; + try { + System.out.println("MusicSource: giving " + url.toExternalForm()); + return url.openConnection().getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + } + return null; + } + + public void setRepeat(boolean rep) { + this.repeat = rep; + } + + public InputStream current() { + try { + return url.openConnection().getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + +} Added: sandbox/tonit/techne.samples.audio.player/src/test/java/techne/AppTest.java =================================================================== --- sandbox/tonit/techne.samples.audio.player/src/test/java/techne/AppTest.java (rev 0) +++ sandbox/tonit/techne.samples.audio.player/src/test/java/techne/AppTest.java 2007-02-15 21:11:16 UTC (rev 62) @@ -0,0 +1,38 @@ +package techne; + +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 ); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-15 21:10:27
|
Revision: 61 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=61&view=rev Author: tonit Date: 2007-02-15 13:10:17 -0800 (Thu, 15 Feb 2007) Log Message: ----------- transfered project to maven2/maven-bundle-plugin project Added Paths: ----------- sandbox/tonit/techne.samples.audio.player/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-13 21:29:44
|
Revision: 60 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=60&view=rev Author: tonit Date: 2007-02-13 13:29:44 -0800 (Tue, 13 Feb 2007) Log Message: ----------- added classes dir to svn:ignore Property Changed: ---------------- sandbox/rickles/org.digivitality.techne.core/ Property changes on: sandbox/rickles/org.digivitality.techne.core ___________________________________________________________________ Name: svn:ignore + classes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-13 21:27:26
|
Revision: 59 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=59&view=rev Author: tonit Date: 2007-02-13 13:27:20 -0800 (Tue, 13 Feb 2007) Log Message: ----------- fixed deprecated dependency Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.core/.classpath Modified: sandbox/rickles/org.digivitality.techne.core/.classpath =================================================================== --- sandbox/rickles/org.digivitality.techne.core/.classpath 2007-02-13 21:07:45 UTC (rev 58) +++ sandbox/rickles/org.digivitality.techne.core/.classpath 2007-02-13 21:27:20 UTC (rev 59) @@ -1,11 +1,10 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.0.4.jar"/> - <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.9.jar"/> - <classpathentry combineaccessrules="false" kind="src" path="/org.digivitality.techne.shell"/> - <classpathentry sourcepath="C:/Workspace/Projects/JAVA/ApacheFelix" kind="lib" path="lib/felix.jar"/> - <classpathentry sourcepath="/org.digivitality.techne.bundle/src/org/digivitality/techne/bundle" kind="lib" path="bundle/org.digivitality.techne.bundle_1.0.0.jar"/> - <classpathentry kind="output" path="classes"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.0.4.jar"/> + <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.9.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/org.digivitality.techne.shell"/> + <classpathentry kind="lib" path="lib/felix.jar" sourcepath="C:/Workspace/Projects/JAVA/ApacheFelix"/> + <classpathentry kind="output" path="classes"/> +</classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-13 21:07:52
|
Revision: 58 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=58&view=rev Author: tonit Date: 2007-02-13 13:07:45 -0800 (Tue, 13 Feb 2007) Log Message: ----------- this file explains the purpose, gives hints for build, package and deployment and gives a small todo list Added Paths: ----------- sandbox/tonit/techne.audio/readme Added: sandbox/tonit/techne.audio/readme =================================================================== --- sandbox/tonit/techne.audio/readme (rev 0) +++ sandbox/tonit/techne.audio/readme 2007-02-13 21:07:45 UTC (rev 58) @@ -0,0 +1,62 @@ +What is it ? +================== +its a set of osgi bundles. They all make up a family of related bundles but yet communicating over small +service interfaces. + +1. techne.audio.player +This is the player. it provides the PlayerControl Service to the OSGi Service Registry. +It depends in the javazoom library (already in place at the load directory of techne-env) + +It requires at least one registered techne.audio.player.MusicSource Service + +2. techne.audio.tui +a felix shell extension providing the "audio" command. +it requires a techne.audio.PlayerControl Service registered at the service registry. + +3. techne.audio.samplemusic +Provides an implementation of techne.audio.player.MusicSource using an embedded mp3 track. + +4. techne.audio.itunes +Provides an implementation of techne.audio.player.MusicSource using a locally installed itunes music library. +(not yet implemented.. but a cool part) + +How to build , package & deploy +================================== +- i am currently transfering this project to maven and the maven-bundle-plugin +Compiling: +--------------- +currently the actual compile is taken by eclipse.. (so you need to import this project into the IDE) + +Packaging: +--------------- +use the bnd tool to build jars out of the .bnd files + +For example for a unix environment (cygwin should work i think..) +0. Open a shell, go to the directory of this readme file +1.(optional) make peters bnd.jar executable: +"alias bnd='java -jar <pathtoyourworkspace>/techne-env/lib/bnd-0.0.110.jar'" +2. build the plugins: +"bnd build techne.audio.player.bnd" +"bnd build techne.audio.tui.bnd" +"bnd build techne.audio.samplemusic.bnd" +"bnd build techne.audio.itunes.bnd" +done. + +Deploying +--------------- +Load the jars like any ordinary bundle. +Note: the techne.audio.tui requires felix.shell +This kind of issue is going to be addressed here: http://issues.ops4j.org/jira/browse/BUNDLES-1?page=comments#action_10141 + +Actually, the easiest way to play woth the services is using aQutes FileInstall Bundle: +Just drop the generated jars into the load directory of your fileinstaller + +ToDo +================================ +- convert build model to maven-bundle-plugin (use felix as a good sample) +- define metadata to make the bundles more intelligent (far) +- implement the itunes support (wanna have..) + + +--Toni Menzel / 12th of february 2007 + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-13 00:57:14
|
Revision: 57 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=57&view=rev Author: tonit Date: 2007-02-12 16:57:09 -0800 (Mon, 12 Feb 2007) Log Message: ----------- added double check locking in next() to make this boring sample more educative ;-) Modified Paths: -------------- sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java Modified: sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java 2007-02-13 00:11:08 UTC (rev 56) +++ sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java 2007-02-13 00:57:09 UTC (rev 57) @@ -31,15 +31,20 @@ } public InputStream next() { - synchronized (this) { - if (count == 0) { - count++; - try { - System.out.println("MusicSource: giving " + url.toExternalForm()); - return url.openConnection().getInputStream(); - } catch (IOException e) { - e.printStackTrace(); - throw new RuntimeException(e); + // double check locking to make this boring sample more educative ;-) + if (hasNext()) { + synchronized (this) { + if (hasNext()) { + count++; + try { + // you get always the same for this example either.. + System.out.println("MusicSource: giving " + + url.toExternalForm()); + return url.openConnection().getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } } } } @@ -62,7 +67,8 @@ // Declarative Services methods.. protected void activate(ComponentContext context) { System.out.println("Started sample MusicSource for techne.audio"); - url = context.getBundleContext().getBundle().getResource("TotallyFreeSong.mp3"); + url = context.getBundleContext().getBundle().getResource( + "TotallyFreeSong.mp3"); } public void deactivate(ComponentContext context) throws Exception { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-13 00:11:11
|
Revision: 56 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=56&view=rev Author: tonit Date: 2007-02-12 16:11:08 -0800 (Mon, 12 Feb 2007) Log Message: ----------- fixed issue with wrongly typed audio command (NoSuchElementException) Modified Paths: -------------- sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java Modified: sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java 2007-02-13 00:02:46 UTC (rev 55) +++ sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java 2007-02-13 00:11:08 UTC (rev 56) @@ -11,25 +11,28 @@ private PlayerControl control; public void execute(String s, PrintStream out, PrintStream err) { - out.println("audio command recognized!"); if (control != null) { StringTokenizer st = new StringTokenizer(s, " "); st.nextToken(); // Ignore the command name. - String cmd = st.nextToken(); - if ("play".equals(cmd)) { - control.play(); - }else if ("stop".equals(cmd)) { - control.stop(); - }else if ("pause".equals(cmd)) { - control.pause(); - }else if ("state".equals(cmd)) { - out.println("Current state: " + control.getState()); - }else - { - out.println("Command " + cmd + " unknown"); + if (st.hasMoreTokens()) { + String cmd = st.nextToken(); + if ("play".equals(cmd)) { + control.play(); + }else if ("stop".equals(cmd)) { + control.stop(); + }else if ("pause".equals(cmd)) { + control.pause(); + }else if ("state".equals(cmd)) { + out.println("Current state: " + control.getState()); + }else + { + out.println("Command " + cmd + " unknown"); + out.println(getUsage()); + } + }else { out.println(getUsage()); - } + } }else { err.println("no PlayerControl instance assigned!"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-13 00:02:48
|
Revision: 55 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=55&view=rev Author: tonit Date: 2007-02-12 16:02:46 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Property Changed: ---------------- sandbox/tonit/techne.audio/ Property changes on: sandbox/tonit/techne.audio ___________________________________________________________________ Name: svn:ignore - bin + bin *.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-13 00:00:56
|
Revision: 54 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=54&view=rev Author: tonit Date: 2007-02-12 16:00:57 -0800 (Mon, 12 Feb 2007) Log Message: ----------- splitted into sub bundles Removed Paths: ------------- sandbox/tonit/techne.audio/techne.audio.bnd Deleted: sandbox/tonit/techne.audio/techne.audio.bnd =================================================================== --- sandbox/tonit/techne.audio/techne.audio.bnd 2007-02-12 23:54:34 UTC (rev 53) +++ sandbox/tonit/techne.audio/techne.audio.bnd 2007-02-13 00:00:57 UTC (rev 54) @@ -1,3 +0,0 @@ -Export-Package: techne.audio -Bundle-Activator: techne.audio.Activator --sources= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:54:35
|
Revision: 53 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=53&view=rev Author: tonit Date: 2007-02-12 15:54:34 -0800 (Mon, 12 Feb 2007) Log Message: ----------- jl now comes from techne-env Modified Paths: -------------- sandbox/tonit/techne.audio/.classpath Modified: sandbox/tonit/techne.audio/.classpath =================================================================== --- sandbox/tonit/techne.audio/.classpath 2007-02-12 23:53:55 UTC (rev 52) +++ sandbox/tonit/techne.audio/.classpath 2007-02-12 23:54:34 UTC (rev 53) @@ -3,7 +3,7 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="/techne-env/development/lib/osgi.jar"/> - <classpathentry kind="lib" path="resources/lib/jl1.0.jar"/> <classpathentry kind="lib" path="/techne-env/bundle/org.apache.felix.shell-0.9.0-incubator-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="/techne-env/load/jl1.0.jar"/> <classpathentry kind="output" path="bin"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:53:56
|
Revision: 52 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=52&view=rev Author: tonit Date: 2007-02-12 15:53:55 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Removed Paths: ------------- sandbox/tonit/techne.audio/build.xml Deleted: sandbox/tonit/techne.audio/build.xml =================================================================== --- sandbox/tonit/techne.audio/build.xml 2007-02-12 23:50:59 UTC (rev 51) +++ sandbox/tonit/techne.audio/build.xml 2007-02-12 23:53:55 UTC (rev 52) @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--assembles the audio component of techne --> -<!--note: it does not compile and changes the manifest by default!--> -<project name="techne.audio" default="bundle"> - <target name="bundle"> - <jar destfile="techne.audio.jar" manifest="META-INF/MANIFEST.MF"> - <fileset dir="bin"> - <include name="**"/> - </fileset> - <fileset dir="."> - <include name="resource/**"/> - </fileset> - <fileset dir="."> - <include name="OSGI-INF/**"/> - </fileset> - </jar> - </target> - <target name="install_lib"> - <copy file="lib/jl1.0.jar" todir="../techne-env/load/"></copy> - </target> - <target name="install"> - <copy file="techne.audio.jar" todir="../techne-env/load/"></copy> - </target> - <target name="uninstall"> - <delete file="../techne-env/load/techne.audio.jar"></delete> - </target> - -</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:50:58
|
Revision: 51 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=51&view=rev Author: tonit Date: 2007-02-12 15:50:59 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Added Paths: ----------- sandbox/tonit/techne.audio/resources/techne.audio.samplemusic/ sandbox/tonit/techne.audio/resources/techne.audio.samplemusic/TotallyFreeSong.mp3 Removed Paths: ------------- sandbox/tonit/techne.audio/resources/META-INF/ sandbox/tonit/techne.audio/resources/OSGI-INF/ sandbox/tonit/techne.audio/resources/lib/ sandbox/tonit/techne.audio/resources/techne_hook.mp3 Added: sandbox/tonit/techne.audio/resources/techne.audio.samplemusic/TotallyFreeSong.mp3 =================================================================== (Binary files differ) Property changes on: sandbox/tonit/techne.audio/resources/techne.audio.samplemusic/TotallyFreeSong.mp3 ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: sandbox/tonit/techne.audio/resources/techne_hook.mp3 =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:45:37
|
Revision: 50 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=50&view=rev Author: tonit Date: 2007-02-12 15:45:37 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Modified Paths: -------------- sandbox/tonit/techne.audio/.classpath Added Paths: ----------- sandbox/tonit/techne.audio/src/techne/audio/itunes/ sandbox/tonit/techne.audio/src/techne/audio/itunes/Activator.java sandbox/tonit/techne.audio/src/techne/audio/itunes/ItunesMusicSource.java sandbox/tonit/techne.audio/src/techne/audio/player/MusicSource.java sandbox/tonit/techne.audio/src/techne/audio/player/PlayerControl.java sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomPlayerThread.java sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerImpl.java sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerState.java sandbox/tonit/techne.audio/src/techne/audio/player/internal/SingleTrackMusicSource.java sandbox/tonit/techne.audio/src/techne/audio/samplemusic/ sandbox/tonit/techne.audio/src/techne/audio/samplemusic/Activator.java sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java sandbox/tonit/techne.audio/src/techne/audio/tui/ sandbox/tonit/techne.audio/src/techne/audio/tui/internal/ sandbox/tonit/techne.audio/src/techne/audio/tui/internal/Activator.java sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java Modified: sandbox/tonit/techne.audio/.classpath =================================================================== --- sandbox/tonit/techne.audio/.classpath 2007-02-12 23:29:24 UTC (rev 49) +++ sandbox/tonit/techne.audio/.classpath 2007-02-12 23:45:37 UTC (rev 50) @@ -4,5 +4,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="/techne-env/development/lib/osgi.jar"/> <classpathentry kind="lib" path="resources/lib/jl1.0.jar"/> + <classpathentry kind="lib" path="/techne-env/bundle/org.apache.felix.shell-0.9.0-incubator-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Added: sandbox/tonit/techne.audio/src/techne/audio/itunes/Activator.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/itunes/Activator.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/itunes/Activator.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,16 @@ +package techne.audio.itunes; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + public void start(BundleContext ctx) throws Exception { + System.out.println("Loading itunes support for techne.audio"); + } + + public void stop(BundleContext arg0) throws Exception { + System.out.println("Removing itunes support for techne.audio"); + } + +} Added: sandbox/tonit/techne.audio/src/techne/audio/itunes/ItunesMusicSource.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/itunes/ItunesMusicSource.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/itunes/ItunesMusicSource.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,45 @@ +package techne.audio.itunes; + +import java.io.InputStream; + +import org.osgi.service.component.ComponentContext; + +import techne.audio.player.MusicSource; +import techne.audio.player.internal.JavaZoomPlayerThread; + +/** + * todo: + * - find local itunes Library.xml + * - read favourites (most played) + * - give streams (next()) + * + * @author tmenzel + * + */ +public class ItunesMusicSource implements MusicSource { + + public InputStream current() { + // TODO Auto-generated method stub + return null; + } + + public boolean hasNext() { + // TODO Auto-generated method stub + return false; + } + + public InputStream next() { + // TODO Auto-generated method stub + return null; + } + + // Declarative Services methods.. + protected void activate(ComponentContext context) { + System.out.println("Started itunes MusicSource for techne.audio"); + } + + public void deactivate(ComponentContext context) throws Exception { + System.out.println("Stopped itunes MusicSource for techne.audio"); + } + +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/MusicSource.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/MusicSource.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/MusicSource.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,10 @@ +package techne.audio.player; + +import java.io.InputStream; + +public interface MusicSource { + InputStream next(); + boolean hasNext(); + InputStream current(); + +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/PlayerControl.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/PlayerControl.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/PlayerControl.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,8 @@ +package techne.audio.player; + +public interface PlayerControl { + void play(); + void stop(); + void pause(); + int getState(); +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomPlayerThread.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomPlayerThread.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomPlayerThread.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,81 @@ +package techne.audio.player.internal; + +import techne.audio.player.MusicSource; + +/** + * * Thread that represents a ready to go music player To control it, use the + * PlayerControls + */ +public class JavaZoomPlayerThread extends Thread { + MusicSource musicSource; + private PlayerImpl pla; + + private int state = PlayerState.STATE_IDLE; + private int lastpos = 0; + + public synchronized void changeState(int state) { + System.out.println("SWITCHING STATE FROM " + this.state + " to " + + state + " at pos " + lastpos); + this.state = state; + if (state != PlayerState.STATE_PLAY) { + // break event + if (pla != null) { + pla.pause(); + + System.out.println("adding " + pla.getPosition() + " to " + + lastpos); + lastpos += pla.getPosition(); + } + } + } + + public void run() { + try { + while (state != PlayerState.STATE_OFF) { + if (this.state == PlayerState.STATE_PLAY) { + if (pla == null || pla.isComplete()) { + if (musicSource.hasNext()) { + pla = new PlayerImpl(musicSource.next()); + pla.play(0, Integer.MAX_VALUE); + } else { + changeState(PlayerState.STATE_IDLE); + } + } else { + // resume + System.out.println("resume at pos " + lastpos); + // resume requires re-opening stream..:-( + pla = new PlayerImpl(musicSource.current()); + pla.play(lastpos, Integer.MAX_VALUE); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println(e.getMessage()); + throw new RuntimeException(e); + } + System.out.println("MusicPlayer Thread closed!"); + } + + public void close() { + changeState(PlayerState.STATE_OFF); + pla.close(); + } + + public MusicSource getMusicSource() { + return musicSource; + } + + + + public void setMusicSource(MusicSource musicSource) { + this.musicSource = musicSource; + } + + public int getCurrentPlayerState() { + return state; + } + + +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerImpl.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerImpl.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerImpl.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,222 @@ +package techne.audio.player.internal; + +import java.io.InputStream; + +import javazoom.jl.decoder.Bitstream; +import javazoom.jl.decoder.BitstreamException; +import javazoom.jl.decoder.Decoder; +import javazoom.jl.decoder.Header; +import javazoom.jl.decoder.JavaLayerException; +import javazoom.jl.decoder.SampleBuffer; +import javazoom.jl.player.AudioDevice; +import javazoom.jl.player.FactoryRegistry; + +public class PlayerImpl { + + /** + * The MPEG audio bitstream. + */ + // javac blank final bug. + /* final */private Bitstream bitstream; + + /** + * The MPEG audio decoder. + */ + /* final */private Decoder decoder; + + /** + * The AudioDevice the audio samples are written to. + */ + private AudioDevice audio; + + /** + * Has the player been closed? + */ + private boolean closed = false; + + /** + * Has the player played back all frames from the stream? + */ + private boolean complete = false; + + private int lastPosition = 0; + + /** + * Creates a new <code>Player</code> instance. + */ + public PlayerImpl(InputStream stream) throws JavaLayerException { + bitstream = new Bitstream(stream); + decoder = new Decoder(); + + FactoryRegistry r = FactoryRegistry.systemRegistry(); + audio = r.createAudioDevice(); + + audio.open(decoder); + } + + public void play() throws JavaLayerException { + play(Integer.MAX_VALUE); + } + + public boolean play(final int start, final int end) { + boolean ret = true; + boolean res = true; + int offset = start; + try { + while (offset-- > 0 && ret) { + ret = skipFrame(); + } + res = play(end - start); + + } catch (JavaLayerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + return res; + } + + /** + * skips over a single frame + * + * @return false if there are no more frames to decode, true otherwise. + */ + protected boolean skipFrame() throws JavaLayerException { + Header h = bitstream.readFrame(); + if (h == null) + return false; + bitstream.closeFrame(); + return true; + } + + /** + * Plays a number of MPEG audio frames. + * + * @param frames + * The number of frames to play. + * @return true if the last frame was played, or false if there are more + * frames. + */ + public boolean play(int frames) throws JavaLayerException { + boolean ret = true; + + while (frames-- > 0 && ret) { + ret = decodeFrame(); + } + + if (!ret) { + // last frame, ensure all data flushed to the audio device. + AudioDevice out = audio; + if (out != null) { + out.flush(); + synchronized (this) { + complete = (!closed); + close(); + } + } + } + return ret; + } + + /** + * Cloases this player. Any audio currently playing is stopped immediately. + */ + public synchronized void close() { + AudioDevice out = audio; + if (out != null) { + closed = true; + audio = null; + // this may fail, so ensure object state is set up before + // calling this method. + out.close(); + lastPosition = out.getPosition(); + try { + bitstream.close(); + } catch (BitstreamException ex) { + } + } + } + + /** + * Returns the completed status of this player. + * + * @return true if all available MPEG audio frames have been decoded, or + * false otherwise. + */ + public synchronized boolean isComplete() { + return complete; + } + + /** + * Retrieves the position in milliseconds of the current audio sample being + * played. This method delegates to the <code> + * AudioDevice</code> that is + * used by this player to sound the decoded audio samples. + */ + public int getPosition() { + int position = lastPosition; + + AudioDevice out = audio; + if (out != null) { + position = out.getPosition(); + } + return position; + } + + /** + * Decodes a single frame. + * + * @return true if there are no more frames to decode, false otherwise. + */ + protected boolean decodeFrame() throws JavaLayerException { + try { + AudioDevice out = audio; + if (out == null) { + return false; + } + Header h = bitstream.readFrame(); + if (h == null) { + return false; + } + // sample buffer set when decoder constructed + SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, + bitstream); + + synchronized (this) { + out = audio; + if (out != null) { + out.write(output.getBuffer(), 0, output.getBufferLength()); + } + } + + bitstream.closeFrame(); + } catch (RuntimeException ex) { + throw new JavaLayerException("Exception decoding audio frame", ex); + } + /* + * catch (IOException ex) { System.out.println("exception decoding audio + * frame: "+ex); return false; } catch (BitstreamException bitex) { + * System.out.println("exception decoding audio frame: "+bitex); return + * false; } catch (DecoderException decex) { + * System.out.println("exception decoding audio frame: "+decex); return + * false; } + */ + return true; + } + + public void pause() { + AudioDevice out = audio; + if (out != null) { + closed = true; + audio = null; + // this may fail, so ensure object state is set up before + // calling this method. + out.close(); + lastPosition = out.getPosition(); + try { + bitstream.close(); + } catch (BitstreamException ex) { + } + } + } +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerState.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerState.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/internal/PlayerState.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,9 @@ +package techne.audio.player.internal; + +public class PlayerState { + public static final int STATE_IDLE = 0; + public static final int STATE_OFF = -1; + + public static final int STATE_PLAY = 1; + public static final int STATE_PAUSE = 2; +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/internal/SingleTrackMusicSource.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/internal/SingleTrackMusicSource.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/internal/SingleTrackMusicSource.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,52 @@ +package techne.audio.player.internal; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import techne.audio.player.MusicSource; + +public class SingleTrackMusicSource implements MusicSource { + boolean repeat = false; + private URL url; + // count of next() requests + int count = 0; + + public SingleTrackMusicSource(URL url) { + this.url = url; + } + + public boolean hasNext() { + return (repeat || count == 0); + } + + public InputStream next() { + synchronized (this) { + if (count == 0) { + count++; + try { + System.out.println("MusicSource: giving " + url.toExternalForm()); + return url.openConnection().getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + } + return null; + } + + public void setRepeat(boolean rep) { + this.repeat = rep; + } + + public InputStream current() { + try { + return url.openConnection().getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + +} Added: sandbox/tonit/techne.audio/src/techne/audio/samplemusic/Activator.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/samplemusic/Activator.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/samplemusic/Activator.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,16 @@ +package techne.audio.samplemusic; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + public void start(BundleContext ctx) throws Exception { + System.out.println("Loading samplemusic support for techne.audio"); + } + + public void stop(BundleContext arg0) throws Exception { + System.out.println("Removing samplemusic support for techne.audio"); + } + +} Added: sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/samplemusic/SampleMusicSource.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,72 @@ +package techne.audio.samplemusic; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import org.osgi.service.component.ComponentContext; + +import techne.audio.player.MusicSource; + +/** + * Provides a sample MusicSource. MP3 Files are included right in the bundle. + * + * Its Self-Contained (does not require network, local mp3s or itunes) + * + * @author tmenzel + * + */ +public class SampleMusicSource implements MusicSource { + + boolean repeat = false; + private URL url; + // count of next() requests + int count = 0; + + public SampleMusicSource() { + } + + public boolean hasNext() { + return (repeat || count == 0); + } + + public InputStream next() { + synchronized (this) { + if (count == 0) { + count++; + try { + System.out.println("MusicSource: giving " + url.toExternalForm()); + return url.openConnection().getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + } + return null; + } + + public void setRepeat(boolean rep) { + this.repeat = rep; + } + + public InputStream current() { + try { + return url.openConnection().getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + // Declarative Services methods.. + protected void activate(ComponentContext context) { + System.out.println("Started sample MusicSource for techne.audio"); + url = context.getBundleContext().getBundle().getResource("TotallyFreeSong.mp3"); + } + + public void deactivate(ComponentContext context) throws Exception { + System.out.println("Stopped sample MusicSource for techne.audio"); + } + +} Added: sandbox/tonit/techne.audio/src/techne/audio/tui/internal/Activator.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/tui/internal/Activator.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/tui/internal/Activator.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,15 @@ +package techne.audio.tui.internal; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + public void start(BundleContext ctx) throws Exception { + System.out.println("Shell Support ON"); + } + + public void stop(BundleContext arg0) throws Exception { + System.out.println("Shell Support OFF"); + } +} Added: sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/tui/internal/PlayerControlCommand.java 2007-02-12 23:45:37 UTC (rev 50) @@ -0,0 +1,54 @@ +package techne.audio.tui.internal; + +import java.io.PrintStream; +import java.util.StringTokenizer; + +import org.apache.felix.shell.Command; + +import techne.audio.player.PlayerControl; + +public class PlayerControlCommand implements Command { + private PlayerControl control; + + public void execute(String s, PrintStream out, PrintStream err) { + out.println("audio command recognized!"); + if (control != null) { + StringTokenizer st = new StringTokenizer(s, " "); + + st.nextToken(); // Ignore the command name. + String cmd = st.nextToken(); + if ("play".equals(cmd)) { + control.play(); + }else if ("stop".equals(cmd)) { + control.stop(); + }else if ("pause".equals(cmd)) { + control.pause(); + }else if ("state".equals(cmd)) { + out.println("Current state: " + control.getState()); + }else + { + out.println("Command " + cmd + " unknown"); + out.println(getUsage()); + } + }else { + err.println("no PlayerControl instance assigned!"); + } + } + + public String getName() { + return "audio"; + } + + public String getShortDescription() { + return "Controls PlayerControl Service with felix shell"; + } + + public String getUsage() { + return "audio <play> or <stop> or <pause> or <state>"; + } + + public void setControl(PlayerControl control) { + this.control = control; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:29:23
|
Revision: 49 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=49&view=rev Author: tonit Date: 2007-02-12 15:29:24 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Modified Paths: -------------- sandbox/tonit/techne.launch/src/techne/launch/FrameworkLauncher.java sandbox/tonit/techne.launch/src/techne/launch/TechneLauncher.java sandbox/tonit/techne.launch/src/techne/launch/felix/FelixFrameworkLauncher.java Added Paths: ----------- sandbox/tonit/techne.launch/src/techne/launch/felix/FelixWrapper.java Modified: sandbox/tonit/techne.launch/src/techne/launch/FrameworkLauncher.java =================================================================== --- sandbox/tonit/techne.launch/src/techne/launch/FrameworkLauncher.java 2007-02-12 23:26:14 UTC (rev 48) +++ sandbox/tonit/techne.launch/src/techne/launch/FrameworkLauncher.java 2007-02-12 23:29:24 UTC (rev 49) @@ -3,4 +3,5 @@ public interface FrameworkLauncher { void init(String[] argv); void launch(); + void shutdown(); } Modified: sandbox/tonit/techne.launch/src/techne/launch/TechneLauncher.java =================================================================== --- sandbox/tonit/techne.launch/src/techne/launch/TechneLauncher.java 2007-02-12 23:26:14 UTC (rev 48) +++ sandbox/tonit/techne.launch/src/techne/launch/TechneLauncher.java 2007-02-12 23:29:24 UTC (rev 49) @@ -18,6 +18,8 @@ */ package techne.launch; +import java.io.File; + /** * @author Toni Menzel, based currently on apache frelix main module * <p> @@ -26,6 +28,7 @@ * </p> */ public class TechneLauncher { + public final static String TECHNE_TMP_DIR ="./tmp"; private String[] argv; public TechneLauncher(String[] argv) { @@ -38,15 +41,18 @@ } private void start() { - System.out.println("\nWelcome to Techne Runtime"); - System.out.println("============================\n"); - // just go for felix now + System.out.println("\n--> Welcome to Techne Runtime <--"); try { + // exit hook for temporary folder + File f = new File(TECHNE_TMP_DIR); + // for some reason this does not work at the mac currently..:-( + f.deleteOnExit(); + System.out.println("loading (default) felix as framework.."); FrameworkLauncher launch = (FrameworkLauncher) Class.forName( "techne.launch.felix.FelixFrameworkLauncher").newInstance(); launch.init(argv); - launch.launch(); + launch.launch(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); Modified: sandbox/tonit/techne.launch/src/techne/launch/felix/FelixFrameworkLauncher.java =================================================================== --- sandbox/tonit/techne.launch/src/techne/launch/felix/FelixFrameworkLauncher.java 2007-02-12 23:26:14 UTC (rev 48) +++ sandbox/tonit/techne.launch/src/techne/launch/felix/FelixFrameworkLauncher.java 2007-02-12 23:29:24 UTC (rev 49) @@ -26,483 +26,539 @@ import org.apache.felix.framework.util.StringMap; import techne.launch.FrameworkLauncher; +import techne.launch.TechneLauncher; -public class FelixFrameworkLauncher implements FrameworkLauncher { - /** - * The system property name used to specify an URL to the system property - * file. - */ - public static final String SYSTEM_PROPERTIES_PROP = "felix.system.properties"; - /** - * The default name used for the system properties file. - */ - public static final String SYSTEM_PROPERTIES_FILE_VALUE = "system.properties"; - /** - * The system property name used to specify an URL to the configuration - * property file to be used for the created the framework instance. - */ - public static final String CONFIG_PROPERTIES_PROP = "felix.config.properties"; - /** - * The default name used for the configuration properties file. - */ - public static final String CONFIG_PROPERTIES_FILE_VALUE = "config.properties"; +public class FelixFrameworkLauncher implements FrameworkLauncher{ + /** + * The system property name used to specify an URL to the system + * property file. + **/ + public static final String SYSTEM_PROPERTIES_PROP = "felix.system.properties"; + /** + * The default name used for the system properties file. + **/ + public static final String SYSTEM_PROPERTIES_FILE_VALUE = "system.properties"; + /** + * The system property name used to specify an URL to the configuration + * property file to be used for the created the framework instance. + **/ + public static final String CONFIG_PROPERTIES_PROP = "felix.config.properties"; + /** + * The default name used for the configuration properties file. + **/ + public static final String CONFIG_PROPERTIES_FILE_VALUE = "config.properties"; - public static final String KEYSTORE_FILE_PROP = "felix.keystore"; + public static final String KEYSTORE_FILE_PROP = "felix.keystore"; - public static final String KEYSTORE_FILE_VALUE = System - .getProperty("java.home") - + File.separatorChar - + "lib" - + File.separatorChar - + "security" - + File.separatorChar - + "cacerts" - + File.pathSeparatorChar - + System.getProperty("user.home") - + File.separatorChar - + ".keystore"; + public static final String KEYSTORE_FILE_VALUE = System.getProperty("java.home") + + File.separatorChar + "lib" + File.separatorChar + "security" + + File.separatorChar + "cacerts" + File.pathSeparatorChar + System.getProperty("user.home") + + File.separatorChar + ".keystore"; - public static final String KEYSTORE_TYPE_PROP = "felix.keystore.type"; + public static final String KEYSTORE_TYPE_PROP = "felix.keystore.type"; - public static final String KEYSTORE_TYPE_VALUE = "JKS" - + File.pathSeparatorChar + "JKS"; + public static final String KEYSTORE_TYPE_VALUE = "JKS" + File.pathSeparatorChar + "JKS"; - public static final String KEYSTORE_PASS_PROP = "felix.keystore.pass"; + public static final String KEYSTORE_PASS_PROP = "felix.keystore.pass"; - public static final String KEYSTORE_PASS_VALUE = "changeit" - + File.pathSeparatorChar + "changeit"; + public static final String KEYSTORE_PASS_VALUE = "changeit" + File.pathSeparatorChar + "changeit"; - private static Felix m_felix = null; + private static Felix m_felix = null; private String[] argv; - public FelixFrameworkLauncher() throws Exception { + public FelixFrameworkLauncher() throws Exception + { + + } + public void launch() { + FelixFrameworkLauncher.loadSystemProperties(); + try + { + Properties configProps = FelixFrameworkLauncher.loadConfigProperties(); + configProps.setProperty(BundleCache.CACHE_PROFILE_DIR_PROP,TechneLauncher.TECHNE_TMP_DIR); + m_felix = new FelixWrapper(); + m_felix.start( + new MutablePropertyResolverImpl(new StringMap(configProps, false)), + null, (System.getSecurityManager() == null) ? null : new TrustManager(configProps)); + System.out.println("felix done"); + } + catch (Exception ex) + { + System.err.println("Could not create framework: " + ex); + ex.printStackTrace(); + System.exit(-1); + } + } + + + + public void init(String[] argv) + { + this.argv = argv; + } + + + /** + * <p> + * Loads the properties in the system property file associated with the + * framework installation into <tt>System.setProperty()</tt>. These properties + * are not directly used by the framework in anyway. By default, the system + * property file is located in the <tt>conf/</tt> directory of the Felix + * installation directory and is called "<tt>system.properties</tt>". The + * installation directory of Felix is assumed to be the parent directory of + * the <tt>felix.jar</tt> file as found on the system class path property. + * The precise file from which to load system properties can be set by + * initializing the "<tt>felix.system.properties</tt>" system property to an + * arbitrary URL. + * </p> + **/ + public static void loadSystemProperties() + { + // The system properties file is either specified by a system + // property or it is in the same directory as the Felix JAR file. + // Try to load it from one of these places. - } + // See if the property URL was specified as a property. + URL propURL = null; + String custom = System.getProperty(SYSTEM_PROPERTIES_PROP); + if (custom != null) + { + try + { + propURL = new URL(custom); + } + catch (MalformedURLException ex) + { + System.err.print("Main: " + ex); + return; + } + } + else + { + // Determine where the configuration directory is by figuring + // out where felix.jar is located on the system class path. + File confDir = null; + String classpath = System.getProperty("java.class.path"); + int index = classpath.toLowerCase().indexOf("techne.jar"); + int start = classpath.lastIndexOf(File.pathSeparator, index) + 1; + if (index > start) + { + String jarLocation = classpath.substring(start, index); + if (jarLocation.length() == 0) + { + jarLocation = "."; + } + confDir = new File(new File(jarLocation).getParent(), "conf"); + } + else + { + // Can't figure it out so use the current directory as default. + confDir = new File(System.getProperty("user.dir")); + } - public void launch() { - FelixFrameworkLauncher.loadSystemProperties(); - try { - Properties configProps = FelixFrameworkLauncher - .loadConfigProperties(); - System.out - .println("keep in mind felix caches at (user.dir)/.felix/" - + configProps - .getProperty(BundleCache.CACHE_PROFILE_PROP)); - m_felix = new Felix(); - m_felix.start(new MutablePropertyResolverImpl(new StringMap( - configProps, false)), null, - (System.getSecurityManager() == null) ? null - : new TrustManager(configProps)); - System.out.println("felix done"); - } catch (Exception ex) { - System.err.println("Could not create framework: " + ex); - ex.printStackTrace(); - System.exit(-1); - } + try + { + propURL = new File(confDir, SYSTEM_PROPERTIES_FILE_VALUE).toURL(); + } + catch (MalformedURLException ex) + { + System.err.print("Main: " + ex); + return; + } + } - } + // Read the properties file. + Properties props = new Properties(); + InputStream is = null; + try + { + is = propURL.openConnection().getInputStream(); + props.load(is); + is.close(); + } + catch (FileNotFoundException ex) + { + // Ignore file not found. + } + catch (Exception ex) + { + System.err.println( + "Main: Error loading system properties from " + propURL); + System.err.println("Main: " + ex); + try + { + if (is != null) is.close(); + } + catch (IOException ex2) + { + // Nothing we can do. + } + return; + } - public void init(String[] argv) { - this.argv = argv; - } + // Perform variable substitution on specified properties. + for (Enumeration e = props.propertyNames(); e.hasMoreElements(); ) + { + String name = (String) e.nextElement(); + System.setProperty(name, + substVars(props.getProperty(name), name, null, null)); + } + } - /** - * <p> - * Loads the properties in the system property file associated with the - * framework installation into <tt>System.setProperty()</tt>. These - * properties are not directly used by the framework in anyway. By default, - * the system property file is located in the <tt>conf/</tt> directory of - * the Felix installation directory and is called "<tt>system.properties</tt>". - * The installation directory of Felix is assumed to be the parent directory - * of the <tt>felix.jar</tt> file as found on the system class path - * property. The precise file from which to load system properties can be - * set by initializing the "<tt>felix.system.properties</tt>" system - * property to an arbitrary URL. - * </p> - */ - public static void loadSystemProperties() { - // The system properties file is either specified by a system - // property or it is in the same directory as the Felix JAR file. - // Try to load it from one of these places. + /** + * <p> + * Loads the configuration properties in the configuration property file + * associated with the framework installation; these properties + * are accessible to the framework and to bundles and are intended + * for configuration purposes. By default, the configuration property + * file is located in the <tt>conf/</tt> directory of the Felix + * installation directory and is called "<tt>config.properties</tt>". + * The installation directory of Felix is assumed to be the parent + * directory of the <tt>felix.jar</tt> file as found on the system class + * path property. The precise file from which to load configuration + * properties can be set by initializing the "<tt>felix.config.properties</tt>" + * system property to an arbitrary URL. + * </p> + * @return A <tt>Properties</tt> instance or <tt>null</tt> if there was an error. + **/ + public static Properties loadConfigProperties() + { + // The config properties file is either specified by a system + // property or it is in the same directory as the Felix JAR file. + // Try to load it from one of these places. - // See if the property URL was specified as a property. - URL propURL = null; - String custom = System.getProperty(SYSTEM_PROPERTIES_PROP); - if (custom != null) { - try { - propURL = new URL(custom); - } catch (MalformedURLException ex) { - System.err.print("Main: " + ex); - return; - } - } else { - // Determine where the configuration directory is by figuring - // out where felix.jar is located on the system class path. - File confDir = null; - String classpath = System.getProperty("java.class.path"); - int index = classpath.toLowerCase().indexOf("techne.jar"); - int start = classpath.lastIndexOf(File.pathSeparator, index) + 1; - if (index > start) { - String jarLocation = classpath.substring(start, index); - if (jarLocation.length() == 0) { - jarLocation = "."; - } - confDir = new File(new File(jarLocation).getParent(), "conf"); - } else { - // Can't figure it out so use the current directory as default. - confDir = new File(System.getProperty("user.dir")); - } + // See if the property URL was specified as a property. + URL propURL = null; + String custom = System.getProperty(CONFIG_PROPERTIES_PROP); + if (custom != null) + { + try + { + propURL = new URL(custom); + } + catch (MalformedURLException ex) + { + System.err.print("Main: " + ex); + return null; + } + } + else + { + // Determine where the configuration directory is by figuring + // out where felix.jar is located on the system class path. + File confDir = null; + String classpath = System.getProperty("java.class.path"); + int index = classpath.toLowerCase().indexOf("techne.jar"); + int start = classpath.lastIndexOf(File.pathSeparator, index) + 1; + if (index > start) + { + String jarLocation = classpath.substring(start, index); + if (jarLocation.length() == 0) + { + jarLocation = "."; + } + confDir = new File(new File(jarLocation).getParent(), "conf"); + } + else + { + // Can't figure it out so use the current directory as default. + confDir = new File(System.getProperty("user.dir")); + } - try { - propURL = new File(confDir, SYSTEM_PROPERTIES_FILE_VALUE) - .toURL(); - } catch (MalformedURLException ex) { - System.err.print("Main: " + ex); - return; - } - } + try + { + propURL = new File(confDir, CONFIG_PROPERTIES_FILE_VALUE).toURL(); + } + catch (MalformedURLException ex) + { + System.err.print("Main: " + ex); + return null; + } + } - // Read the properties file. - Properties props = new Properties(); - InputStream is = null; - try { - is = propURL.openConnection().getInputStream(); - props.load(is); - is.close(); - } catch (FileNotFoundException ex) { - // Ignore file not found. - } catch (Exception ex) { - System.err.println("Main: Error loading system properties from " - + propURL); - System.err.println("Main: " + ex); - try { - if (is != null) - is.close(); - } catch (IOException ex2) { - // Nothing we can do. - } - return; - } + // Read the properties file. + Properties props = new Properties(); + InputStream is = null; + try + { + is = propURL.openConnection().getInputStream(); + props.load(is); + is.close(); + } + catch (FileNotFoundException ex) + { + // Ignore file not found. + } + catch (Exception ex) + { + System.err.println( + "Error loading config properties from " + propURL); + System.err.println("Main: " + ex); + try + { + if (is != null) is.close(); + } + catch (IOException ex2) + { + // Nothing we can do. + } + return null; + } - // Perform variable substitution on specified properties. - for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { - String name = (String) e.nextElement(); - System.setProperty(name, substVars(props.getProperty(name), name, - null, null)); - } - } + // Perform variable substitution for system properties. + for (Enumeration e = props.propertyNames(); e.hasMoreElements(); ) + { + String name = (String) e.nextElement(); + props.setProperty(name, + substVars(props.getProperty(name), name, null, props)); + } - /** - * <p> - * Loads the configuration properties in the configuration property file - * associated with the framework installation; these properties are - * accessible to the framework and to bundles and are intended for - * configuration purposes. By default, the configuration property file is - * located in the <tt>conf/</tt> directory of the Felix installation - * directory and is called "<tt>config.properties</tt>". The - * installation directory of Felix is assumed to be the parent directory of - * the <tt>felix.jar</tt> file as found on the system class path property. - * The precise file from which to load configuration properties can be set - * by initializing the "<tt>felix.config.properties</tt>" system - * property to an arbitrary URL. - * </p> - * - * @return A <tt>Properties</tt> instance or <tt>null</tt> if there was - * an error. - */ - public static Properties loadConfigProperties() { - // The config properties file is either specified by a system - // property or it is in the same directory as the Felix JAR file. - // Try to load it from one of these places. + return props; + } - // See if the property URL was specified as a property. - URL propURL = null; - String custom = System.getProperty(CONFIG_PROPERTIES_PROP); - if (custom != null) { - try { - propURL = new URL(custom); - } catch (MalformedURLException ex) { - System.err.print("Main: " + ex); - return null; - } - } else { - // Determine where the configuration directory is by figuring - // out where felix.jar is located on the system class path. - File confDir = null; - String classpath = System.getProperty("java.class.path"); - int index = classpath.toLowerCase().indexOf("techne.jar"); - int start = classpath.lastIndexOf(File.pathSeparator, index) + 1; - if (index > start) { - String jarLocation = classpath.substring(start, index); - if (jarLocation.length() == 0) { - jarLocation = "."; - } - confDir = new File(new File(jarLocation).getParent(), "conf"); - } else { - // Can't figure it out so use the current directory as default. - confDir = new File(System.getProperty("user.dir")); - } + private static final String DELIM_START = "${"; + private static final String DELIM_STOP = "}"; - try { - propURL = new File(confDir, CONFIG_PROPERTIES_FILE_VALUE) - .toURL(); - } catch (MalformedURLException ex) { - System.err.print("Main: " + ex); - return null; - } - } + /** + * <p> + * This method performs property variable substitution on the + * specified value. If the specified value contains the syntax + * <tt>${<prop-name>}</tt>, where <tt><prop-name></tt> + * refers to either a configuration property or a system property, + * then the corresponding property value is substituted for the variable + * placeholder. Multiple variable placeholders may exist in the + * specified value as well as nested variable placeholders, which + * are substituted from inner most to outer most. Configuration + * properties override system properties. + * </p> + * @param val The string on which to perform property substitution. + * @param currentKey The key of the property being evaluated used to + * detect cycles. + * @param cycleMap Map of variable references used to detect nested cycles. + * @param configProps Set of configuration properties. + * @return The value of the specified string after system property substitution. + * @throws IllegalArgumentException If there was a syntax error in the + * property placeholder syntax or a recursive variable reference. + **/ + public static String substVars(String val, String currentKey, + Map cycleMap, Properties configProps) + throws IllegalArgumentException + { + // If there is currently no cycle map, then create + // one for detecting cycles for this invocation. + if (cycleMap == null) + { + cycleMap = new HashMap(); + } - // Read the properties file. - Properties props = new Properties(); - InputStream is = null; - try { - is = propURL.openConnection().getInputStream(); - props.load(is); - is.close(); - } catch (FileNotFoundException ex) { - // Ignore file not found. - } catch (Exception ex) { - System.err.println("Error loading config properties from " - + propURL); - System.err.println("Main: " + ex); - try { - if (is != null) - is.close(); - } catch (IOException ex2) { - // Nothing we can do. - } - return null; - } + // Put the current key in the cycle map. + cycleMap.put(currentKey, currentKey); - // Perform variable substitution for system properties. - for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { - String name = (String) e.nextElement(); - props.setProperty(name, substVars(props.getProperty(name), name, - null, props)); - } + // Assume we have a value that is something like: + // "leading ${foo.${bar}} middle ${baz} trailing" - return props; - } + // Find the first ending '}' variable delimiter, which + // will correspond to the first deepest nested variable + // placeholder. + int stopDelim = val.indexOf(DELIM_STOP); - private static final String DELIM_START = "${"; - private static final String DELIM_STOP = "}"; + // Find the matching starting "${" variable delimiter + // by looping until we find a start delimiter that is + // greater than the stop delimiter we have found. + int startDelim = val.indexOf(DELIM_START); + while (stopDelim >= 0) + { + int idx = val.indexOf(DELIM_START, startDelim + DELIM_START.length()); + if ((idx < 0) || (idx > stopDelim)) + { + break; + } + else if (idx < stopDelim) + { + startDelim = idx; + } + } - /** - * <p> - * This method performs property variable substitution on the specified - * value. If the specified value contains the syntax - * <tt>${<prop-name>}</tt>, where <tt><prop-name></tt> - * refers to either a configuration property or a system property, then the - * corresponding property value is substituted for the variable placeholder. - * Multiple variable placeholders may exist in the specified value as well - * as nested variable placeholders, which are substituted from inner most to - * outer most. Configuration properties override system properties. - * </p> - * - * @param val - * The string on which to perform property substitution. - * @param currentKey - * The key of the property being evaluated used to detect cycles. - * @param cycleMap - * Map of variable references used to detect nested cycles. - * @param configProps - * Set of configuration properties. - * @return The value of the specified string after system property - * substitution. - * @throws IllegalArgumentException - * If there was a syntax error in the property placeholder - * syntax or a recursive variable reference. - */ - public static String substVars(String val, String currentKey, Map cycleMap, - Properties configProps) throws IllegalArgumentException { - // If there is currently no cycle map, then create - // one for detecting cycles for this invocation. - if (cycleMap == null) { - cycleMap = new HashMap(); - } + // If we do not have a start or stop delimiter, then just + // return the existing value. + if ((startDelim < 0) && (stopDelim < 0)) + { + return val; + } + // At this point, we found a stop delimiter without a start, + // so throw an exception. + else if (((startDelim < 0) || (startDelim > stopDelim)) + && (stopDelim >= 0)) + { + throw new IllegalArgumentException( + "stop delimiter with no start delimiter: " + + val); + } - // Put the current key in the cycle map. - cycleMap.put(currentKey, currentKey); + // At this point, we have found a variable placeholder so + // we must perform a variable substitution on it. + // Using the start and stop delimiter indices, extract + // the first, deepest nested variable placeholder. + String variable = + val.substring(startDelim + DELIM_START.length(), stopDelim); - // Assume we have a value that is something like: - // "leading ${foo.${bar}} middle ${baz} trailing" + // Verify that this is not a recursive variable reference. + if (cycleMap.get(variable) != null) + { + throw new IllegalArgumentException( + "recursive variable reference: " + variable); + } - // Find the first ending '}' variable delimiter, which - // will correspond to the first deepest nested variable - // placeholder. - int stopDelim = val.indexOf(DELIM_STOP); + // Get the value of the deepest nested variable placeholder. + // Try to configuration properties first. + String substValue = (configProps != null) + ? configProps.getProperty(variable, null) + : null; + if (substValue == null) + { + // Ignore unknown property values. + substValue = System.getProperty(variable, ""); + } - // Find the matching starting "${" variable delimiter - // by looping until we find a start delimiter that is - // greater than the stop delimiter we have found. - int startDelim = val.indexOf(DELIM_START); - while (stopDelim >= 0) { - int idx = val.indexOf(DELIM_START, startDelim - + DELIM_START.length()); - if ((idx < 0) || (idx > stopDelim)) { - break; - } else if (idx < stopDelim) { - startDelim = idx; - } - } + // Remove the found variable from the cycle map, since + // it may appear more than once in the value and we don't + // want such situations to appear as a recursive reference. + cycleMap.remove(variable); - // If we do not have a start or stop delimiter, then just - // return the existing value. - if ((startDelim < 0) && (stopDelim < 0)) { - return val; - } - // At this point, we found a stop delimiter without a start, - // so throw an exception. - else if (((startDelim < 0) || (startDelim > stopDelim)) - && (stopDelim >= 0)) { - throw new IllegalArgumentException( - "stop delimiter with no start delimiter: " + val); - } + // Append the leading characters, the substituted value of + // the variable, and the trailing characters to get the new + // value. + val = val.substring(0, startDelim) + + substValue + + val.substring(stopDelim + DELIM_STOP.length(), val.length()); - // At this point, we have found a variable placeholder so - // we must perform a variable substitution on it. - // Using the start and stop delimiter indices, extract - // the first, deepest nested variable placeholder. - String variable = val.substring(startDelim + DELIM_START.length(), - stopDelim); + // Now perform substitution again, since there could still + // be substitutions to make. + val = substVars(val, currentKey, cycleMap, configProps); - // Verify that this is not a recursive variable reference. - if (cycleMap.get(variable) != null) { - throw new IllegalArgumentException("recursive variable reference: " - + variable); - } + // Return the value. + return val; + } - // Get the value of the deepest nested variable placeholder. - // Try to configuration properties first. - String substValue = (configProps != null) ? configProps.getProperty( - variable, null) : null; - if (substValue == null) { - // Ignore unknown property values. - substValue = System.getProperty(variable, ""); - } + private static class TrustManager extends AbstractCollection + { + private String[] m_keystores = null; + private String[] m_passwds = null; + private String[] m_types = null; + private ArrayList m_stores = null; - // Remove the found variable from the cycle map, since - // it may appear more than once in the value and we don't - // want such situations to appear as a recursive reference. - cycleMap.remove(variable); + TrustManager(Properties config) + { + StringTokenizer tok = new StringTokenizer(System.getProperty(KEYSTORE_FILE_PROP, + config.getProperty(KEYSTORE_FILE_PROP, KEYSTORE_FILE_VALUE)), File.pathSeparator); - // Append the leading characters, the substituted value of - // the variable, and the trailing characters to get the new - // value. - val = val.substring(0, startDelim) + substValue - + val.substring(stopDelim + DELIM_STOP.length(), val.length()); + m_keystores = new String[tok.countTokens()]; - // Now perform substitution again, since there could still - // be substitutions to make. - val = substVars(val, currentKey, cycleMap, configProps); + for (int i = 0;tok.hasMoreTokens();i++) + { + m_keystores[i] = tok.nextToken(); + } - // Return the value. - return val; - } + tok = new StringTokenizer(System.getProperty(KEYSTORE_PASS_PROP, + config.getProperty(KEYSTORE_PASS_PROP, KEYSTORE_PASS_VALUE)), File.pathSeparator); - private static class TrustManager extends AbstractCollection { - private String[] m_keystores = null; - private String[] m_passwds = null; - private String[] m_types = null; - private ArrayList m_stores = null; + m_passwds = new String[tok.countTokens()]; - TrustManager(Properties config) { - StringTokenizer tok = new StringTokenizer(System.getProperty( - KEYSTORE_FILE_PROP, config.getProperty(KEYSTORE_FILE_PROP, - KEYSTORE_FILE_VALUE)), File.pathSeparator); + for (int i = 0;tok.hasMoreTokens();i++) + { + m_passwds[i] = tok.nextToken(); + } - m_keystores = new String[tok.countTokens()]; + tok = new StringTokenizer(System.getProperty(KEYSTORE_TYPE_PROP, + config.getProperty(KEYSTORE_TYPE_PROP, KEYSTORE_TYPE_VALUE)), File.pathSeparator); - for (int i = 0; tok.hasMoreTokens(); i++) { - m_keystores[i] = tok.nextToken(); - } + m_types = new String[tok.countTokens()]; - tok = new StringTokenizer(System - .getProperty(KEYSTORE_PASS_PROP, config.getProperty( - KEYSTORE_PASS_PROP, KEYSTORE_PASS_VALUE)), - File.pathSeparator); + for (int i = 0;tok.hasMoreTokens();i++) + { + m_types[i] = tok.nextToken(); + } + } - m_passwds = new String[tok.countTokens()]; + @Override + public synchronized Iterator iterator() + { + if (m_stores == null) + { + loadStores(); + } - for (int i = 0; tok.hasMoreTokens(); i++) { - m_passwds[i] = tok.nextToken(); - } + return m_stores.iterator(); + } - tok = new StringTokenizer(System - .getProperty(KEYSTORE_TYPE_PROP, config.getProperty( - KEYSTORE_TYPE_PROP, KEYSTORE_TYPE_VALUE)), - File.pathSeparator); + @Override + public synchronized int size() + { + if (m_stores == null) + { + loadStores(); + } - m_types = new String[tok.countTokens()]; + return m_stores.size(); + } - for (int i = 0; tok.hasMoreTokens(); i++) { - m_types[i] = tok.nextToken(); - } - } + private void loadStores() + { + m_stores = new ArrayList(); - @Override - public synchronized Iterator iterator() { - if (m_stores == null) { - loadStores(); - } + if ((m_keystores.length == m_passwds.length) && (m_passwds.length == m_types.length) + && (System.getSecurityManager() != null)) + { + AccessController.doPrivileged(new PrivilegedAction() + { + public Object run() + { + List certs = new ArrayList(); - return m_stores.iterator(); - } + for (int i = 0;i < m_keystores.length;i++) + { - @Override - public synchronized int size() { - if (m_stores == null) { - loadStores(); - } + try + { + KeyStore ks = KeyStore.getInstance(m_types[i]); + ks.load(new FileInputStream(m_keystores[i]), m_passwds[i].toCharArray()); + for (Enumeration e = ks.aliases(); e.hasMoreElements();) + { + String alias = (String) e.nextElement(); + if (ks.isCertificateEntry(alias)) + { + certs.add(ks.getCertificate(alias)); + } + } + } + catch (Exception ex) + { + certs.clear(); + ex.printStackTrace(System.err); - return m_stores.size(); - } + System.err.println("WARNING: Error accessing keystore: " + m_keystores[i]); + } - private void loadStores() { - m_stores = new ArrayList(); + if (!certs.isEmpty()) + { + m_stores.addAll(certs); + certs.clear(); + } + } - if ((m_keystores.length == m_passwds.length) - && (m_passwds.length == m_types.length) - && (System.getSecurityManager() != null)) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - List certs = new ArrayList(); + return null; + } + }); + } + if (m_stores.isEmpty()) + { + System.err.println("WARNING: No trusted CA certificates!"); + } + } + } - for (int i = 0; i < m_keystores.length; i++) { - - try { - KeyStore ks = KeyStore.getInstance(m_types[i]); - ks.load(new FileInputStream(m_keystores[i]), - m_passwds[i].toCharArray()); - for (Enumeration e = ks.aliases(); e - .hasMoreElements();) { - String alias = (String) e.nextElement(); - if (ks.isCertificateEntry(alias)) { - certs.add(ks.getCertificate(alias)); - } - } - } catch (Exception ex) { - certs.clear(); - ex.printStackTrace(System.err); - - System.err - .println("WARNING: Error accessing keystore: " - + m_keystores[i]); - } - - if (!certs.isEmpty()) { - m_stores.addAll(certs); - certs.clear(); - } - } - - return null; - } - }); - } - if (m_stores.isEmpty()) { - System.err.println("WARNING: No trusted CA certificates!"); - } - } + public void shutdown() { + // got shutdown ! + System.out.println("Got SHUTDOWN HOOK!"); } } Added: sandbox/tonit/techne.launch/src/techne/launch/felix/FelixWrapper.java =================================================================== --- sandbox/tonit/techne.launch/src/techne/launch/felix/FelixWrapper.java (rev 0) +++ sandbox/tonit/techne.launch/src/techne/launch/felix/FelixWrapper.java 2007-02-12 23:29:24 UTC (rev 49) @@ -0,0 +1,17 @@ +package techne.launch.felix; + +import org.apache.felix.framework.Felix; + +public class FelixWrapper extends Felix { + FelixFrameworkLauncher launcher; + + public void FelixWrapper(FelixFrameworkLauncher launcher) { + this.launcher = launcher; + } + + public void shutdown() { + super.shutdown(); + launcher.shutdown(); + // + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:26:13
|
Revision: 48 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=48&view=rev Author: tonit Date: 2007-02-12 15:26:14 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Modified Paths: -------------- sandbox/tonit/techne-env/bin/techne.jar Added Paths: ----------- sandbox/tonit/techne-env/lib/bnd-0.0.110.jar Property Changed: ---------------- sandbox/tonit/techne-env/ Property changes on: sandbox/tonit/techne-env ___________________________________________________________________ Name: svn:ignore + tmp Modified: sandbox/tonit/techne-env/bin/techne.jar =================================================================== (Binary files differ) Added: sandbox/tonit/techne-env/lib/bnd-0.0.110.jar =================================================================== (Binary files differ) Property changes on: sandbox/tonit/techne-env/lib/bnd-0.0.110.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:23:48
|
Revision: 47 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=47&view=rev Author: tonit Date: 2007-02-12 15:23:49 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Modified Paths: -------------- sandbox/tonit/techne-env/conf/config.properties sandbox/tonit/techne-env/development/build/build.xml sandbox/tonit/techne-env/lib/org.apache.felix.framework-0.9.0-incubator-SNAPSHOT.jar Added Paths: ----------- sandbox/tonit/techne-env/lib/org.eclipse.osgi_3.2.1.R32x_v20060919.jar Property Changed: ---------------- sandbox/tonit/techne-env/lib/ Modified: sandbox/tonit/techne-env/conf/config.properties =================================================================== --- sandbox/tonit/techne-env/conf/config.properties 2007-02-12 23:11:50 UTC (rev 46) +++ sandbox/tonit/techne-env/conf/config.properties 2007-02-12 23:23:49 UTC (rev 47) @@ -1,6 +1,5 @@ # this is to be merged across osgi framwworks # FELIX specific section: -felix.cache.profile=technelaunch org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \ org.osgi.service.packageadmin; version=1.2.0, \ org.osgi.service.startlevel; version=1.0.0, \ @@ -15,7 +14,6 @@ file:bundle/org.apache.felix.bundlerepository-0.9.0-incubator-SNAPSHOT.jar \ file:bundle/org.osgi.compendium-0.9.0-incubator-SNAPSHOT.jar \ file:bundle/org.apache.felix.http.jetty-0.8.0-SNAPSHOT.jar \ - file:bundle/org.apache.felix.scr-0.9.0-incubator-SNAPSHOT.jar \ file:bundle/org.apache.felix.log-0.9.0-incubator-SNAPSHOT.jar \ file:bundle/aQute.fileinstall-1.0.jar felix.log.level=1 Modified: sandbox/tonit/techne-env/development/build/build.xml =================================================================== --- sandbox/tonit/techne-env/development/build/build.xml 2007-02-12 23:11:50 UTC (rev 46) +++ sandbox/tonit/techne-env/development/build/build.xml 2007-02-12 23:23:49 UTC (rev 47) @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!--base for techne build assembly --> <project name="techne.development" default="bundle" basedir="../../../"> + <property name="dir.felixtrunk" value="/Users/tmenzel/devel/felix/felix/trunk" /> <target name="bundle"> <jar destfile="techne-env/load/${component}.jar" manifest="${component}/resources/META-INF/MANIFEST.MF"> <fileset dir="${component}/bin"> @@ -40,5 +41,12 @@ <target name="uninstall"> <delete file="../techne-env/load/techne.audio.jar"></delete> </target> - + + <target name="synclibs"> + <copy todir="../techne-env/lib" > + <fileset dir="${dir.felixtrunk}/framework/target/"> + <include name="*.jar"/> + </fileset> + </copy> + </target> </project> \ No newline at end of file Property changes on: sandbox/tonit/techne-env/lib ___________________________________________________________________ Name: svn:ignore + tmp Modified: sandbox/tonit/techne-env/lib/org.apache.felix.framework-0.9.0-incubator-SNAPSHOT.jar =================================================================== (Binary files differ) Added: sandbox/tonit/techne-env/lib/org.eclipse.osgi_3.2.1.R32x_v20060919.jar =================================================================== (Binary files differ) Property changes on: sandbox/tonit/techne-env/lib/org.eclipse.osgi_3.2.1.R32x_v20060919.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:11:50
|
Revision: 46 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=46&view=rev Author: tonit Date: 2007-02-12 15:11:50 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Added Paths: ----------- sandbox/tonit/techne.audio/techne.audio.itunes.bnd sandbox/tonit/techne.audio/techne.audio.player.bnd sandbox/tonit/techne.audio/techne.audio.samplemusic.bnd sandbox/tonit/techne.audio/techne.audio.tui.bnd Added: sandbox/tonit/techne.audio/techne.audio.itunes.bnd =================================================================== --- sandbox/tonit/techne.audio/techne.audio.itunes.bnd (rev 0) +++ sandbox/tonit/techne.audio/techne.audio.itunes.bnd 2007-02-12 23:11:50 UTC (rev 46) @@ -0,0 +1,5 @@ +Private-Package: techne.audio.itunes +Bundle-Activator: techne.audio.itunes.Activator +Service-Component=techne.audio.itunes.ItunesMusicSource;\ +provide:=techne.audio.player.MusicSource +-sources= Added: sandbox/tonit/techne.audio/techne.audio.player.bnd =================================================================== --- sandbox/tonit/techne.audio/techne.audio.player.bnd (rev 0) +++ sandbox/tonit/techne.audio/techne.audio.player.bnd 2007-02-12 23:11:50 UTC (rev 46) @@ -0,0 +1,7 @@ +Export-Package: techne.audio.player +Private-Package: techne.audio.player.internal +Bundle-Activator: techne.audio.player.Activator +Service-Component=techne.audio.player.internal.JavaZoomMusicPlayer;\ +musicSource=techne.audio.player.MusicSource; \ +provide:=techne.audio.player.PlayerControl +-sources= Added: sandbox/tonit/techne.audio/techne.audio.samplemusic.bnd =================================================================== --- sandbox/tonit/techne.audio/techne.audio.samplemusic.bnd (rev 0) +++ sandbox/tonit/techne.audio/techne.audio.samplemusic.bnd 2007-02-12 23:11:50 UTC (rev 46) @@ -0,0 +1,6 @@ +Private-Package: techne.audio.samplemusic +Bundle-Activator: techne.audio.samplemusic.Activator +Service-Component=techne.audio.samplemusic.SampleMusicSource;\ +provide:=techne.audio.player.MusicSource +Include-Resource: resources/techne.audio.samplemusic/ +-sources= Added: sandbox/tonit/techne.audio/techne.audio.tui.bnd =================================================================== --- sandbox/tonit/techne.audio/techne.audio.tui.bnd (rev 0) +++ sandbox/tonit/techne.audio/techne.audio.tui.bnd 2007-02-12 23:11:50 UTC (rev 46) @@ -0,0 +1,6 @@ +Private-Package: techne.audio.tui.internal +Bundle-Activator: techne.audio.tui.internal.Activator +Service-Component=techne.audio.tui.internal.PlayerControlCommand;\ +control=techne.audio.player.PlayerControl; \ +provide:=org.apache.felix.shell.Command +-sources= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <to...@us...> - 2007-02-12 23:10:14
|
Revision: 45 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=45&view=rev Author: tonit Date: 2007-02-12 15:10:12 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Added Paths: ----------- sandbox/tonit/techne.audio/src/techne/audio/player/ sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java sandbox/tonit/techne.audio/src/techne/audio/player/internal/ sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java Removed Paths: ------------- sandbox/tonit/techne.audio/src/techne/audio/Activator.java sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java Deleted: sandbox/tonit/techne.audio/src/techne/audio/Activator.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/Activator.java 2007-02-12 05:00:13 UTC (rev 44) +++ sandbox/tonit/techne.audio/src/techne/audio/Activator.java 2007-02-12 23:10:12 UTC (rev 45) @@ -1,24 +0,0 @@ -package techne.audio; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class Activator implements BundleActivator { - - public void start(BundleContext ctx) throws Exception { - System.out.println("Audio ON"); - try { - System.out.println("Component header: " - + ctx.getBundle().getHeaders().get("Service-Component")); - - System.out.println("LogReader wired!"); - } catch (Exception e) { - System.out.println("Cannot wire to logreader"); - } - } - - public void stop(BundleContext arg0) throws Exception { - System.out.println("Audio OFF"); - } - -} Deleted: sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java 2007-02-12 05:00:13 UTC (rev 44) +++ sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java 2007-02-12 23:10:12 UTC (rev 45) @@ -1,33 +0,0 @@ -package techne.audio; - -import java.net.URL; -import java.net.URLConnection; - -import javazoom.jl.player.Player; - -public class BackgroundPlayer extends Thread { - private URL url; - - public BackgroundPlayer(URL url) { - System.out.println("backgroundplayer loading.."); - this.url = url; - } - - public void run() { - try { - URLConnection urlCon = url.openConnection(); - urlCon.getInputStream(); - Player pl = new Player(urlCon.getInputStream()); - - System.out.println("Start running backgroundplayer.."); - pl.play(); - System.out.println("Song should be finished now"); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - System.out.println(e.getMessage()); - throw new RuntimeException(e); - } - } - -} Deleted: sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java 2007-02-12 05:00:13 UTC (rev 44) +++ sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java 2007-02-12 23:10:12 UTC (rev 45) @@ -1,46 +0,0 @@ -package techne.audio; - -import java.net.URL; -import java.net.URLConnection; - -import javazoom.jl.player.Player; - -import org.osgi.service.component.ComponentContext; - -public class PlayerService extends Thread { - private ComponentContext context; - Player pl = null; - - public PlayerService() { - System.out.println("public constructor called!"); - } - - protected void activate(ComponentContext context) { - this.context = context; - start(); - } - - public void deactivate(ComponentContext context) throws Exception { - if (pl != null) pl.close(); - if (this.isAlive()) this.interrupt(); - System.out.println("Player Service is down"); - } - - public void run() { - try { - URL url = context.getBundleContext().getBundle().getResource("techne_hook.mp3"); - URLConnection urlCon = url.openConnection(); - urlCon.getInputStream(); - pl = new Player(urlCon.getInputStream()); - - System.out.println("Start running backgroundplayer.."); - pl.play(); - System.out.println("Song should be finished now"); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - System.out.println(e.getMessage()); - throw new RuntimeException(e); - } - } -} Copied: sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java (from rev 8, sandbox/tonit/techne.audio/src/techne/audio/Activator.java) =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java 2007-02-12 23:10:12 UTC (rev 45) @@ -0,0 +1,24 @@ +package techne.audio.player; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + public void start(BundleContext ctx) throws Exception { + System.out.println("Audio ON"); + try { + System.out.println("Component header: " + + ctx.getBundle().getHeaders().get("Service-Component")); + + System.out.println("LogReader wired!"); + } catch (Exception e) { + System.out.println("Cannot wire to logreader"); + } + } + + public void stop(BundleContext arg0) throws Exception { + System.out.println("Audio OFF"); + } + +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java 2007-02-12 23:10:12 UTC (rev 45) @@ -0,0 +1,82 @@ +package techne.audio.player.internal; + +import org.osgi.service.component.ComponentContext; + +import techne.audio.player.MusicSource; +import techne.audio.player.PlayerControl; + +/** + * + * Currently it just supports a single track. Later it will accept mutiple + * tracks. Those track shoudl come from a MusicSource impl. Thus, the controls + * will likely to be extended (foward,backward) + * + * + * @author tmenzel + * + */ +public class JavaZoomMusicPlayer implements PlayerControl { + private JavaZoomPlayerThread thread; + private MusicSource musicSource; + private ComponentContext context; + + public JavaZoomMusicPlayer() { + } + + protected void activate(ComponentContext context) { + this.context = context; + // reference hopefully injected already? + if (musicSource != null) { + thread = new JavaZoomPlayerThread(); + thread.setMusicSource(musicSource); + } else { + System.out.println("There is no musicSource for some reason.. :-("); + } + } + + public void deactivate(ComponentContext context) throws Exception { + if (thread != null) { + thread.changeState(PlayerState.STATE_OFF); + thread.close(); + } + System.out.println("Player Service is down"); + } + + public void pause() { + thread.changeState(PlayerState.STATE_PAUSE); + } + + public void play() { + if (thread == null) { + thread = new JavaZoomPlayerThread(); + thread.setMusicSource(musicSource); + } + + if (thread != null) { + if (!thread.isAlive()) { + System.out.println("start player thread.."); + thread.start(); + } + thread.changeState(PlayerState.STATE_PLAY); + } + } + + public void stop() { + if (thread != null) { + thread.changeState(PlayerState.STATE_IDLE); + } + } + + public MusicSource getMusicSource() { + return musicSource; + } + + public void setMusicSource(MusicSource source) { + this.musicSource = source; + } + + public int getState() { + return thread.getCurrentPlayerState(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-02-12 05:00:12
|
Revision: 44 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=44&view=rev Author: rickles Date: 2007-02-11 21:00:13 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Fixed NPE problem when framework command is typed in before setting the framework. Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java Modified: sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java =================================================================== --- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-12 00:31:10 UTC (rev 43) +++ sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-12 05:00:13 UTC (rev 44) @@ -172,7 +172,7 @@ context = (BundleContext) getContext.invoke(systemBundle, null); System.out.println("BundleContext: " + context); - Class clazz = Class.forName("org.apache.felix.shell.ShellService"); + //Class clazz = Class.forName("org.apache.felix.shell.ShellService"); Object[] args = {line, in, out}; ServiceReference ref = context.getServiceReference(ShellService.class.getName()); @@ -186,6 +186,9 @@ //Thread.currentThread().setContextClassLoader(clazz.getClassLoader()); //shell = ShellService.class.cast(o); } + } catch (NullPointerException npe) { + logger.warn("Could not invoke execute method: ", npe); + System.out.println("Cannot execute framework command. Please select a framework."); } catch (Exception e) { e.printStackTrace(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-02-12 00:31:13
|
Revision: 43 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=43&view=rev Author: rickles Date: 2007-02-11 16:31:10 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Update the classpath to use 0.8 version of Felix. Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.core/.classpath Modified: sandbox/rickles/org.digivitality.techne.core/.classpath =================================================================== --- sandbox/rickles/org.digivitality.techne.core/.classpath 2007-02-12 00:30:11 UTC (rev 42) +++ sandbox/rickles/org.digivitality.techne.core/.classpath 2007-02-12 00:31:10 UTC (rev 43) @@ -5,5 +5,7 @@ <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.0.4.jar"/> <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.9.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/org.digivitality.techne.shell"/> + <classpathentry sourcepath="C:/Workspace/Projects/JAVA/ApacheFelix" kind="lib" path="lib/felix.jar"/> + <classpathentry sourcepath="/org.digivitality.techne.bundle/src/org/digivitality/techne/bundle" kind="lib" path="bundle/org.digivitality.techne.bundle_1.0.0.jar"/> <classpathentry kind="output" path="classes"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-02-12 00:30:11
|
Revision: 42 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=42&view=rev Author: rickles Date: 2007-02-11 16:30:11 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Intercept all felix shell commands. Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.shell/.classpath sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java Modified: sandbox/rickles/org.digivitality.techne.shell/.classpath =================================================================== --- sandbox/rickles/org.digivitality.techne.shell/.classpath 2007-02-12 00:27:16 UTC (rev 41) +++ sandbox/rickles/org.digivitality.techne.shell/.classpath 2007-02-12 00:30:11 UTC (rev 42) @@ -4,6 +4,8 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="lib" path="/org.digivitality.techne.core/lib/commons-logging-1.0.4.jar"/> - <classpathentry kind="lib" path="C:/Workspace/eclipse-3.2/techne/sandbox/tonit/techne-env/bin/techne.jar"/> + <classpathentry kind="lib" path="/org.digivitality.techne.core/lib/felix.jar"/> + <classpathentry kind="lib" path="/org.digivitality.techne.core/bundle/org.apache.felix.shell-0.8.0-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="/org.digivitality.techne.core/classes"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java =================================================================== --- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-12 00:27:16 UTC (rev 41) +++ sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-12 00:30:11 UTC (rev 42) @@ -5,11 +5,20 @@ import java.io.*; import java.text.*; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +//import org.ungoverned.osgi.service.shell.ShellService; +import org.apache.felix.shell.ShellService; +import org.apache.felix.shell.impl.*; +import org.apache.felix.framework.*; -import techne.launch.*; +import org.digivitality.techne.launch.felix.*; /** * This is intended to demonstrate the concept of a container shell. @@ -26,6 +35,11 @@ private boolean stopping = false; Thread techneThread; Thread frameworkThread; + FelixLauncher launcher; + FelixFrameworkThread felix; + //static ShellService shellService; + static Method executeCommand; + BundleContext context; public void init() { System.out.println("\n===============================================================================\n"); @@ -47,6 +61,7 @@ public void execute() { final Runnable shell = new Runnable() { + public void run() { String line = null; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); @@ -90,20 +105,34 @@ * Will use Command pattern later on. */ public void runCommand(String line, PrintStream out, PrintStream err) { - + if (line.equals("set framework to Felix")) { if (FRAMEWORK_SET) { out.print("Framework has already been set to Felix\n"); } else { - frameworkThread = new Thread(new FelixFrameworkThread()); + try { + File file = new File("mytempfile"); + System.out.println("Where am i: " + file.getCanonicalPath()); + } catch (Exception e) { + e.printStackTrace(); + } + felix = new FelixFrameworkThread(); + frameworkThread = new Thread(felix); frameworkThread.setPriority(1); frameworkThread.start(); } } else if (line.equals("exit") || line.equals("quit") ) { stopping = true; - System.exit(0); - } else { - out.print("Unsupported command. Please try another command.\n"); + try { + Runtime.getRuntime().halt(0); + } catch (Exception e) { + e.printStackTrace(); + } finally { + System.exit(0); + } + } else { // assume that it is a framework command + //out.print("Unsupported command. Please try another command.\n"); + execute(line, System.out, System.out); } } }; @@ -112,14 +141,96 @@ techneThread.start(); } - private class FelixFrameworkThread implements Runnable { + protected void execute(String line, PrintStream in, PrintStream out) { + //Bundle[] bundles = felix.getBundles(); + ShellService shell = null; + //System.out.println("Bundles found: " + bundles.length); + + /* + for (int i = 0; i < bundles.length; i++) { + System.out.println("Got this bundle: " + bundles[i].getLocation()); + if (bundles[i].getSymbolicName().startsWith("org.digivitality.techne.bundle")) { + try { + Class clazz = bundles[i].getClass(); + System.out.println("clazz: " + clazz.getName()); + Method m = clazz.getSuperclass().getDeclaredMethod("getShellService", new Class[0]); + m.setAccessible(true); + shell = (ShellService)m.invoke(bundles[i], new Object[0]); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + */ + try { + Method m = Felix.class.getDeclaredMethod("getBundle", new Class[] { long.class }); + m.setAccessible(true); + Bundle systemBundle = (Bundle) m.invoke(launcher.getFelix(), new Object[] { new Long(0) }); + System.out.println("systemBundle superclass: " + systemBundle.getClass().getSuperclass().getName()); + Method getContext = systemBundle.getClass().getSuperclass().getDeclaredMethod("getContext", null); + getContext.setAccessible(true); + context = (BundleContext) getContext.invoke(systemBundle, null); + System.out.println("BundleContext: " + context); + + Class clazz = Class.forName("org.apache.felix.shell.ShellService"); + Object[] args = {line, in, out}; + + ServiceReference ref = context.getServiceReference(ShellService.class.getName()); + if (ref!=null) { + Object o = context.getService(ref); + System.out.println("o: " + o.getClass().getName() + " cl: " + o.getClass().getClassLoader()); + Class[] parameterTypes={String.class,PrintStream.class,PrintStream.class}; + executeCommand = o.getClass().getDeclaredMethod("executeCommand", parameterTypes); + executeCommand.setAccessible(true); + executeCommand.invoke(o, args); + //Thread.currentThread().setContextClassLoader(clazz.getClassLoader()); + //shell = ShellService.class.cast(o); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static BundleContext getBundleContext(Bundle bundle) { + try { + Class clazz = bundle.getClass(); + /* + System.out.println("clazz is " + clazz.getName()); Field field = clazz.getDeclaredField("bundleContext"); + field.setAccessible(true); + return (BundleContext) field.get(bundle); + */ + Method m = clazz.getDeclaredMethod("getContext", new Class[0]); + m.setAccessible(true); + return (BundleContext) m.invoke(bundle, new Object[0]); + } catch (Exception e) { + logger.error("getBundleContext failed", e); + e.printStackTrace(); + return null; + } + } + + class FelixFrameworkThread implements Runnable { + + Bundle[] bundles; + public void run() { try { - TechneLauncher.main(null); + launcher = new FelixLauncher(); + launcher.launch(); System.out.print("techne> "); } catch (Exception e) { e.printStackTrace(); } } + + /* + public Bundle[] getBundles() { + return launcher.getBundles(); + } + + public Object getService(Bundle b, ServiceReference ref) { + return launcher.getService(b, ref); + } + */ } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-02-12 00:27:19
|
Revision: 41 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=41&view=rev Author: rickles Date: 2007-02-11 16:27:16 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Created project to test the service bundle. Added Paths: ----------- sandbox/rickles/org.digivitality.techne.service/ sandbox/rickles/org.digivitality.techne.service/.classpath sandbox/rickles/org.digivitality.techne.service/.project sandbox/rickles/org.digivitality.techne.service/bin/ sandbox/rickles/org.digivitality.techne.service/build.xml sandbox/rickles/org.digivitality.techne.service/org.digivitality.techne.service-1.0.0.jar sandbox/rickles/org.digivitality.techne.service/src/ sandbox/rickles/org.digivitality.techne.service/src/META-INF/ sandbox/rickles/org.digivitality.techne.service/src/META-INF/Manifest.mf sandbox/rickles/org.digivitality.techne.service/src/org/ sandbox/rickles/org.digivitality.techne.service/src/org/digivitality/ sandbox/rickles/org.digivitality.techne.service/src/org/digivitality/techne/ sandbox/rickles/org.digivitality.techne.service/src/org/digivitality/techne/service/ sandbox/rickles/org.digivitality.techne.service/src/org/digivitality/techne/service/Activator.java Added: sandbox/rickles/org.digivitality.techne.service/.classpath =================================================================== --- sandbox/rickles/org.digivitality.techne.service/.classpath (rev 0) +++ sandbox/rickles/org.digivitality.techne.service/.classpath 2007-02-12 00:27:16 UTC (rev 41) @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry sourcepath="C:/Workspace/Projects/JAVA/ApacheFelix" kind="lib" path="/org.digivitality.techne.core/lib/felix.jar"/> + <classpathentry kind="lib" path="/org.digivitality.techne.core/lib/commons-logging-1.0.4.jar"/> + <classpathentry kind="output" path="classes"/> +</classpath> Added: sandbox/rickles/org.digivitality.techne.service/.project =================================================================== --- sandbox/rickles/org.digivitality.techne.service/.project (rev 0) +++ sandbox/rickles/org.digivitality.techne.service/.project 2007-02-12 00:27:16 UTC (rev 41) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.digivitality.techne.service</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: sandbox/rickles/org.digivitality.techne.service/build.xml =================================================================== --- sandbox/rickles/org.digivitality.techne.service/build.xml (rev 0) +++ sandbox/rickles/org.digivitality.techne.service/build.xml 2007-02-12 00:27:16 UTC (rev 41) @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project name="org.digivitality.techne.service" default="all" basedir="."> + <property name="classes.dir" value="classes"/> + <property name="src.dir" value="src"/> + <property name="lib.dir" value="lib"/> + <property name="metainf.dir" value="${src.dir}/META-INF"/> + <property name="version" value="1.0.0"/> + <property name="techne.core" value="../org.digivitality.techne.core"/> + <property name="deploy.dir" value="${techne.core}/bin/load"/> + + <target name="init"> + <mkdir dir="${metainf.dir}"/> + </target> + + <!-- Create the bundle. --> + <target name="jar" depends="init"> + <manifest file="${metainf.dir}/Manifest.mf"> + <attribute name="Manifest-Version" value="1.0"/> + <attribute name="Bundle-ManifestVersion" value="2"/> + <attribute name="Bundle-Name" value="Techne Service Plugin"/> + <attribute name="Bundle-SymbolicName" value="org.digivitality.techne.service"/> + <attribute name="Bundle-Version" value="1.0.0"/> + <attribute name="Bundle-Activator" value="org.digivitality.techne.service.Activator"/> + <attribute name="Import-Package" value="org.osgi.framework,org.apache.felix.shell,org.apache.commons.logging"/> + </manifest> + <jar jarfile="${ant.project.name}-${version}.jar" + basedir="${classes.dir}" + manifest="${metainf.dir}/Manifest.mf"> + <include name="**/*"/> + </jar> + </target> + + <target name="deploy"> + <copy todir="${deploy.dir}"> + <fileset dir="${basedir}" includes="*.jar"/> + </copy> + </target> + + <target name="all" depends="init"> + <antcall target="clean"/> + <antcall target="jar"/> + <antcall target="deploy"/> + </target> + + <!-- Clean up everything. --> + <target name="clean"> + <delete> + <fileset dir="${metainf.dir}"/> + <fileset dir="${deploy.dir}"> + <include name="${ant.project.name}-${version}.jar"/> + </fileset> + </delete> + </target> +</project> Added: sandbox/rickles/org.digivitality.techne.service/org.digivitality.techne.service-1.0.0.jar =================================================================== (Binary files differ) Property changes on: sandbox/rickles/org.digivitality.techne.service/org.digivitality.techne.service-1.0.0.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: sandbox/rickles/org.digivitality.techne.service/src/META-INF/Manifest.mf =================================================================== --- sandbox/rickles/org.digivitality.techne.service/src/META-INF/Manifest.mf (rev 0) +++ sandbox/rickles/org.digivitality.techne.service/src/META-INF/Manifest.mf 2007-02-12 00:27:16 UTC (rev 41) @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.6.5 +Created-By: 1.5.0_07-b03 (Sun Microsystems Inc.) +Bundle-ManifestVersion: 2 +Bundle-Name: Techne Service Plugin +Bundle-SymbolicName: org.digivitality.techne.service +Bundle-Version: 1.0.0 +Bundle-Activator: org.digivitality.techne.service.Activator +Import-Package: org.osgi.framework,org.apache.felix.shell,org.apache.c + ommons.logging + Added: sandbox/rickles/org.digivitality.techne.service/src/org/digivitality/techne/service/Activator.java =================================================================== --- sandbox/rickles/org.digivitality.techne.service/src/org/digivitality/techne/service/Activator.java (rev 0) +++ sandbox/rickles/org.digivitality.techne.service/src/org/digivitality/techne/service/Activator.java 2007-02-12 00:27:16 UTC (rev 41) @@ -0,0 +1,29 @@ +/** + * + */ +package org.digivitality.techne.service; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author Rick Litton + * + */ +public class Activator implements BundleActivator { + + protected BundleContext bc; + protected final Log logger = LogFactory.getLog(getClass()); + + public void start(BundleContext context) throws Exception { + logger.info("Starting the service bundle..."); + } + + public void stop(BundleContext context) throws Exception { + logger.info("Stopping the service bundle..."); + + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-02-12 00:23:53
|
Revision: 40 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=40&view=rev Author: rickles Date: 2007-02-11 16:23:54 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Create a simple Felix launcher for testing purposes. Added Paths: ----------- sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/launch/ sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/launch/felix/ sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/launch/felix/FelixLauncher.java Added: sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/launch/felix/FelixLauncher.java =================================================================== --- sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/launch/felix/FelixLauncher.java (rev 0) +++ sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/launch/felix/FelixLauncher.java 2007-02-12 00:23:54 UTC (rev 40) @@ -0,0 +1,48 @@ +package org.digivitality.techne.launch.felix; + +import java.io.*; +import java.util.*; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.apache.felix.framework.Felix; +import org.apache.felix.main.Main; +import org.apache.felix.framework.util.*; +import org.digivitality.techne.shell.Shell; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +/** + * Just a simple launcher for testing Felix + * + */ + +public class FelixLauncher { + + private BundleContext context; + private Felix felix; + protected static final Log logger = LogFactory.getLog(FelixLauncher.class); + + protected Properties getFelixConfiguration() throws Exception { + Main.loadSystemProperties(); + Properties configProps = Main.loadConfigProperties(); + return configProps; + } + + public void launch() { + try + { + felix = new Felix(); + felix.start(new MutablePropertyResolverImpl(new StringMap(getFelixConfiguration(), false)), + null, null); + } catch (Exception ex) { + ex.printStackTrace(); + System.exit(-1); + } + } + + public Felix getFelix() { + return felix; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-02-12 00:22:35
|
Revision: 39 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=39&view=rev Author: rickles Date: 2007-02-11 16:22:36 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Use apache commons LogFactory instead of log4j. Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/Main.java Modified: sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/Main.java =================================================================== --- sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/Main.java 2007-02-12 00:19:11 UTC (rev 38) +++ sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/Main.java 2007-02-12 00:22:36 UTC (rev 39) @@ -5,9 +5,11 @@ import org.apache.log4j.*; import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.impl.Log4JLogger; import org.digivitality.techne.shell.*; +import org.digivitality.techne.launch.felix.*; /** * Generic starter. @@ -17,18 +19,18 @@ */ public class Main { - static Logger logger = Logger.getLogger(Main.class); + static Log logger = LogFactory.getLog(Main.class); /** * @param args */ public static void main(String[] args) { - PropertyConfigurator.configure("../conf/log4j.properties"); - logger.info("user.dir = " + System.getProperty("user.dir")); - System.getProperties().setProperty(Log.class.getName(), - Log4JLogger.class.getName()); + (LogFactory.getLog(Main.class)).info("user.dir = " + System.getProperty("user.dir")); Shell container = new Shell(); container.init(); + /* test to run launcher directly */ + //FelixLauncher l = new FelixLauncher(); + //l.launch(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |