Re: SpringBean doesn't support Generics?

2015-01-05 Thread Martin Grigorov
Hi,

Please create a ticket with a quickstart.
With a patch would be awesome!
Thanks!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Jan 6, 2015 at 3:04 AM, RedCarpet bluecar...@gmx.com wrote:

 Spring 4 is able to wire/inject generic beans, as described here:
 http://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics .
 However, I'm experiencing problems when using generic beans with Wicket's
 SpringBean.

 I basically have following situation, two concrete dao's that implement a
 generic typed interface dao.:
 class Product{}
 class Car extends Product{}
 class Phone extends Product{}
 interface ProductDaoT extends Product {}
 class CarProductDao implements ProductDaoCar {}
 class PhoneProductDao implements ProductDaoPhone {}

 class ProductModelT extends Product extends LoadableDetachableModelT {
  @SpringBean ProductDaoT productDao;
 }
 class ProductPage extends WebPage {
  ...
  ProductModelCarProduct model = new ProductModelCarProduct(product);
  ...
 }

 This will result in the following error:
 2015-jan-06;01:53:23.471 http-nio-8080-exec-6 WARN  RequestCycleExtra -
 Handling the following exception
 java.lang.IllegalStateException: More than one bean of type [ProductDao]
 found, you have to specify the name of the bean (@SpringBean(name=foo))
 or
 (@Named(foo) if using @javax.inject classes) in order to resolve this
 conflict. Matched beans: carProductDao,phoneProductDao
 at

 org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanNameOfClass(AnnotProxyFieldValueFactory.java:289)
 ~[AnnotProxyFieldValueFactory.class:6.18.0]
 at

 org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanName(AnnotProxyFieldValueFactory.java:198)
 ~[AnnotProxyFieldValueFactory.class:6.18.0]
 at

 org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:130)
 ~[AnnotProxyFieldValueFactory.class:6.18.0]
 at org.apache.wicket.injection.Injector.inject(Injector.java:111)
 ~[Injector.class:6.18.0]
 at

 org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
 ~[SpringComponentInjector.class:6.18.0]
 at ProductModel.init(ProductModel.java:20)
 ~[ProductModel.class:na]
 at ProductPage$15.populateItem(ProductPage.java:742)
 ~[ProductPage$15.class:na]



 Does Wicket's SpringBean support Spring-4's generics support?



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/SpringBean-doesn-t-support-Generics-tp4668928.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: What is the proper way to start a secondary process in Wicket 6

2015-01-05 Thread Ernesto Reinaldo Barreiro
Dear All,

With the invaluable help of Martin Grigorov, I have summarized the
discussion on this thread on a small Wicket in Action article [1]. The
complete sample project can be found at [2].

1- http://wicketinaction.com/2014/07/working-with-background-jobs/
2-https://github.com/reiern70/antilia-bits/tree/master/bgprocess


On Tue, Nov 25, 2014 at 6:30 AM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:

 @Martin,

 Many thanks! I will try to have a look today at the PR and see if I find
 the time to write the blogs article during this week.

 Thanks again!

 On Mon, Nov 24, 2014 at 5:46 PM, Martin Grigorov mgrigo...@apache.org
 wrote:

 Hi Ernesto,

 See https://github.com/reiern70/antilia-bits/pull/1
 I've moved the code that exports the Application thread local to
 TasksRunnable. This way it is possible to export the Session too.

 The code looks good (after removing all annoying whitespaces :-) ). Now it
 needs some explanation (i.e. blog article) ;-)

 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov

 On Sun, Nov 23, 2014 at 8:13 AM, Ernesto Reinaldo Barreiro 
 reier...@gmail.com wrote:

  Warren,
 
  ThreadContext.detach(); seems to be more proper than...
  ThreadContext.setApplication(null); I will update demo.
 
  On Sat, Nov 22, 2014 at 10:58 PM, Warren Bell warrenbe...@gmail.com
  wrote:
 
   Ernesto,
  
   That’s kind of what I ended up doing except with a different
   ThreadPoolExecutor implementation.
  
   ExecutorService executorService = new ScheduledThreadPoolExecutor(20)
   {
   @Override
   protected void beforeExecute(Thread t, Runnable r) {
   ThreadContext.setApplication(MyApplication.this);
   }
  
   @Override
   protected void afterExecute(Runnable r, Throwable t) {
   ThreadContext.detach();
   }
   };
  
   No particular reason why I picked ScheduledThreadPoolExecutor other
 than
   it looked a little easier to use. I need to look more into the
 different
   types of Thread pools and such.
  
   I used:
  
   ThreadContext.detach();
  
   instead of:
  
   ThreadContext.setApplication(null);
  
   Warren Bell
  
  
   On Nov 22, 2014, at 11:18 AM, Ernesto Reinaldo Barreiro 
   reier...@gmail.com wrote:
  
