Re: T5 IOC Questions

2009-07-13 Thread Norman Franke
Not sure what I was doing wrong, but this works when added to my  
AppModule:


public static void bind(ServiceBinder binder) {
		binder.bind(ActionRenderResponseGenerator.class,  
MyActionRenderResponseGenerator 
.class).withId(MyActionRenderResponseGenerator);

}

public static void contributeServiceOverride(
			@InjectService(MyActionRenderResponseGenerator)  
ActionRenderResponseGenerator myService,

MappedConfigurationClass?,Object configuration) {
configuration.add(ActionRenderResponseGenerator.class, 
myService);
}

Thanks to some discussions archived from the list:
http://osdir.com/ml/users-tapestry-apache/2009-03/msg00614.html

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Jul 10, 2009, at 8:05 PM, Norman Franke wrote:


On Jul 10, 2009, at 7:08 PM, Norman Franke wrote:


On Jul 10, 2009, at 6:55 PM, Howard Lewis Ship wrote:

On Fri, Jul 10, 2009 at 3:27 PM, Norman Frankenor...@myasd.com  
wrote:
First, I have a ton of DAOs that I need to bind the interface to  
the
implementation. I'd like to do this automatically, so I don't  
have to keep
modifying my AppModule for each DAO I create. What's the best way  
to go
about this? I figure if I can somehow get a ClassNameLocator  
instance, I
could just iterate through my package and do it that way.  
However, how do I

get a ClassNameLocator in bind(ServiceBinder)?


Look at the ServiceBinder interface; there are methods there
(especially in 5.1) that may address your needs.


I did, but how do I get a ClassNameLocator in the bind() method so  
I can then pass my classes to the ServiceBinder? bind() can only  
take a single argument, and I can't inject something into the  
class, since this is static.




Second, on the SUPPRESS_REDIRECT_FROM_ACTION_REQUESTS issue, is  
it possible
to inject my own ActionRenderResponseGenerator that does my  
bidding?


Not following you here ... but in 5.1 it is possible to override
contributions as well as services.


I see that the InternalModule has a  
buildActionRenderResponseGenerator() and I'd like replace that with  
my own implementation. I'm just not sure how. I've tried a number  
of things, including adding my own  
buildActionRenderResponseGenerator, which fails due to duplication.  
I tried an alias, but can't get that working either. What's the  
magic mojo to replace the ActionRenderResponseGenerator service  
with something else in my AppModule?


I've tried:
contributeAlias
contributeAliasOverride
contributeServiceOverride

None seem to actually override the ActionRenderResponseGenerator.  
Very strange.


-Norman



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





Re: T5 IOC Questions

2009-07-13 Thread Norman Franke

On Jul 10, 2009, at 6:55 PM, Howard Lewis Ship wrote:

On Fri, Jul 10, 2009 at 3:27 PM, Norman Frankenor...@myasd.com  
wrote:

First, I have a ton of DAOs that I need to bind the interface to the
implementation. I'd like to do this automatically, so I don't have  
to keep
modifying my AppModule for each DAO I create. What's the best way  
to go
about this? I figure if I can somehow get a ClassNameLocator  
instance, I
could just iterate through my package and do it that way. However,  
how do I

get a ClassNameLocator in bind(ServiceBinder)?


Look at the ServiceBinder interface; there are methods there
(especially in 5.1) that may address your needs.



ServiceBinder just has three bind() methods and nothing else  
interesting. This one seemed promising:


T ServiceBindingOptions bind(ClassT serviceInterface,  
ServiceBuilderT builder);


However, I can't add stuff to the ServiceBinder from the  
ServiceBuilder. And even with .eagerLoad(),  buildServices() method  
isn't called until after AppModule.bind() has finished. I  can't see  
how I can both add bindings while obtaining a ClassNameLocator.


Any other tips?

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com





Re: T5 IOC Questions

2009-07-13 Thread Norman Franke
Alas, I just gave up. I wrote my own getClassesFromPackage() instead  
of using ClassNameLocator and went with that. Seems to work.


Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Jul 13, 2009, at 3:42 PM, Norman Franke wrote:


On Jul 10, 2009, at 6:55 PM, Howard Lewis Ship wrote:

On Fri, Jul 10, 2009 at 3:27 PM, Norman Frankenor...@myasd.com  
wrote:

