Re: Manifold questions: Creating sinks/sources

2022-08-10 Thread Jason Zwolak
I don't think you need two streams at all. Unless there's more code in 
between the two streams that you're not showing.

Would the following work:
(def -private-stream- (s/stream ...))
(def my-sink (s/sink-only -private-stream-)) 
(def my-source (s/source-only -private-stream-))

Or if you really want `-private-stream-` to be out of scope, then a fn to 
create the source and sink could be used. Something like

(defn create-sink-and-source []
  (let [private-stream (s/stream ...)]
{:sink (s/sink-only private-stream)
 :source (s/source-only private-stream}))

(def sink-and-source (create-sink-and-source))
(def my-sink (:sink sink-and-source))
(def my-source (:source sink-and-source))

Since a stream is both a sink and a source, you can mask it with 
`sink-only` and `source-only` to get the appearance of having just a sink 
_and_ just a source. I would like to point out that having two streams does 
nothing different than having one other than the overhead and complexity of 
moving data between two streams. Unless, as I said earlier, you're doing 
something in between the two streams.
On Thursday, August 27, 2015 at 4:18:33 PM UTC-4 atamert...@gmail.com wrote:

>
>
> On Thu, Aug 27, 2015 at 10:51 PM, Zach Tellman  wrote:
>
>> Hi Atamert,
>>
>>
> Hi Zach,
>  
>
>> For future reference, posting these questions to 
>> https://groups.google.com/forum/#!forum/aleph-lib will ensure I'll see 
>> them sooner.  
>>
>
> I've subscribed. Thanks.
>
>  
>
>>
>> The `source-only` method is just a way to make sure that the chance for 
>> confusion is minimized, it doesn't prevent the underlying object from being 
>> used normally.  As for your scenario, I'm not sure I completely 
>> understand.  In a standard stream, the flow of data is:
>>
>> [ sink -> source ]
>>
>> So if you `put!` something into the sink, you can `take!` it from the 
>> source.  If you use `source-only` and connect that to some other sink, then 
>> the flow of data will be
>>
>> [ sink -> source ] -> sink
>>
>> So the source is only connected to one sink, not two.  Maybe I'm 
>> misunderstanding you, though.
>>
>
> I have initially written it right. I was looking through the docs and the 
> source at the same time and I got confused. Then I replaced source with 
> sink and vice versa. So if you are misunderstanding, you are understanding. 
> :)
>
> Let me try again. If we have:
>
> (def my-sink (s/sink-only (s/stream ...))) 
> (def my-source (s/source-only (s/stream ...)))
> (s/connect my-source my-sink)   ;; BTW this got me confused, I thought 
> flow was like my-source -> my-sink
>
> After I have written the comment above, and playing with this code in the 
> REPL, I have realized the flow IS from source to sink.
>
> I think I am un-confused now, and it all makes sense. I have a producer 
> side and a consumer side. Instead of repeating a function call, I want to 
> connect these two components using a stream. I thought I'd need half a 
> stream here and half a stream there. But now I realize I need two whole 
> streams, connect them, put! on one side, take! on the other. I hope it 
> makes sense. Sorry for the noise.
>
>
>  
>
>>
>> Zach
>>
>> On Thursday, August 27, 2015 at 4:13:35 AM UTC-7, Atamert Ölçgen wrote:
>>>
>>> Hi,
>>>
>>> AFAIK the only way to create (just) a source (or sink) is:
>>>
>>> (def my-source (s/source-only (s/stream ...)))
>>>
>>> This results in creating a stream and then wrapping it with a 
>>> SourceProxy. We don't keep a reference to the stream and 
>>> the SourceProxy doesn't allow taking.
>>>
>>> But if I'm not missing something since SourceProxy keeps a reference of 
>>> the original stream, there is a sink nobody is using there.
>>>
>>> If I create a sink separately and connect my-source to it, now 
>>> my-source would be connected to two sinks.
>>>
>>> My questions are:
>>>
>>> 1. Is there another method for creating only sinks or sources?
>>> 2. Should the extra/unused source/sink I mentioned above cause concern?
>>>
>>> PS: I'm not talking about a scenario where we're creating thousands 
>>> streams and connecting them all like there's no tomorrow.
>>>
>>>
>>> -- 
>>> Kind Regards,
>>> Atamert Ölçgen
>>>
>>> ◻◼◻
>>> ◻◻◼
>>> ◼◼◼
>>>
>>> www.muhuk.com
>>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Kind Regards,
> Atamert 