pushed a new version including injecting a Guice managed service
 class
   
On Sat, Nov 22, 2014 at 8:08 PM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:
   
Warren,
   
Something like:
   
ExecutorService executorService =  new ThreadPoolExecutor(10, 10,
   0L, TimeUnit.MILLISECONDS,
   new LinkedBlockingQueueRunnable()) {
  @Override
  protected void beforeExecute(final Thread t, final
 Runnable
   r) {
  ThreadContext.setApplication(BgProcessApplication.this);
  };
  @Override
  protected void afterExecute(final Runnable r, final
  Throwable
t) {
  ThreadContext.setApplication(null);
  }
};
   
seems to work.
   
On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell 
   warr...@clarksnutrition.com
wrote:
   
I have seen this from a 2010 post:
   
final Application app = Application.get();
 final ExecutorService service = new
ScheduledThreadPoolExecutor(1) {
   @Override
   protected void beforeExecute(final Thread t, final
  Runnable
r) {
 Application.set(app);
   };
   @Override
   protected void afterExecute(final Runnable r, final
   Throwable
t) {
 Application.unset();
   }
 };
   
But there is no more Application#set(app) and Application#unset()
 in
Wicket 6. Does Wicket 6 have some built in way of creating
 secondary
processes, maybe an internal thread pool that can be set-up ?
   
Warren Bell
   
On Nov 20, 2014, at 10:03 AM, Warren Bell 
  warr...@clarksnutrition.com
mailto:warr...@clarksnutrition.com wrote:
   
Ernesto, great job putting all that code together so quickly. I
  cloned
your project and cherry picked out the code that I needed, I don’t
   need all
the process progress code you have. I don’t really care what the
   process
progress is or even if it completes ok, just don’t want it
 holding up
   my
response.
   
I ended up using your ExecutionBridge, TasksRunnable, and ITask
  classes
and interfaces. But I still don’t know where and how to inject my
   service
into this new task/thread or ExecutionBridge without getting this
   exception:
   
Exception in thread pool-1-thread-1
org.apache.wicket.WicketRuntimeException: There is no application
   attached
to current thread pool-1-thread-1
   
Do I need to get the application attached to my new threads
 somehow
  so
   I
can use my injected service, and if so, how do I do that ?
   
   

Re: What is the proper way to start a secondary process in Wicket 6

2015-01-05 Thread Francois Meillet
Thanks Ernesto !

François Meillet




Le 5 janv. 2015 à 10:38, Ernesto Reinaldo Barreiro reier...@gmail.com a écrit 
:

 Martin



Re: Wicket 7.0.4M - bug related to queueing and wicket:enclosure

2015-01-05 Thread mscoon
Hi Martin,

I just tried it with 7.0.0-SNAPSHOT and I get the same exception. I have
opened https://issues.apache.org/jira/browse/WICKET-5800 with details and a
quickstart.

Thanks
Marios

