0.9.0 : I don't understand

46 views
Skip to first unread message

Riccardo Cohen

unread,
Jul 1, 2015, 1:41:56 PM7/1/15
to barat...@googlegroups.com
Hello

I try to understand Baratine way of working. With baratine 0.8.7 I
succeeded in creating a list of users in an in-memory persistent
service. With 0.9.0, I had to restart from scratch.

You'll find enclosed 2 services : UserList and User. UserList is
supposed to provide access to a list of Users and has for the moment one
method : CreateUser. But it throws an exception :

io.baratine.core.ServiceExceptionNotFound: 'local:///RealtyUserListUser'
is an unknown service in AmpManager[podapp:pods/pod.0]
at com.caucho.amp.inbox.InboxNull.serviceNotFound(InboxNull.java:106)
at com.caucho.amp.inbox.InboxNull.createHeaders(InboxNull.java:101)
at com.caucho.amp.message.MessageMethod.<init>(MessageMethod.java:82)
at com.caucho.amp.message.QueryItem.<init>(QueryItem.java:83)
at com.caucho.amp.message.QueryRefFuture.<init>(QueryRefFuture.java:62)
at
com.caucho.amp.message.QueryWithFutureMessageBase.<init>(QueryWithFutureMessageBase.java:51)
at
com.caucho.amp.message.QueryWithFutureMessage_N.<init>(QueryWithFutureMessage_N.java:51)
at com.caucho.amp.resource.ResourceManager__AmpProxy.create(Unknown Source)
at RealtyTutorial.UserList.CreateUser(UserList.java:31)

I don't understand why the service is not found.
I'm a bit lost, isn't there any tutorial explaining how to do this ?
Thanks for any advice.
--
Riccardo Cohen
27 / 29 rue du Colombier
37100 Tours France
+33 6 09 83 64 49
User.java
UserList.java

Scott Ferguson

unread,
Jul 1, 2015, 3:46:47 PM7/1/15
to barat...@googlegroups.com
A new tutorial is a good idea. We'll add one for the next release, which
will be either late this week or early next week.

The RealityUserListUser isn't found because the "{m_id}" no longer does
anything special.

In the new model, you'll still have two classes, but they're look a bit
different. The ResourceManager goes away entirely.

UserManager - (replaces the UserList and the ResourceManager). Its URL
is the parent of the users. In your case /RealityUserListUser.

1. Does not have the ResourceManager
2. Has a new @Lookup to instantiate a User instance.

User:
1. No longer has a URL pattern (or a @Service annotation.)
2. Has a new @OnLoad to restore the instance
3. Has a new @OnSave to save the instance

The new model does require a bit more code for the @OnLookup, @OnLoad
and @OnSave, but should be more straightforward conceptually because you
don't need the ResourceManager. It's less magic than before.

-- Scott

> Thanks for any advice.

Nam Nguyen

unread,
Jul 1, 2015, 7:47:35 PM7/1/15
to barat...@googlegroups.com
Hi Riccardo,

I've updated your code to use the new v0.9 resources. Attached.

-- Nam
User.java
UserList.java

Scott Ferguson

unread,
Jul 1, 2015, 8:09:06 PM7/1/15
to barat...@googlegroups.com
On 7/1/15 4:47 PM, Nam Nguyen wrote:
> Hi Riccardo,
>
> I've updated your code to use the new v0.9 resources. Attached.

That's not really the same, though.

This scenario isn't an auto-create scenario. You want the user to be
created only when the create() method is called on the UserList.

So, the URL format should remain as /user/13.

The UserList should have a create() that does a lookup for

user = _selfRef.lookup("/user/" + _idCount++).as(User.class);

and then calls User create() with the proper arguments.

-- Scott

Nam Nguyen

unread,
Jul 1, 2015, 8:24:39 PM7/1/15
to barat...@googlegroups.com
On 7/1/15 5:09 PM, Scott Ferguson wrote:
> On 7/1/15 4:47 PM, Nam Nguyen wrote:
>> Hi Riccardo,
>>
>> I've updated your code to use the new v0.9 resources. Attached.
>
> That's not really the same, though.
>
> This scenario isn't an auto-create scenario. You want the user to be
> created only when the create() method is called on the UserList.
>
> So, the URL format should remain as /user/13.
>
> The UserList should have a create() that does a lookup for
>
> user = _selfRef.lookup("/user/" + _idCount++).as(User.class);
>
> and then calls User create() with the proper arguments.

Yup. v2 (current) has the url format of /user/last/first for child
services (resources). v3 would change that to /user/id with an explicit
create.

-- Nam

Riccardo Cohen

unread,
Jul 2, 2015, 3:17:22 AM7/2/15
to barat...@googlegroups.com
Thanks Scott, Nam. I'll continue in this direction.

(by the way parent.as(UserList.class) is throwing a null pointer
exception, I've replaced it with the UserList instance directly)
Reply all
Reply to author
Forward
0 new messages