More Granularity
←Older revision | Revision as of 12:31, 26 March 2019 | ||
Line 31: | Line 31: | ||
{{:HeavyWeight}} | {{:HeavyWeight}} | ||
+ | |||
+ | Very [[rational]] solution - however it requires thinking. | ||
==== Injecting UI & co. ==== | ==== Injecting UI & co. ==== |
More Granularity
←Older revision | Revision as of 12:31, 26 March 2019 | ||
Line 31: | Line 31: | ||
{{:HeavyWeight}} | {{:HeavyWeight}} | ||
+ | |||
+ | Very [[rational]] solution - however it requires thinking. | ||
==== Injecting UI & co. ==== | ==== Injecting UI & co. ==== |
More Granularity
←Older revision | Revision as of 12:29, 26 March 2019 | ||
Line 28: | Line 28: | ||
==== More Granularity ==== | ==== More Granularity ==== | ||
- | On the other hand, there is a [[rationalistic]] solution. Your system is [[modular]], isn't it? Just some of your modules may be too | + | On the other hand, there is a [[rationalistic]] solution. Your system is [[modular]], isn't it? Just some of your modules may be too [[HeavyWeight]]. |
- | + | {{:HeavyWeight}} | |
==== Injecting UI & co. ==== | ==== Injecting UI & co. ==== |
Different Implementation
←Older revision | Revision as of 11:37, 23 March 2014 | ||
Line 132: | Line 132: | ||
Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]] (see [http://bits.netbeans.org/html4j/0.7.6/net/java/html/json/doc-files/websockets.html the javadoc]). | Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]] (see [http://bits.netbeans.org/html4j/0.7.6/net/java/html/json/doc-files/websockets.html the javadoc]). | ||
Then it was easy to provide one implementation using classical ''Tyrus'' library and one, really slim using in browser ''WebSocket'' object and make sure the best suitable is always plugged in. | Then it was easy to provide one implementation using classical ''Tyrus'' library and one, really slim using in browser ''WebSocket'' object and make sure the best suitable is always plugged in. | ||
+ | |||
+ | == Summary == | ||
+ | |||
+ | [[JDK]]8 [[profiles]] are here with us and our [[libraries]], [[framework]]s and application need to acknowledge that. Luckily there are simple patterns (demonstrated on this page) that help us adopt to smaller [[JDK]] [[profiles]] and make our code more re-usable. |
And When in that - Let's Also!
←Older revision | Revision as of 11:34, 23 March 2014 | ||
Line 132: | Line 132: | ||
Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]] (see [http://bits.netbeans.org/html4j/0.7.6/net/java/html/json/doc-files/websockets.html the javadoc]). | Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]] (see [http://bits.netbeans.org/html4j/0.7.6/net/java/html/json/doc-files/websockets.html the javadoc]). | ||
Then it was easy to provide one implementation using classical ''Tyrus'' library and one, really slim using in browser ''WebSocket'' object and make sure the best suitable is always plugged in. | Then it was easy to provide one implementation using classical ''Tyrus'' library and one, really slim using in browser ''WebSocket'' object and make sure the best suitable is always plugged in. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- |
Different Implementation
←Older revision | Revision as of 11:34, 23 March 2014 | ||
Line 130: | Line 130: | ||
What if our restricted profile requires different implementation than the original one? Then one has to make the implementation pluggable (for example by creating an [[Injectable Singleton]]) and implement it twice. Sometimes it is possible to keep the original [[API]] and have just two different implementations. Sometimes the original [[API]] richness cannot be achieved in the restricted [[environment]] - in such case one may consider to abstract the shared functionality into new module with [[API]] and rewrite modules ready for using the restricted version to use it instead. | What if our restricted profile requires different implementation than the original one? Then one has to make the implementation pluggable (for example by creating an [[Injectable Singleton]]) and implement it twice. Sometimes it is possible to keep the original [[API]] and have just two different implementations. Sometimes the original [[API]] richness cannot be achieved in the restricted [[environment]] - in such case one may consider to abstract the shared functionality into new module with [[API]] and rewrite modules ready for using the restricted version to use it instead. | ||
- | Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]] | + | Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]] (see [http://bits.netbeans.org/html4j/0.7.6/net/java/html/json/doc-files/websockets.html the javadoc]). |
- | Then it was easy to provide one implementation using classical ''Tyrus'' library and one, really slim using in browser ''WebSocket'' object. | + | Then it was easy to provide one implementation using classical ''Tyrus'' library and one, really slim using in browser ''WebSocket'' object and make sure the best suitable is always plugged in. |
== And When in that - Let's Also! == | == And When in that - Let's Also! == |
Different Implementation
←Older revision | Revision as of 11:32, 23 March 2014 | ||
Line 128: | Line 128: | ||
==== Different Implementation ==== | ==== Different Implementation ==== | ||
- | What if our restricted profile requires different implementation than the original one? Then one has to make the implementation pluggable (for example by creating an [[Injectable Singleton]]) and implement it twice. Sometimes it is possible to keep the original [[API]] and have just two different implementations. Sometimes the original [[API] richness cannot be achieved in the restricted [[environment]] - in such case one may consider to abstract the shared functionality into new module with [[API]] and rewrite modules ready for using the restricted version to use it instead. | + | What if our restricted profile requires different implementation than the original one? Then one has to make the implementation pluggable (for example by creating an [[Injectable Singleton]]) and implement it twice. Sometimes it is possible to keep the original [[API]] and have just two different implementations. Sometimes the original [[API]] richness cannot be achieved in the restricted [[environment]] - in such case one may consider to abstract the shared functionality into new module with [[API]] and rewrite modules ready for using the restricted version to use it instead. |
Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]]. See http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/doc-files/websockets.html | Recently I had a lot of fun with restricted [[environment]] called [[Bck2Brwsr]] and for example to encapsulate [[WebSocket]] communication I rather invented new [[API]] than tried to use one already existing in [[Java]]. See http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/doc-files/websockets.html |
Fake Emulation Classes
←Older revision | Revision as of 11:31, 23 March 2014 | ||
Line 124: | Line 124: | ||
</source> | </source> | ||
- | which is exactly the workaround [[I]] used to get [[Grizzly]] working on [[JDK]]8 compact 2 profile, before it got fixed. One can use this trick whenever it comes to ''javax'' packages - those can be loaded by any classloader. The trick does not work for ''java'' packages, as those are sealed and can only be loaded by system classloader. | + | which is exactly the workaround [[I]] used to get [[Grizzly]] working on [[JDK]]8 compact 2 profile, before it got fixed. One can use this trick whenever it comes to ''javax'' packages - those can be loaded by any classloader. The trick does not work for ''java'' packages, as those are sealed and can only be loaded by the system classloader. |
==== Different Implementation ==== | ==== Different Implementation ==== |
Fake Emulation Classes
←Older revision | Revision as of 11:30, 23 March 2014 | ||
Line 113: | Line 113: | ||
==== Fake Emulation Classes ==== | ==== Fake Emulation Classes ==== | ||
- | Sometimes (especially when it comes to [[API]]) it is harder to eliminate classes from richer [[profiles]] easily. In such case | + | Sometimes (especially when it comes to [[API]]) it is harder to eliminate classes from richer [[profiles]] easily. In such case one can try the ''brutal force, think no more'' solution: Emulate such classes. This is particularly easy in case of simple interfaces or classes that can throw exceptions. For example get your [[API]] compact 1 profile ready and still reference {{JDK|javax/swing|Action}}, just copy the class and everything will work. Or to eliminate need of [[JNDI]] without changing a line on the call site, one can create a fake: |
<source lang="java"> | <source lang="java"> |
Fake Emulation Classes
←Older revision | Revision as of 11:30, 23 March 2014 | ||
Line 113: | Line 113: | ||
==== Fake Emulation Classes ==== | ==== Fake Emulation Classes ==== | ||
- | Sometimes (especially when it comes to [[API]]) it is harder to eliminate classes from richer [[profiles]] easily. In such case, there may be brutal force, think no more solution: Emulate such classes. This is particularly easy in case of simple interfaces or classes that can throw exceptions. For example get your [[API]] compact 1 profile ready and still reference {{JDK|javax/swing | + | Sometimes (especially when it comes to [[API]]) it is harder to eliminate classes from richer [[profiles]] easily. In such case, there may be brutal force, think no more solution: Emulate such classes. This is particularly easy in case of simple interfaces or classes that can throw exceptions. For example get your [[API]] compact 1 profile ready and still reference {{JDK|javax/swing|Action}}, just copy the class and everything will work. Or to eliminate need of [[JNDI]] without changing a line on the call site, one can create a fake: |
<source lang="java"> | <source lang="java"> |
No Need to Hack
←Older revision | Revision as of 11:28, 23 March 2014 | ||
Line 89: | Line 89: | ||
<source lang="java"> | <source lang="java"> | ||
- | EventQueue.invokeLater( -> runAction(); ); | + | EventQueue.invokeLater(() -> runAction(); ); |
</source> | </source> | ||