Strange classpath / ClassNotFoundException with Swing and JavaFX

2016-05-09 Thread Jason Zwolak
I don't want to cross post, but I wanted to see if anyone on this list can 
answer this tough StackOverflow question:

http://stackoverflow.com/questions/37119814/swing-javafx-and-clojure-arent-playing-nice-with-the-classpath

It's a strange ClassNotFoundException that requires a specific order of 
Swing and JavaFX initialization and the use of Clojure's eval.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2016-03-21 Thread Jason Zwolak
I sat down to use fx-fn today and discovered another library fx-clj.

fx-clj hasn't had any activity for over a year, but it does use core.async,
which seems to be the right direction if you want clean UI code:
http://www.infoq.com/presentations/core-async-clojure

Any plans to incorporate core.async into fx-fn? fx-clj does seem to be more
mature than fx-fn... and I'm not sure if the two projects need to be
separate projects other than they started independently... I think the
efforts may be best placed behind one project...

I'm very interested in JavaFX on Clojure and have time to put behind a
project that is using the best we know about GUI programming. At the moment
that seems to be core.async and some kind of DOM that can be diffed.

--
Jason Zwolak

On Fri, Mar 18, 2016 at 12:42 PM, Timothy Baldridge <tbaldri...@gmail.com>
wrote:

> I dusted off the fn-fx code today and fixed a bunch of bugs, and
> implemented a few examples: https://github.com/halgari/fn-fx
>
> One of the most complex examples so far is here:
> https://github.com/halgari/fn-fx/blob/master/examples/getting_started/02_form.clj
>
> As you can see the library is capable of some rather decent UIs (grid
> panes, event handlers, etc). This is mostly because the JavaFX API is very
> uniform and therefore easy to generate wrappers/converters using reflection
> and meta-programming.
>
> I will probably continue working on this as time goes on, but to some
> extent I need a good use case to drive development on fn(fx), so if anyone
> has some OSS project or some swing app, they'd like to switch over to
> fn(fx), drop me a line.
>
> Timothy
>
> On Fri, Mar 18, 2016 at 5:30 AM, Mathias De Wachter <
> mathias.dewach...@gmail.com> wrote:
>
>> Hi Timothy,
>> I'm really glad to see some new commits on fn(fx)! I don't know about
>> others, but you'll definitely have at least one very enthusiastic user if I
>> can get to a point where I can use it easily for simple things, and
>> adapt/contribute for more complex things.
>> Do you think the project is in that state already? (Haven't tried yet...)
>> Thanks,
>> Mathias
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/NkLXh8KYXqk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2016-03-19 Thread Jason Zwolak
Paul, yeap, Seesaw is definitely something worth considering. Dave Ray
hasn't abandoned the project, but I sent a personal email to him asking
about the state of the project and it does seem the Seesaw is in more of a
maintenance phase than a continue to move forward and improve phase. Dave
Ray, if you're on this list, would you chime in?

Also, I was at the talk you mentioned and was very impressed with their
methods. What wasn't mentioned in the talk was the fundamental structure of
the interface between Clojure and JavaFX. One point that _really_ struck me
is that they have a reoccurring timer running in the background and each
time it wakes up it checks for changes on the app-state (presumably an
atom, but I do not remember). If the app-state has changed then it starts
re-rendering the UI. If I remember correctly it recreates the UI components
that rely on any part of the app state that has changed. It sounds a little
similar to Facebook React. I questioned them on this approach as it sounded
strange to me... and they convinced me it's a good approach for their
project and inspired me to try something similar on my own... which I'm
secretly working on ;-)

One thing that makes this work so well for their approach is that they have
animations that depend on the app state. So their reoccurring timer is
almost like a video algorithm redrawing the on screen image at the
specified frame rate.

