Re: Question tapestry service

2012-08-20 Thread George Christman
Thanks Thiago. This has really helped me a lot. 



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715628.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Question tapestry service

2012-08-20 Thread Thiago H de Paula Figueiredo
On Mon, 20 Aug 2012 14:37:49 -0300, George Christman  
 wrote:



Okay Few more minor questions on this and I think I'll be good to go.

1. If I declared ImportTask as a service, could I use it as a list as  
well?


Example

@Inject
private List importTask;


No. You can, however, have something like an ImportTaskSource service that  
returns the import tasks available.



2. When using services, should the service always be used with an
interface?


No. Defining a service as an interface has its advantages,


In the case above, it's being shown with a Hibernate entity
class.


If ImportTask is a Hibernate entity, it definitely should not be a service.


3. lastly when I populate my Service Obj, is that data available to me in
another service,


Your service can provide getters and setters so other services can access  
this data.


--
Thiago H. de Paula Figueiredo

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



Re: Question tapestry service

2012-08-20 Thread George Christman
On Mon, Aug 20, 2012 at 1:13 PM, Thiago H de Paula Figueiredo [via
Tapestry]  wrote:

> On Mon, 20 Aug 2012 12:36:34 -0300, George Christman
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=5715615&i=0>>
> wrote:
>
> > public static SomeService someServiceBuilder(Service1 service1, Service2
> > service2) {
> >   return new SomeService(service1, service2);
> > }
>
> This can be replaced by binder.bind().
>
> > and returns a new Class(service1, service2). I wasn't aware you could
> > pass in non service objs into the method.
>
> Which method? The builder method parameters can only handle services and a
>
> couple other objects (distributed configuration and other objects that
> aren't services but have injection provided for them. Inside the method,
> you can do anything you want.
>
> Okay, this is what that is what I thought based on what I've read.


> > In my case I have an entity called
> > ImportTask.class. I'm populating the ImportTask from a hibernate
> criteria
> > query.
> >
> > @Inject
> > private AutoMateParser autoMateParser;
> >
> > ImportTask importTasks = (ImportTask) session.get(ImportTask.class,
> > DatabaseConstant.AUTOMATE_PARSER);
> >
> > for(ImporTask importTask : importTasks) {
> >//non service
> >AutoMateParser autoMateParser = new AutoMateParser(importTask);
> >
> >//With Service
> >autoMateParser.set(importTasks);
> > }
> >
> > I tried something like this below,
> >
> > public static AutoMateParser autoMateParserBuilder(ImportTask
> > importTask) {
> > return new AutoMateParser(importTask);
> > }
> >
> > but couldn't figure out how to actually pass my import obj into the
> > builder method so it ends up .
>
> Declare ImportTask as a service and it'll work.
>

Okay Few more minor questions on this and I think I'll be good to go.

1. If I declared ImportTask as a service, could I use it as a list as well?

Example

@Inject
private List importTask;

2. When using services, should the service always be used with an
interface? In the case above, it's being shown with a Hibernate entity
class.

3. lastly when I populate my Service Obj, is that data available to me in
another service, or would some sort of  @SessionState be required? I just
always thought service's were used to handle business logic and not to be
used like a bean.

Once again Thiago, thanks for all your help.


> The only way I know of getting that non service obj
> into my Service is with a set. Could you explain an alternate way to
> passing in that obj so it ends up in the service constructor?

public static SomeService someServiceBuilder(Service1 service1, Service2
> service2) {
>  SomeService service = new SomeService(service1, service2);
>  SomethingElse else = ...; // do anything you want here
>  service.setSomethingElse(else);
>  return service;
> }
>
> --
> Thiago H. de Paula Figueiredo
>
> -
> To unsubscribe, e-mail: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5715615&i=1>
> For additional commands, e-mail: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5715615&i=2>
>
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715615.html
>  To unsubscribe from Question tapestry service, click 
> here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5715573&code=Z2NocmlzdG1hbkBjYXJkYWRkeS5jb218NTcxNTU3M3wxNjMyOTYxMjA3>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York




--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715616.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Question tapestry service

2012-08-20 Thread Thiago H de Paula Figueiredo
On Mon, 20 Aug 2012 12:36:34 -0300, George Christman  
 wrote:



public static SomeService someServiceBuilder(Service1 service1, Service2
service2) {
  return new SomeService(service1, service2);
}


This can be replaced by binder.bind().

and returns a new Class(service1, service2). I wasn't aware you could  
pass in non service objs into the method.


Which method? The builder method parameters can only handle services and a  
couple other objects (distributed configuration and other objects that  
aren't services but have injection provided for them. Inside the method,  
you can do anything you want.



In my case I have an entity called
ImportTask.class. I'm populating the ImportTask from a hibernate criteria
query.

@Inject
private AutoMateParser autoMateParser;

ImportTask importTasks = (ImportTask) session.get(ImportTask.class,
DatabaseConstant.AUTOMATE_PARSER);

for(ImporTask importTask : importTasks) {
   //non service
   AutoMateParser autoMateParser = new AutoMateParser(importTask);

   //With Service
   autoMateParser.set(importTasks);
}

I tried something like this below,

public static AutoMateParser autoMateParserBuilder(ImportTask  
importTask) {

return new AutoMateParser(importTask);
}

but couldn't figure out how to actually pass my import obj into the  
builder method so it ends up .


Declare ImportTask as a service and it'll work.


The only way I know of getting that non service obj
into my Service is with a set. Could you explain an alternate way to
passing in that obj so it ends up in the service constructor?


public static SomeService someServiceBuilder(Service1 service1, Service2  
service2) {

SomeService service = new SomeService(service1, service2);
SomethingElse else = ...; // do anything you want here
service.setSomethingElse(else);
return service;
}

--
Thiago H. de Paula Figueiredo

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



Re: Question tapestry service

2012-08-20 Thread George Christman
My apology, correcting a few things in my example, was being rushed for
lunch.

On Mon, Aug 20, 2012 at 11:36 AM, George Christman
wrote:

>
>
> On Mon, Aug 20, 2012 at 11:06 AM, Thiago H de Paula Figueiredo [via
> Tapestry]  wrote:
>
>> On Mon, 20 Aug 2012 11:16:28 -0300, George Christman
>> <[hidden email] <http://user/SendEmail.jtp?type=node&node=5715610&i=0>>
>> wrote:
>>
>> > He say's what I'm calling a factory is actually a service locator and
>> > that AutoMateParser should be defined as a service in the AppModule.
>>
>> Yep . . .
>>
>> > He also stated the objects I use to pass in through the constructor now
>>
>> > need to be passed in through set methods
>>
>> This isn't correct for Tapestry and not even for Spring. Both support
>> injection through constructors.
>>
>> Thiago, could you elaborate on this a little bit? I've seen in the app
> module you can define a builder method that takes in some service args
>
> public static SomeService someServiceBuilder(Service1 service1, Service2
> service2) {
>   return new SomeService(service1, service2);
> }
>
> I wasn't aware you could pass in non service objs into the method. In my
> case I have an entity called ImportTask.class. I'm populating the
> ImportTask from a hibernate criteria query.
>
> @Inject
> private AutoMateParser autoMateParser;
>
> ImportTask importTasks = (ImportTask) session.get(ImportTask.class,
> DatabaseConstant.AUTOMATE_PARSER);
>
>//non service
>AutoMateParser autoMateParser = new AutoMateParser(importTask);
>
>//With Service
>autoMateParser.set(importTasks);
>
>
> I tried something like this below,
>
> public static AutoMateParser autoMateParserBuilder(ImportTask importTask) {
> return new AutoMateParser(importTask);
> }
>
> but couldn't figure out how to actually pass my import obj into the
> builder method so it ends up . The only way I know of getting that non
> service obj into my Service is with a set. Could you explain an alternate
> way to passing in that obj so it ends up in the service constructor?
>
>> > The last question where I'm still a little confused is related to using
>> > services inside extended classes. Because I'm declaring
>> > AutoMateParser.class as a service, but extending say Parser.class,
>> would
>> > I be able to inject my services inside my extended class without having
>>
>> > to declare Parser.class in my AppModule a service?
>>
>> Yes.
>>
>> --
>> Thiago H. de Paula Figueiredo
>>
>> -----
>> To unsubscribe, e-mail: [hidden 
>> email]<http://user/SendEmail.jtp?type=node&node=5715610&i=1>
>> For additional commands, e-mail: [hidden 
>> email]<http://user/SendEmail.jtp?type=node&node=5715610&i=2>
>>
>>
>>
>> --
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715610.html
>>  To unsubscribe from Question tapestry service, click 
>> here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5715573&code=Z2NocmlzdG1hbkBjYXJkYWRkeS5jb218NTcxNTU3M3wxNjMyOTYxMjA3>
>> .
>> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
> --
> George Christman
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York
>
>
>


-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York




--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715613.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Question tapestry service

2012-08-20 Thread George Christman
On Mon, Aug 20, 2012 at 11:06 AM, Thiago H de Paula Figueiredo [via
Tapestry]  wrote:

> On Mon, 20 Aug 2012 11:16:28 -0300, George Christman
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=5715610&i=0>>
> wrote:
>
> > He say's what I'm calling a factory is actually a service locator and
> > that AutoMateParser should be defined as a service in the AppModule.
>
> Yep . . .
>
> > He also stated the objects I use to pass in through the constructor now
>
> > need to be passed in through set methods
>
> This isn't correct for Tapestry and not even for Spring. Both support
> injection through constructors.
>
> Thiago, could you elaborate on this a little bit? I've seen in the app
module you can define a classBuilder method that takes in some service args

public static SomeService someServiceBuilder(Service1 service1, Service2
service2) {
  return new SomeService(service1, service2);
}

and returns a new Class(service1, service2). I wasn't aware you could pass
in non service objs into the method. In my case I have an entity called
ImportTask.class. I'm populating the ImportTask from a hibernate criteria
query.

@Inject
private AutoMateParser autoMateParser;

ImportTask importTasks = (ImportTask) session.get(ImportTask.class,
DatabaseConstant.AUTOMATE_PARSER);

for(ImporTask importTask : importTasks) {
   //non service
   AutoMateParser autoMateParser = new AutoMateParser(importTask);

   //With Service
   autoMateParser.set(importTasks);
}

I tried something like this below,

public static AutoMateParser autoMateParserBuilder(ImportTask importTask) {
return new AutoMateParser(importTask);
}

but couldn't figure out how to actually pass my import obj into the builder
method so it ends up . The only way I know of getting that non service obj
into my Service is with a set. Could you explain an alternate way to
passing in that obj so it ends up in the service constructor?

> > The last question where I'm still a little confused is related to using
> > services inside extended classes. Because I'm declaring
> > AutoMateParser.class as a service, but extending say Parser.class, would
>
> > I be able to inject my services inside my extended class without having
>
> > to declare Parser.class in my AppModule a service?
>
> Yes.
>
> --
> Thiago H. de Paula Figueiredo
>
> -
> To unsubscribe, e-mail: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5715610&i=1>
> For additional commands, e-mail: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5715610&i=2>
>
>
>
> ------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715610.html
>  To unsubscribe from Question tapestry service, click 
> here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5715573&code=Z2NocmlzdG1hbkBjYXJkYWRkeS5jb218NTcxNTU3M3wxNjMyOTYxMjA3>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York




--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715612.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Question tapestry service

2012-08-20 Thread Thiago H de Paula Figueiredo
On Mon, 20 Aug 2012 11:16:28 -0300, George Christman  
 wrote:


He say's what I'm calling a factory is actually a service locator and  
that AutoMateParser should be defined as a service in the AppModule.


Yep . . .

He also stated the objects I use to pass in through the constructor now  
need to be passed in through set methods


This isn't correct for Tapestry and not even for Spring. Both support  
injection through constructors.



The last question where I'm still a little confused is related to using
services inside extended classes. Because I'm declaring  
AutoMateParser.class as a service, but extending say Parser.class, would  
I be able to inject my services inside my extended class without having  
to declare Parser.class in my AppModule a service?


Yes.

--
Thiago H. de Paula Figueiredo

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



Re: Question tapestry service

2012-08-20 Thread George Christman
So I spent sometime with a fellow coworker this morning, "non tapestry
developer, but spring developer" and we discussed these issues I ran into
over the weekend. He was able to provide me with some basic info enabling me
to overcome the majority of my issues and understandings, but still a little
confused on one last question. 

He say's what I'm calling a factory is actually a service locator and that
AutoMateParser should be defined as a service in the AppModule. 

He also stated the objects I use to pass in through the constructor now need
to be passed in through set methods and that I could use super.set to pass
up through the extended classes which all makes sense to me now. "basic java
knowledge I should already know :( " 

The last question where I'm still a little confused is related to using
services inside extended classes. Because I'm declaring AutoMateParser.class
as a service, but extending say Parser.class, would I be able to inject my
services inside my extended class without having to declare Parser.class in
my AppModule a service? My assumption would be yes since the compiler sees
Parser.class as just AutoMateParser.class at runtime, but I'm not sure how
tapestry would see it. 

If my above assumption is incorrect, should I be extending Parser.class or
should I be Injecting Parser.class into AutoMateParser as a tapestry
service? This would be much less ideal though.

Pointing out thread safety, I wouldn't actually be using @Inject on my
properties as describe above, but rather constructor service injection with
final. Hopefully my understanding on that is clear as well. 

Thanks Guys for all the help. Looking forward to a Tap5 class at some point.  





--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715600.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Question tapestry service

2012-08-19 Thread George Christman
Hi Richard, I'll try and explain what the code does so youll be better able
to help me. The dmsimport.class has a for loop that calls a method
containing Parser parser = DMSFactory.getParser. From the for loop, I pass
into the factory which parser were going to use. AutoMateParser is actually
a custom data scrubber used to scrub csv files. I receive many different
kinds of files from different companies, so we need different scrubbers in
the factory. All of them extend my generic parser class which contains the
line reader. In the Parser.class, I'm trying to access my vehicleDAO service
which contains my hibernate queries and commits. So the problem I'm having
is not being able inject any of my services into these classes which leaves
me stuck. I'm rewritting my old app which is still on 5.1 and uses old
cayenne stuff to 5.3 and hibernate. 

I'm familiar with binding interfaces with impl class, just not sure how to
use services inside extended classes or new classes. From what I've read and
understand is you can only use tap services when your class is using ioC.
"looking forward to a good tap book or a tap class to better understand this
stuff". Hope that helps. Sorry, I'm rather new to java too.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573p5715583.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Question tapestry service

2012-08-19 Thread Richard Frovarp

On 08/18/2012 05:36 PM, George Christman wrote:

I have a few questions about the tapestry services. I'd like to be able to
Inject services in these classes, however I'm a little confused. I
understand if you want to be able to Inject a service, you must first bind
the service in the app module. However, I'm not sure if I would need to
first bind the class I'm trying to Inject the service into.

I'm also uncertain how I would go about binding an abstract class like
below, or is it inherited from the base class.

Lastly is there away to setup an entire package to work with services like
tapestry pages and components work without having to bind every class within
the task. Perhaps my understanding isn't completely clear.

A few classes and some sample code below to hopefully help clarify what I'm
trying to do.

Thanks.

public class DMSImport {

 Parser parser = DMSFactory.getParser(value1, value2, value3);

}

  public abstract class Parser {

 @Inject
 private VehicleDAO vehicleDAO;

 public Parser(String value1, String value2, String value3) {
 //Sets attributes
 vehicleDAO.setVehicle(value1);
 }

  protected abstract void parse(Reader dataReader, ParserCallback
callback) throws IOException;

}

public class AutoMateParser extends Parser {
 public AutoMateParser (String  value1, String value2, String value3) {
 super(value1, value3, value3);
 }

 protected void parse(Reader dataReader, ParserCallback callback) throws
IOException {
 //some code
 }
}

public class DMSFactory {

 public static Parser getParser(String value1, String value2, String
value3) {
 switch (dms) {
 case DatabaseConstants.INTEGRATION_IMPORTSYSTEM_AUTOMATE:
 return new AutoMateParser(value1, value2, value3);
 case
 //many other parsers that are setup identical to the
AutoMateParser
  }
 }
}





You only need to bind services. You can inject those services into other 
classes with the @Inject or @InjectService annotation.


I'm still working my way through how it all works. You don't bind 
abstract classes. You bind a class to the interface which it fully 
implements. You can use abstract classes between the interface and the 
class that is being bound with it, but in the end you can't bind 
abstract classes.


Which pieces are you trying to turn into a service? It looks like the 
VehicleDAO is a service, but from what little I can tell, it shouldn't 
be. Services need to be thread safe, so typically all of the class 
variables are declared final.


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



Question tapestry service

2012-08-18 Thread George Christman
I have a few questions about the tapestry services. I'd like to be able to
Inject services in these classes, however I'm a little confused. I
understand if you want to be able to Inject a service, you must first bind
the service in the app module. However, I'm not sure if I would need to
first bind the class I'm trying to Inject the service into. 

I'm also uncertain how I would go about binding an abstract class like
below, or is it inherited from the base class. 

Lastly is there away to setup an entire package to work with services like
tapestry pages and components work without having to bind every class within
the task. Perhaps my understanding isn't completely clear. 

A few classes and some sample code below to hopefully help clarify what I'm
trying to do. 

Thanks. 

public class DMSImport {

Parser parser = DMSFactory.getParser(value1, value2, value3);

}

 public abstract class Parser {

@Inject
private VehicleDAO vehicleDAO;

public Parser(String value1, String value2, String value3) {
//Sets attributes
vehicleDAO.setVehicle(value1);
}

 protected abstract void parse(Reader dataReader, ParserCallback
callback) throws IOException;

}

public class AutoMateParser extends Parser {
public AutoMateParser (String  value1, String value2, String value3) {
super(value1, value3, value3);
}

protected void parse(Reader dataReader, ParserCallback callback) throws
IOException {
//some code
}
}

public class DMSFactory {

public static Parser getParser(String value1, String value2, String
value3) {
switch (dms) {
case DatabaseConstants.INTEGRATION_IMPORTSYSTEM_AUTOMATE:
return new AutoMateParser(value1, value2, value3);
case 
//many other parsers that are setup identical to the
AutoMateParser
 }
}
}



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Question-tapestry-service-tp5715573.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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