First, I have a ton of DAOs that I need to bind the interface to the
implementation. I'd like to do this automatically, so I don't have  
to keep
modifying my AppModule for each DAO I create. What's the best way  
to go
about this? I figure if I can somehow get a ClassNameLocator  
instance, I
could just iterate through my package and do it that way. However,  
how do I

get a ClassNameLocator in bind(ServiceBinder)?


Look at the ServiceBinder interface; there are methods there
(especially in 5.1) that may address your needs.



ServiceBinder just has three bind() methods and nothing else  
interesting. This one seemed promising:


   T ServiceBindingOptions bind(ClassT serviceInterface,  
ServiceBuilderT builder);


However, I can't add stuff to the ServiceBinder from the  
ServiceBuilder. And even with .eagerLoad(),  buildServices() method  
isn't called until after AppModule.bind() has finished. I  can't see  
how I can both add bindings while obtaining a ClassNameLocator.


Any other tips?

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com







Re: T5 IOC Questions

2009-07-10 Thread Howard Lewis Ship
On Fri, Jul 10, 2009 at 3:27 PM, Norman Frankenor...@myasd.com wrote:
 First, I have a ton of DAOs that I need to bind the interface to the
 implementation. I'd like to do this automatically, so I don't have to keep
 modifying my AppModule for each DAO I create. What's the best way to go
 about this? I figure if I can somehow get a ClassNameLocator instance, I
 could just iterate through my package and do it that way. However, how do I
 get a ClassNameLocator in bind(ServiceBinder)?

Look at the ServiceBinder interface; there are methods there
(especially in 5.1) that may address your needs.


 Second, on the SUPPRESS_REDIRECT_FROM_ACTION_REQUESTS issue, is it possible
 to inject my own ActionRenderResponseGenerator that does my bidding?

Not following you here ... but in 5.1 it is possible to override
contributions as well as services.


 Norman Franke
 Answering Service for Directors, Inc.
 www.myasd.com







-- 
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

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



Re: T5 IOC Questions

2009-07-10 Thread Norman Franke

On Jul 10, 2009, at 6:55 PM, Howard Lewis Ship wrote:

On Fri, Jul 10, 2009 at 3:27 PM, Norman Frankenor...@myasd.com  
wrote:

First, I have a ton of DAOs that I need to bind the interface to the
implementation. I'd like to do this automatically, so I don't have  
to keep
modifying my AppModule for each DAO I create. What's the best way  
to go
about this? I figure if I can somehow get a ClassNameLocator  
instance, I
could just iterate through my package and do it that way. However,  
how do I

get a ClassNameLocator in bind(ServiceBinder)?


Look at the ServiceBinder interface; there are methods there
(especially in 5.1) that may address your needs.


I did, but how do I get a ClassNameLocator in the bind() method so I  
can then pass my classes to the ServiceBinder? bind() can only take a  
single argument, and I can't inject something into the class, since  
this is static.




Second, on the SUPPRESS_REDIRECT_FROM_ACTION_REQUESTS issue, is it  
possible

to inject my own ActionRenderResponseGenerator that does my bidding?


Not following you here ... but in 5.1 it is possible to override
contributions as well as services.


I see that the InternalModule has a  
buildActionRenderResponseGenerator() and I'd like replace that with my  
own implementation. I'm just not sure how. I've tried a number of  
things, including adding my own buildActionRenderResponseGenerator,  
which fails due to duplication. I tried an alias, but can't get that  
working either. What's the magic mojo to replace the  
ActionRenderResponseGenerator service with something else in my  
AppModule?



Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos


Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



Re: T5 IOC Questions

2009-07-10 Thread Norman Franke

On Jul 10, 2009, at 7:08 PM, Norman Franke wrote:


On Jul 10, 2009, at 6:55 PM, Howard Lewis Ship wrote:

On Fri, Jul 10, 2009 at 3:27 PM, Norman Frankenor...@myasd.com  
wrote:

First, I have a ton of DAOs that I need to bind the interface to the
implementation. I'd like to do this automatically, so I don't have  
to keep
modifying my AppModule for each DAO I create. What's the best way  
to go
about this? I figure if I can somehow get a ClassNameLocator  
instance, I
could just iterate through my package and do it that way. However,  
how do I

get a ClassNameLocator in bind(ServiceBinder)?


Look at the ServiceBinder interface; there are methods there
(especially in 5.1) that may address your needs.


I did, but how do I get a ClassNameLocator in the bind() method so I  
can then pass my classes to the ServiceBinder? bind() can only take  
a single argument, and I can't inject something into the class,  
since this is static.