On Wed, Dec 24, 2014 at 12:33 PM, Martin Grigorov mgrigo...@apache.org
wrote:

 Hi,

 I believe this is fixed in 7.0.0-SNAPSHOT.
 Please try it if you can.
 Thanks!
 On Dec 24, 2014 9:47 AM, mscoon msc...@gmail.com wrote:

  Hi,
 
  I have a component extending a FormComponentPanel which includes
  wicket:enclosures. It is embedded in tab in an ajax tabbed panel.
 
  I am getting the following exception when trying to change the active
 tab.
  It was working fine with wicket 6.15.0.
 
  I saw there are some issues in jira related to autocomponents and
 dequeing
  (WICKET-5730). Any ideas if this is related?
 
  org.apache.wicket.WicketRuntimeException: Detach called on component with
  id 'hireFek' while it had a non-empty queue: ComponentQueue{queueSize=2,
  queue=[[Enclosure [Component id = wicket_enclosure11]], [Enclosure
  [Component id = wicket_enclosure12]], null, null, null, null, null,
 null]}
  at org.apache.wicket.MarkupContainer.onDetach(MarkupContainer.java:1936)
  at
 
 
 org.apache.wicket.markup.html.form.LabeledWebMarkupContainer.onDetach(LabeledWebMarkupContainer.java:46)
  at
 
 
 org.apache.wicket.markup.html.form.FormComponent.onDetach(FormComponent.java:1409)
  at org.apache.wicket.Component.detach(Component.java:1160)
  at
 
 org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653)
  at org.apache.wicket.Component.detach(Component.java:1179)
  at
 
 org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653)
  at org.apache.wicket.Component.detach(Component.java:1179)
  at
 
 org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653)
  at org.apache.wicket.Component.detach(Component.java:1179)
  at
 
 
 org.apache.wicket.MarkupContainer.removedComponent(MarkupContainer.java:1356)
  at org.apache.wicket.MarkupContainer.replace(MarkupContainer.java:742)
  at
 org.apache.wicket.MarkupContainer.addOrReplace(MarkupContainer.java:214)
  at
 
 
 org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.setCurrentTab(TabbedPanel.java:439)
  at
 
 
 org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.setSelectedTab(TabbedPanel.java:397)
  at
 
 
 gr.sol.wicket.markup.html.form.tabs.FormContainerAjaxTabbedPanel$TabLink.onSubmit(FormContainerAjaxTabbedPanel.java:67)
 
  Thanks,
  Marios
 



Re: What is the proper way to start a secondary process in Wicket 6

2015-01-05 Thread Ernesto Reinaldo Barreiro
De rien!

2015-01-05 9:54 GMT+00:00 Francois Meillet francois.meil...@gmail.com:

 Thanks Ernesto !

 François Meillet




 Le 5 janv. 2015 à 10:38, Ernesto Reinaldo Barreiro reier...@gmail.com a
 écrit :

  Martin




-- 
Regards - Ernesto Reinaldo Barreiro


Re: DebugBar reports strange sizes

2015-01-05 Thread ChambreNoire
I'm having trouble fully understanding Wicket's serialization. 

I understand that if I declare a final object outside of an anonymous inner
class and then use it from within that anonymous inner class, the compiler
will ass a member variable to the anonymous inner class which gets
serialized.

final Object outer = /a 10K entity/;

add(new Label(label, new LoadableDetachableModel() {

@Override
protected Object load() {
return outer;
}
}));

However if the containing component / page has a large Model 

setDefaultModel(Model.of(/a 50K entity/));

DebugBar Inspector reports that the Label takes up 66.5K (including the 6.1K
debugbar).

Does this mean that all anonymous inner classes, declared within a component
with such a model, will serialize a copy of the container? This seems to be
what the sizes reported by the DebugBar suggests...

(I'm aware of the correct usage of LDMs etc. I'd just like to understand the
consequences of the various anti-patterns)

Thanks,

CN



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/DebugBar-reports-strange-sizes-tp4668920p4668926.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 7.0.4M - bug related to queueing and wicket:enclosure

2015-01-05 Thread andrea del bene

Hi,

now the snapshot should work.

Andrea.