--
Jason Zwolak

On Thu, Mar 17, 2016 at 11:06 AM, Paul L. Snyder <p...@pataprogramming.com>
wrote:

> Yow, old indeed!
>
> In 2011, Dave Ray released Seesaw, which is a very nice wrapper for Swing.
> I've used it for a bunch of projects, and it works great. Of course, it
> does look like Swing, but it's plenty usable. (It's also still being
> maintained, so if you're looking for a toolkit that you can use right now,
> it's a good way to go.)
>
>   https://github.com/daveray/seesaw
>
> That said, I'd also love to see a JavaFX wrapper. At the Conj in Philly,
> Cognitect talked about a project where they'd used it extensively:
>
>   https://www.youtube.com/watch?v=ajX09xQ_UEg
>
> It's definitely piqued my interest.
>
> Paul
>
> On Sat, 12 Mar 2016, Jason Zwolak wrote:
>
> > +1 JavaFX.
> >
> > I know this is an old thread... but in case anyone comes across it (like
> I
> > did just now) and wants to see where things are, they should know that
> > JavaFX has come a long way and seems to be Oracle's replacement for
> Swing.
> > Now JavaFX is no longer only in JavaFXscript... in fact, I believe
> > JavaFXscript is deprecated in favor of the JavaFX Java classes.
> >
> > I've seen some major projects done with Clojure and JavaFX... even from
> the
> > guys at Cognitect.
> >
> > On Thursday, May 27, 2010 at 11:18:41 AM UTC-4, Luke VanderHart wrote:
> > >
> > > My side project is a fairly complex GUI application written in
> > > Clojure. Recently, I've become irritated with using Java interop for
> > > everything. It's not that Clojure doesn't have nice java interop - it
> > > does. It's just that when interacting with a GUI framework, which is a
> > > large part of my app, I have to be back in mutable object-oriented
> > > land, worrying about class hierarchies, mutable state, locks, etc.
> > > Yucky.
> > >
> > > So, with a perhaps dangerous lack of sanity and without any guarantee
> > > of success, I've decided to try my hand at writing an idiomatic
> > > Clojure GUI library. If I have success (which I doubt) I will of
> > > course make it available as open source.
> > >
> > > I intend for it to be mostly declarative, with a nice DSL for defining
> > > GUI elements. Each component will also implement map, and use one of
> > > Clojure's reference types as an interface for inspecting / updating
> > > its state. I may also implement some aspects of Functional Reactive
> > > Programming wherever it's convenient to do so.
> > >
> > > What you all must help me decide is what GUI framework to use as the
> > > underpinnings of it. It's genuinely hard to decide. I have at least
> > > some experience with all of them, so I have no strong preference, but
> > > I'd like to get your input. I did consider trying to make it abstract
> > > enough that you could plug in *any* of them under the hood, but
> > > there's enough differences between the frameworks that that would get
> > > very ugly very fast.
> > >
> > > Possibilities are:
> > >
> > > AWT
> > > Pros: native widgets, bundled with Java, low-level
> > > Cons: few widgets, considered somewhat obselete
> > >
> > > Swing
> 

Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2016-03-19 Thread Jason Zwolak
You can diff JavaFX components like that?

--
Jason Zwolak

On Thu, Mar 17, 2016 at 12:51 PM, Timothy Baldridge <tbaldri...@gmail.com>
wrote:

> >> If the app-state has changed then it starts re-rendering the UI.
>
> That's pretty much exactly what fn-fx does in the latest version, with two
> caveats: 1) there's no timer, just a watch on an atom. 2) If you properly
> diff components you don't need to re-create them every time, just change
> the properties that changed. So if you have a text box 5 components deep in
> your app, and you change the background color, only the background color
> property of that single component will be changed, the rest of the app will
> remain unmodified.
>
> On Thu, Mar 17, 2016 at 10:37 AM, Jason Zwolak <jzwo...@gmail.com> wrote:
>
>> Paul, yeap, Seesaw is definitely something worth considering. Dave Ray
>> hasn't abandoned the project, but I sent a personal email to him asking
>> about the state of the project and it does seem the Seesaw is in more of a
>> maintenance phase than a continue to move forward and improve phase. Dave
>> Ray, if you're on this list, would you chime in?
>>
>> Also, I was at the talk you mentioned and was very impressed with their
>> methods. What wasn't mentioned in the talk was the fundamental structure of
>> the interface between Clojure and JavaFX. One point that _really_ struck me
>> is that they have a reoccurring timer running in the background and each
>> time it wakes up it checks for changes on the app-state (presumably an
>> atom, but I do not remember). If the app-state has changed then it starts
>> re-rendering the UI. If I remember correctly it recreates the UI components
>> that rely on any part of the app state that has changed. It sounds a little
>> similar to Facebook React. I questioned them on this approach as it sounded
>> strange to me... and they convinced me it's a good approach for their
>> project and inspired me to try something similar on my own... which I'm
>> secretly working on ;-)
>>
>> One thing that makes this work so well for their approach is that they
>> have animations that depend on the app state. So their reoccurring timer is
>> almost like a video algorithm redrawing the on screen image at the
>> specified frame rate.
>>
>> --
>> Jason Zwolak
>>
>> On Thu, Mar 17, 2016 at 11:06 AM, Paul L. Snyder <
>> p...@pataprogramming.com> wrote:
>>
>>> Yow, old indeed!
>>>
>>> In 2011, Dave Ray released Seesaw, which is a very nice wrapper for
>>> Swing.
>>> I've used it for a bunch of projects, and it works great. Of course, it
>>> does look like Swing, but it's plenty usable. (It's also still being
>>> maintained, so if you're looking for a toolkit that you can use right
>>> now,
>>> it's a good way to go.)
>>>
>>>   https://github.com/daveray/seesaw
>>>
>>> That said, I'd also love to see a JavaFX wrapper. At the Conj in Philly,
>>> Cognitect talked about a project where they'd used it extensively:
>>>
>>>   https://www.youtube.com/watch?v=ajX09xQ_UEg
>>>
>>> It's definitely piqued my interest.
>>>
>>> Paul
>>>
>>> On Sat, 12 Mar 2016, Jason Zwolak wrote:
>>>
>>> > +1 JavaFX.
>>> >
>>> > I know this is an old thread... but in case anyone comes across it
>>> (like I
>>> > did just now) and wants to see where things are, they should know that
>>> > JavaFX has come a long way and seems to be Oracle's replacement for
>>> Swing.
>>> > Now JavaFX is no longer only in JavaFXscript... in fact, I believe
>>> > JavaFXscript is deprecated in favor of the JavaFX Java classes.
>>> >
>>> > I've seen some major projects done with Clojure and JavaFX... even
>>> from the
>>> > guys at Cognitect.
>>> >
>>> > On Thursday, May 27, 2010 at 11:18:41 AM UTC-4, Luke VanderHart wrote:
>>> > >
>>> > > My side project is a fairly complex GUI application written in
>>> > > Clojure. Recently, I've become irritated with using Java interop for
>>> > > everything. It's not that Clojure doesn't have nice java interop - it
>>> > > does. It's just that when interacting with a GUI framework, which is
>>> a
>>> > > large part of my app, I have to be back in mutable object-oriented
>>> > > land, worrying about class hierarchies, mutable state, locks, etc.
>>> > > Yucky.
>>> > >
>>> > 

Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2016-03-12 Thread Jason Zwolak
+1 JavaFX.

I know this is an old thread... but in case anyone comes across it (like I 
did just now) and wants to see where things are, they should know that 
JavaFX has come a long way and seems to be Oracle's replacement for Swing. 
Now JavaFX is no longer only in JavaFXscript... in fact, I believe 
JavaFXscript is deprecated in favor of the JavaFX Java classes.

I've seen some major projects done with Clojure and JavaFX... even from the 
guys at Cognitect.