Second, on the SUPPRESS_REDIRECT_FROM_ACTION_REQUESTS issue, is it  
possible

to inject my own ActionRenderResponseGenerator that does my bidding?


Not following you here ... but in 5.1 it is possible to override
contributions as well as services.


I see that the InternalModule has a  
buildActionRenderResponseGenerator() and I'd like replace that with  
my own implementation. I'm just not sure how. I've tried a number of  
things, including adding my own buildActionRenderResponseGenerator,  
which fails due to duplication. I tried an alias, but can't get that  
working either. What's the magic mojo to replace the  
ActionRenderResponseGenerator service with something else in my  
AppModule?


I've tried:
contributeAlias
contributeAliasOverride
contributeServiceOverride

None seem to actually override the ActionRenderResponseGenerator. Very  
strange.


-Norman



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



Re: T5 IOC questions

2007-07-06 Thread David Avenante

Ok,

I continue my investigation.
So I think I don't need to override my service but only override my
service configuration.

So my service is :
PageRenderInitializer
and my service configuration is :
contributePageRenderInitializer( ...

As write in the documentation :
The extensibility comes from the fact multiple modules may all
contribute to the same service configuration:

So I override the the contributePageRenderInitializer with :

public void 
contributePageRenderInitializer(OrderedConfigurationPageRenderCommand
configuration,
   final SymbolSource symbolSource,
   final AssetSource assetSource) {
   configuration.add(PageRenderSupport, new PageRenderCommand() {
   public void cleanup(Environment environment) {
   environment.pop(PageRenderSupport.class);
   Document document = environment.peek(Document.class);
   DocumentScriptBuilder builder =
environment.pop(DocumentScriptBuilder.class);
   builder.updateDocument(document);
   }

   public void setup(Environment environment) {
   DocumentScriptBuilder builder = new
MyOwnDocumentScriptBuilderImpl();
   environment.push(DocumentScriptBuilder.class, builder);
   environment.push(PageRenderSupport.class, new
PageRenderSupportImpl(builder,
   symbolSource, assetSource));
   }
   }, before:*);

   }

It's an ordered list so I add the before:* statement to reflect the
order that I can see in the original method.

But this approach don't work : first my method is call twice 
And the method throw and exception like :

11:21:18,796 - [SocketListener0-1] ERROR - PageRenderInitializer:
Construction of service PageRenderInitializer failed: Error invoking
service builder method
org.apache.tapestry.services.TapestryModule.build(List) (at
TapestryModule.java:988) (for service 'PageRenderInitializer'): Error
invoking service contribution method
com.illuminate.services.AppModule.contributePageRenderInitializer(OrderedConfiguration,
SymbolSource, AssetSource): java.lang.NullPointerException
java.lang.RuntimeException: Error invoking service builder method
org.apache.tapestry.services.TapestryModule.build(List) (at
TapestryModule.java:988) (for service 'PageRenderInitializer'): Error
invoking service contribution method
com.illuminate.services.AppModule.contributePageRenderInitializer(OrderedConfiguration,
SymbolSource, AssetSource): java.lang.NullPointerException
...
...
Caused by: java.lang.RuntimeException: Error invoking service
contribution method
com.illuminate.services.AppModule.contributePageRenderInitializer(OrderedConfiguration,
SymbolSource, AssetSource): java.lang.NullPointerException

Thank for any input ;)

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 IOC questions

2007-07-06 Thread David Avenante

Hummm after debug time I found that impossible to me to add in ordered
list the same Id (see class Orderer code).

So if it's impossible I need to override the component
PageRenderInitializer and all the associated configuration.

So I continue my investigation with aliasOveridesService.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 IOC questions

2007-06-18 Thread Howard Lewis Ship

You should be getting an error there, ApplicationDefault's
configuration is a MapString,String.

You override built-in services by contributing to the Alias service
(or the AliasOverrides service).

On 6/18/07, David Avenante [EMAIL PROTECTED] wrote:

Hi,

I've two questions about the configuration of my ioc container.

First i would be able to override the default configuration to use my
own DocumentScriptBuilder i've wrote some code in my appModule to try
to overide
the default config but without succes !!!