On 05/01/2015 11:32, mscoon wrote:

Hi Martin,

I just tried it with 7.0.0-SNAPSHOT and I get the same exception. I have
opened https://issues.apache.org/jira/browse/WICKET-5800 with details and a
quickstart.

Thanks
Marios

On Wed, Dec 24, 2014 at 12:33 PM, Martin Grigorov mgrigo...@apache.org
wrote:





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



SpringBean doesn't support Generics?

2015-01-05 Thread RedCarpet
Spring 4 is able to wire/inject generic beans, as described here:
http://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics .
However, I'm experiencing problems when using generic beans with Wicket's
SpringBean.

I basically have following situation, two concrete dao's that implement a
generic typed interface dao.:
class Product{}
class Car extends Product{}
class Phone extends Product{}
interface ProductDaoT extends Product {}
class CarProductDao implements ProductDaoCar {}
class PhoneProductDao implements ProductDaoPhone {}

class ProductModelT extends Product extends LoadableDetachableModelT {
 @SpringBean ProductDaoT productDao;
}
class ProductPage extends WebPage {
 ...
 ProductModelCarProduct model = new ProductModelCarProduct(product);
 ...
}

This will result in the following error:
2015-jan-06;01:53:23.471 http-nio-8080-exec-6 WARN  RequestCycleExtra -
Handling the following exception
java.lang.IllegalStateException: More than one bean of type [ProductDao]
found, you have to specify the name of the bean (@SpringBean(name=foo)) or
(@Named(foo) if using @javax.inject classes) in order to resolve this
conflict. Matched beans: carProductDao,phoneProductDao
at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanNameOfClass(AnnotProxyFieldValueFactory.java:289)
~[AnnotProxyFieldValueFactory.class:6.18.0]
at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanName(AnnotProxyFieldValueFactory.java:198)
~[AnnotProxyFieldValueFactory.class:6.18.0]
at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:130)
~[AnnotProxyFieldValueFactory.class:6.18.0]
at org.apache.wicket.injection.Injector.inject(Injector.java:111)
~[Injector.class:6.18.0]
at
org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
~[SpringComponentInjector.class:6.18.0]
at ProductModel.init(ProductModel.java:20) ~[ProductModel.class:na]
at ProductPage$15.populateItem(ProductPage.java:742)
~[ProductPage$15.class:na]



Does Wicket's SpringBean support Spring-4's generics support?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/SpringBean-doesn-t-support-Generics-tp4668928.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: DebugBar reports strange sizes

2015-01-05 Thread Martin Grigorov
Hi,


On Mon, Jan 5, 2015 at 3:10 PM, ChambreNoire a...@tentelemed.com wrote:

 I'm having trouble fully understanding Wicket's serialization.


It is not Wicket serialization. It is Java serialization.



 I understand that if I declare a final object outside of an anonymous inner
 class and then use it from within that anonymous inner class, the compiler
 will ass a member variable to the anonymous inner class which gets
 serialized.


Actually the inner class has a reference to the complete outer/normal class.



 final Object outer = /a 10K entity/;

 add(new Label(label, new LoadableDetachableModel() {

 @Override
 protected Object load() {
 return outer;
 }
 }));

 However if the containing component / page has a large Model

 setDefaultModel(Model.of(/a 50K entity/));

 DebugBar Inspector reports that the Label takes up 66.5K (including the
 6.1K
 debugbar).

 Does this mean that all anonymous inner classes, declared within a
 component
 with such a model, will serialize a copy of the container? This seems to be


Yes and No.
Java serialization will serialize the referred container *once*. All inner
classes will serialize just a pointer to the container.


 what the sizes reported by the DebugBar suggests...

 (I'm aware of the correct usage of LDMs etc. I'd just like to understand
 the
 consequences of the various anti-patterns)


Calculating the size of an object in Java is very tricky. It is a best
effort, not exact.



 Thanks,

 CN



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/DebugBar-reports-strange-sizes-tp4668920p4668926.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org