On Thursday, May 27, 2010 at 11:18:41 AM UTC-4, Luke VanderHart wrote:
>
> My side project is a fairly complex GUI application written in
> Clojure. Recently, I've become irritated with using Java interop for
> everything. It's not that Clojure doesn't have nice java interop - it
> does. It's just that when interacting with a GUI framework, which is a
> large part of my app, I have to be back in mutable object-oriented
> land, worrying about class hierarchies, mutable state, locks, etc.
> Yucky.
>
> So, with a perhaps dangerous lack of sanity and without any guarantee
> of success, I've decided to try my hand at writing an idiomatic
> Clojure GUI library. If I have success (which I doubt) I will of
> course make it available as open source.
>
> I intend for it to be mostly declarative, with a nice DSL for defining
> GUI elements. Each component will also implement map, and use one of
> Clojure's reference types as an interface for inspecting / updating
> its state. I may also implement some aspects of Functional Reactive
> Programming wherever it's convenient to do so.
>
> What you all must help me decide is what GUI framework to use as the
> underpinnings of it. It's genuinely hard to decide. I have at least
> some experience with all of them, so I have no strong preference, but
> I'd like to get your input. I did consider trying to make it abstract
> enough that you could plug in *any* of them under the hood, but
> there's enough differences between the frameworks that that would get
> very ugly very fast.
>
> Possibilities are:
>
> AWT
> Pros: native widgets, bundled with Java, low-level
> Cons: few widgets, considered somewhat obselete
>
> Swing
> Pros: bundled with Java, good widget selection
> Cons: non-native widgets
>
> SWT
> Pros: native widgets, widely used
> Cons: requires platform-specific libs
>
> QT Jambi
> Pros: native widgets, huge widget selection, highly-regarded framework
> Cons: requires platform-specific libs, writing custom widgets is
> hairy, momentum and support seem to be lagging since Nokia dropped
> official support.
>
> Remember, the actual API won't matter - that will be completely
> abstracted away. So try to focus on the framework's look and feel.
> Also let me know if I've missed any of the framework's key
> characteristics.
>
> Thanks!
>
> -Luke
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: java web start and clojure application

2016-02-15 Thread Jason Zwolak
I'd also like to point out for the record, since I ran into this problem, 
that the policy related static code must appear before any requires in the 
Java code that loads the application specific functions; like the 
"clojure-main" in the OPs example.

I believe a more modern load of the application Clojure code would look 
like this (before the setPolicy):

public static final IFn require = Clojure.var("clojure.core", 
"require");
static {
require.invoke(Clojure.read("clojure-main"));
}

After setPolicy code, it would look like this:

public static final IFn require = Clojure.var("clojure.core", 
"require");
static {
Policy.setPolicy( new Policy() { 
public PermissionCollection 
getPermissions(CodeSource codesource) { 
Permissions perms = new Permissions(); 
perms.add(new AllPermission()); 
return(perms); 
} 
public void refresh(){ 
} 
}); 
require.invoke(Clojure.read("clojure-main"));
}


On Tuesday, April 22, 2008 at 9:44:27 AM UTC-4, Pawel Ostrowski wrote:
>
> Hello, 
>
> I managed to successfully deploy simple clojure application with java 
> web start. I will share my experience here, because I had some 
> problems with granting enough security privileges to run clojure 
> application as java web start applet (getting AccessControlException) 
> and I did not find complete solution in group's archive. Editing 
> java.policy file was not an option because I wanted to share my 
> application with users who might not understand java policies at all. 
>
> My application is written entirely in clojure except one java class 
> with static main method. This main method looks like this: 
>
>  public static void main(String[] args) throws Exception { 
> RT.init(); 
> // load clj resource 
> loadFromClasspath("alphabet/alphabet.clj"); 
> // get clojure fun 
> StringReader sr = new StringReader("clojure-main"); 
> PushbackReader r = new PushbackReader(sr); 
> IFn clojureFun = (IFn) Compiler.eval(LispReader.read(r, false, 
> null, false)); 
> // call clojure fun 
> clojureFun.invoke(); 
> ... 
>
> So all I do here is: load clojure source file, get clojure main 
> function and then call it. 
>
> To run it as java web start applet I had to: 
>
> 1) Include   element in 
> my .jnlp file. 
> 2) Sign clojure.jar and my application .jar files. Instructions found 
> on http://www.dallaway.com/acad/webstart/ were helpful 
> 3) Put the following code in static section in class with the static 
> main method: 
>
> static { 
> Policy.setPolicy( new Policy() { 
> public PermissionCollection 
> getPermissions(CodeSource codesource) { 
> Permissions perms = new Permissions(); 
> perms.add(new AllPermission()); 
> return(perms); 
> } 
> public void refresh(){ 
> } 
> }); 
> } 
>
> Third step was necessary because all permissions from first step were 
> granted to javaws classloader only and clojure creates it's own 
> classloaders, at least I think so :). 
>
> ps. This is a simple alphabet typing swing application, it measures 
> your time to type whole alphabet. Time starts with typing letter a and 
> ends with letter z. Space resets the game. It may be run with javaws 
> from here: http://www.pasza.org/files/alphabet/alphabet.jnlp 
>
> clojure code may be found in this jar: 
> http://www.pasza.org/files/alphabet/alphabet.jar 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: java web start and clojure application