public static void
contributeApplicationDefaults(MappedConfigurationString, Object
configuration,
 final
SymbolSource symbolSource,
 final AssetSource
assetSource) {
configuration.add(tapestry.supported-locales, en);
configuration.add(PageRenderSupport, new PageRenderCommand()
{
public void cleanup(Environment environment)
{
environment.pop(PageRenderSupport.class);
Document document = environment.peek(Document.class);
DocumentScriptBuilder builder =
environment.pop(DocumentScriptBuilder.class);
builder.updateDocument(document);
}

public void setup(Environment environment)
{
DocumentScriptBuilder builder = new
MyDocumentScriptBuilderImpl();
environment.push(DocumentScriptBuilder.class, builder);
environment.push(PageRenderSupport.class, new
PageRenderSupportImpl(builder,
symbolSource, assetSource));
}
});

}

I've miss something ?

Other question is about my authenticate Filter. I can test the url and
find if the user session is valide. But how redirect/forward the user
to a specifique page with the same use of tapestry navigation (with
class name for exemple) and without use of low level servlet API.

Thank's

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 IOC questions

2007-06-18 Thread David Avenante

Humm I'm very confuse with your input. The documentation and the
tapestry  code source don't help me too :(

I use the Alias approche like this :

public static void contributeAlias(ConfigurationAliasContribution
configuration,
  final SymbolSource
symbolSource, final AssetSource assetSource)
   {
   configuration.add(AliasContribution.create(PageRenderCommand.class,
new PageRenderCommand() {
   public void cleanup(Environment environment) {
   environment.pop(PageRenderSupport.class);

   Document document = environment.peek(Document.class);
   DocumentScriptBuilder builder =
environment.pop(DocumentScriptBuilder.class);
   builder.updateDocument(document);
   }

   public void setup(Environment environment) {
   DocumentScriptBuilder builder = new
MyDocumentScriptBuilderImpl();
   environment.push(DocumentScriptBuilder.class, builder);
   environment.push(PageRenderSupport.class, new
PageRenderSupportImpl(builder, symbolSource, assetSource));
   }
   }));

   }

But I raise a recursive exception :
java.lang.RuntimeException: Failure starting Jetty instance:
org.mortbay.util.MultiException[java.lang.RuntimeException: Exception
constructing service 'ServletApplicationInitializer': Unable to
instantiate class org.apache.tapestry.services.TapestryModule as a
module builder: Exception constructing service 'Alias': Error invoking
service builder method
org.apache.tapestry.services.TapestryModule.build(Log, String,
AliasManager, Collection) (at TapestryModule.java:254) (for service
'Alias'): Error invoking service contribution method
com.illuminate.services.AppModule.contributeAlias(Configuration,
SymbolSource, AssetSource): Exception constructing service 'Alias':
Construction of service 'Alias' has failed due to recursion: the
service depends on itself in some way. Please check
org.apache.tapestry.services.TapestryModule.build(Log, String,
AliasManager, Collection) (at TapestryModule.java:254) for references
to another service that is itself dependent on service 'Alias'.]

Does i need to overide the PageRenderSupport service or only the
DocumentScriptBuilder and what the right way ?

Thank's


On 6/18/07, Howard Lewis Ship [EMAIL PROTECTED] wrote:

You should be getting an error there, ApplicationDefault's
configuration is a MapString,String.

You override built-in services by contributing to the Alias service
(or the AliasOverrides service).

On 6/18/07, David Avenante [EMAIL PROTECTED] wrote:
 Hi,

 I've two questions about the configuration of my ioc container.

 First i would be able to override the default configuration to use my
 own DocumentScriptBuilder i've wrote some code in my appModule to try
 to overide
 the default config but without succes !!!

 public static void
 contributeApplicationDefaults(MappedConfigurationString, Object
 configuration,
  final
 SymbolSource symbolSource,
  final AssetSource
 assetSource) {
 configuration.add(tapestry.supported-locales, en);
 configuration.add(PageRenderSupport, new PageRenderCommand()
 {
 public void cleanup(Environment environment)
 {
 environment.pop(PageRenderSupport.class);
 Document document = environment.peek(Document.class);
 DocumentScriptBuilder builder =
 environment.pop(DocumentScriptBuilder.class);
 builder.updateDocument(document);
 }

 public void setup(Environment environment)
 {
 DocumentScriptBuilder builder = new
 MyDocumentScriptBuilderImpl();
 environment.push(DocumentScriptBuilder.class, builder);
 environment.push(PageRenderSupport.class, new
 PageRenderSupportImpl(builder,
 symbolSource, assetSource));
 }
 });

 }

 I've miss something ?

 Other question is about my authenticate Filter. I can test the url and
 find if the user session is valide. But how redirect/forward the user
 to a specifique page with the same use of tapestry navigation (with
 class name for exemple) and without use of low level servlet API.

 Thank's

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: T5 IOC questions