2015-10-03 Thread Jason Zwolak
Fantastic!  Thanks for reporting this.  Your work helped me get my 
application working with Clojure code in a webstart environment.

I do have a question about security in relation to step 3 where the Policy 
is set.  Is this the strictest policy that will work with Clojure code 
compiled at runtime?  Does this policy leave an application open to 
security problems?  My interpretation of step 3 is that all class loaders 
now have all-privileges.  This could be a problem if some third party jar, 
which my have been compromised or contain malicious code, creates its own 
class loader and loads arbitrary code from a server.  All this code would 
then have all permissions where it wouldn't have them without step 3.  Is 
my assessment correct?

Thanks,
Jason

On Tuesday, April 22, 2008 at 9:44:27 AM UTC-4, Pawel Ostrowski wrote:
>
> Hello, 
>
> I managed to successfully deploy simple clojure application with java 
> web start. I will share my experience here, because I had some 
> problems with granting enough security privileges to run clojure 
> application as java web start applet (getting AccessControlException) 
> and I did not find complete solution in group's archive. Editing 
> java.policy file was not an option because I wanted to share my 
> application with users who might not understand java policies at all. 
>
> My application is written entirely in clojure except one java class 
> with static main method. This main method looks like this: 
>
>  public static void main(String[] args) throws Exception { 
> RT.init(); 
> // load clj resource 
> loadFromClasspath("alphabet/alphabet.clj"); 
> // get clojure fun 
> StringReader sr = new StringReader("clojure-main"); 
> PushbackReader r = new PushbackReader(sr); 
> IFn clojureFun = (IFn) Compiler.eval(LispReader.read(r, false, 
> null, false)); 
> // call clojure fun 
> clojureFun.invoke(); 
> ... 
>
> So all I do here is: load clojure source file, get clojure main 
> function and then call it. 
>
> To run it as java web start applet I had to: 
>
> 1) Include   element in 
> my .jnlp file. 
> 2) Sign clojure.jar and my application .jar files. Instructions found 
> on http://www.dallaway.com/acad/webstart/ were helpful 
> 3) Put the following code in static section in class with the static 
> main method: 
>
> static { 
> Policy.setPolicy( new Policy() { 
> public PermissionCollection 
> getPermissions(CodeSource codesource) { 
> Permissions perms = new Permissions(); 
> perms.add(new AllPermission()); 
> return(perms); 
> } 
> public void refresh(){ 
> } 
> }); 
> } 
>
> Third step was necessary because all permissions from first step were 
> granted to javaws classloader only and clojure creates it's own 
> classloaders, at least I think so :). 
>
> ps. This is a simple alphabet typing swing application, it measures 
> your time to type whole alphabet. Time starts with typing letter a and 
> ends with letter z. Space resets the game. It may be run with javaws 
> from here: http://www.pasza.org/files/alphabet/alphabet.jnlp 
>
> clojure code may be found in this jar: 
> http://www.pasza.org/files/alphabet/alphabet.jar 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.