2007-06-18 Thread Howard Lewis Ship

Making contributions to the Alias service can be somewhat tricky,
there's a chicken-and-the-egg problem.  You're contributing into the
Alias service, but the Alias service is used to disambiguate
injections ... such as the SymbolSource and AssetSource parameters to
the contribution method.  That's the recursion.  You may have to
perform the injection explicitly, via @InjectService.

On 6/18/07, David Avenante [EMAIL PROTECTED] wrote:

Humm I'm very confuse with your input. The documentation and the
tapestry  code source don't help me too :(

I use the Alias approche like this :

public static void contributeAlias(ConfigurationAliasContribution
configuration,
   final SymbolSource
symbolSource, final AssetSource assetSource)
{
configuration.add(AliasContribution.create(PageRenderCommand.class,
new PageRenderCommand() {
public void cleanup(Environment environment) {
environment.pop(PageRenderSupport.class);

Document document = environment.peek(Document.class);
DocumentScriptBuilder builder =
environment.pop(DocumentScriptBuilder.class);
builder.updateDocument(document);
}

public void setup(Environment environment) {
DocumentScriptBuilder builder = new
MyDocumentScriptBuilderImpl();
environment.push(DocumentScriptBuilder.class, builder);
environment.push(PageRenderSupport.class, new
PageRenderSupportImpl(builder, symbolSource, assetSource));
}
}));

}

But I raise a recursive exception :
java.lang.RuntimeException: Failure starting Jetty instance:
org.mortbay.util.MultiException[java.lang.RuntimeException: Exception
constructing service 'ServletApplicationInitializer': Unable to
instantiate class org.apache.tapestry.services.TapestryModule as a
module builder: Exception constructing service 'Alias': Error invoking
service builder method
org.apache.tapestry.services.TapestryModule.build(Log, String,
AliasManager, Collection) (at TapestryModule.java:254) (for service
'Alias'): Error invoking service contribution method
com.illuminate.services.AppModule.contributeAlias(Configuration,
SymbolSource, AssetSource): Exception constructing service 'Alias':
Construction of service 'Alias' has failed due to recursion: the
service depends on itself in some way. Please check
org.apache.tapestry.services.TapestryModule.build(Log, String,
AliasManager, Collection) (at TapestryModule.java:254) for references
to another service that is itself dependent on service 'Alias'.]

Does i need to overide the PageRenderSupport service or only the
DocumentScriptBuilder and what the right way ?

Thank's


On 6/18/07, Howard Lewis Ship [EMAIL PROTECTED] wrote:
 You should be getting an error there, ApplicationDefault's
 configuration is a MapString,String.

 You override built-in services by contributing to the Alias service
 (or the AliasOverrides service).

 On 6/18/07, David Avenante [EMAIL PROTECTED] wrote:
  Hi,
 
  I've two questions about the configuration of my ioc container.
 
  First i would be able to override the default configuration to use my
  own DocumentScriptBuilder i've wrote some code in my appModule to try
  to overide
  the default config but without succes !!!
 
  public static void
  contributeApplicationDefaults(MappedConfigurationString, Object
  configuration,
   final
  SymbolSource symbolSource,
   final AssetSource
  assetSource) {
  configuration.add(tapestry.supported-locales, en);
  configuration.add(PageRenderSupport, new PageRenderCommand()
  {
  public void cleanup(Environment environment)
  {
  environment.pop(PageRenderSupport.class);
  Document document = environment.peek(Document.class);
  DocumentScriptBuilder builder =
  environment.pop(DocumentScriptBuilder.class);
  builder.updateDocument(document);
  }
 
  public void setup(Environment environment)
  {
  DocumentScriptBuilder builder = new
  MyDocumentScriptBuilderImpl();
  environment.push(DocumentScriptBuilder.class, builder);
  environment.push(PageRenderSupport.class, new
  PageRenderSupportImpl(builder,
  symbolSource, assetSource));
  }
  });
 
  }
 
  I've miss something ?
 
  Other question is about my authenticate Filter. I can test the url and
  find if the user session is valide. But how redirect/forward the user
  to a specifique page with the same use of tapestry navigation (with
  class name for exemple) and without use of low level servlet API.
 
  Thank's
 
  -
  To unsubscribe, e-mail: [EMAIL