Discussion:
"Service point hivemind.Startup does not exist" when attempting to create Registry 'the long way'
Alistair Israel
2004-10-12 13:57:34 UTC
Permalink
Hi, folks!

Apologies if this has been asked and answered before. I've only worked
with Hivemind for about a week or so and have managed to get it to
work very basically for me - I still don't know whether the Registry
can 'autowire' using constructor injection like it can with setter
injection (or like how Picocontainer does it).

Anyway, so now I'm trying to specify the location of "hivemodule.xml"
myself, someplace (possibly) not in $user.dir\META-INF or someplace
outside of the classpath perhaps.

I already have the following code to bootstrap the registry.
ClassResolver classResolver = new DefaultClassResolver();
ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
moduleDescriptor.setLocation(new LocationImpl(new
FileResource( "C:\\hivemodule.xml")));
RegistryBuilder registryBuilder = new RegistryBuilder();
registryBuilder.processModule(moduleDescriptor);
registry = registryBuilder.constructRegistry(Locale.getDefault());


I've also tried the alternate method of constructing the Registry at:
http://article.gmane.org/gmane.comp.jakarta.hivemind.user/219

When I run the (unit test code), I get the following exception:

java.lang.ExceptionInInitializerError
at test.enterworks.epim.spike.MigrationComponentBuilderTest.testGetDbProxy(MigrationComponentBuilderTest.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: org.apache.hivemind.ApplicationRuntimeException: Service
point hivemind.Startup does not exist.
at org.apache.hivemind.impl.RegistryImpl.getServicePoint(RegistryImpl.java:142)
at org.apache.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:149)
at org.apache.hivemind.impl.RegistryImpl.startup(RegistryImpl.java:321)
at org.apache.hivemind.impl.RegistryBuilder.constructRegistry(RegistryBuilder.java:417)
at com.enterworks.epim.spike.MigrationComponentBuilder.<clinit>(MigrationComponentBuilder.java:41)
... 16 more

I must be missing something very, very basic, I know - but for the
life of me can't see it in the docs (which, BTW it seems they now
refer to 1.1alpha so they're not very useful).

TIA!

Alistair A. Israel
--
http://aisrael.multiply.com
Howard Lewis Ship
2004-10-12 14:20:13 UTC
Permalink
Your code is only loading your one specific descriptor; you still need
to use the normal process for loading descriptors on the classpath,
such as the built-in ones for the hivemind module itself.

HiveMind isn't as smart as PicoContainer at autowriing w/
constructors; for constuctor DI you must supply a list of constructor
arguments, no autowiring.
Post by Alistair Israel
Hi, folks!
Apologies if this has been asked and answered before. I've only worked
with Hivemind for about a week or so and have managed to get it to
work very basically for me - I still don't know whether the Registry
can 'autowire' using constructor injection like it can with setter
injection (or like how Picocontainer does it).
Anyway, so now I'm trying to specify the location of "hivemodule.xml"
myself, someplace (possibly) not in $user.dir\META-INF or someplace
outside of the classpath perhaps.
I already have the following code to bootstrap the registry.
ClassResolver classResolver = new DefaultClassResolver();
ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
moduleDescriptor.setLocation(new LocationImpl(new
FileResource( "C:\\hivemodule.xml")));
RegistryBuilder registryBuilder = new RegistryBuilder();
registryBuilder.processModule(moduleDescriptor);
registry = registryBuilder.constructRegistry(Locale.getDefault());
http://article.gmane.org/gmane.comp.jakarta.hivemind.user/219
java.lang.ExceptionInInitializerError
at test.enterworks.epim.spike.MigrationComponentBuilderTest.testGetDbProxy(MigrationComponentBuilderTest.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: org.apache.hivemind.ApplicationRuntimeException: Service
point hivemind.Startup does not exist.
at org.apache.hivemind.impl.RegistryImpl.getServicePoint(RegistryImpl.java:142)
at org.apache.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:149)
at org.apache.hivemind.impl.RegistryImpl.startup(RegistryImpl.java:321)
at org.apache.hivemind.impl.RegistryBuilder.constructRegistry(RegistryBuilder.java:417)
at com.enterworks.epim.spike.MigrationComponentBuilder.<clinit>(MigrationComponentBuilder.java:41)
... 16 more
I must be missing something very, very basic, I know - but for the
life of me can't see it in the docs (which, BTW it seems they now
refer to 1.1alpha so they're not very useful).
TIA!
Alistair A. Israel
--
http://aisrael.multiply.com
---------------------------------------------------------------------
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com
John Coleman
2004-10-12 23:41:00 UTC
Permalink
I want to access HiveMind services in my Tapestry application.

In my engine I put this:-

protected Object createGlobal(RequestContext context) {
Global global = (Global) super.createGlobal(context);
global.initResitry(context);
return global;
}

public UserService getUserService() {
if (userService == null) {
userService = (UserService) ((Global)
getGlobal()).getRegistry().getService(UserService.class);
}
return userService;
}

I use the engine to instantiate the Global object with the registry:-

// for services
public void initResitry(RequestContext context) {
if (registry == null) {
registry = HiveMindFilter.getRegistry(context.getRequest());
}
}

I am interested in comments on this design. How are others dealing with
their HiveMind service references in Tapestry?

My main question is about how services inside HiveMind will share a
"SessionManager" service, and can I make that service private to classes
inside HiveMind.

I have considered a SessionManager interface but at the moment simply have a
implementation like this:-

public class HibernateSessionManager {

private static final SessionFactory sessionFactory;

static {
// Create the SessionFactory
try {
sessionFactory = new
Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
// variable to hold a session object for a thread
public static final ThreadLocal session = new ThreadLocal();

// obtain the session of the current thread
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}

// close the session on the current thread
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null) s.close();
}

}

I suppose as everything is static I can just use static access, but is that
best practice as that will tie me to an implemenation class! I would rather
create an interface and be get a ref to the implementing class that is
defined in the xml configs.

Is there an example xml to show me this please?

TIA
John
James Carman
2004-10-14 01:15:03 UTC
Permalink
John, there is a WIKI
(http://wiki.apache.org/jakarta-hivemind/HibernateSupport) page set up to
discuss Hibernate support in Hivemind. I have posted an example application
(http://issues.apache.org/jira/browse/HIVEMIND-54?page=comments#action_53136
) as a comment on the JIRA issue which requests Hibernate support in
Hivemind, which you can download and run. It might give you some good
ideas. I'm not saying that my solution is the best solution, but it can get
you started. I hope the example can help you. Let me know if you need
anything.

-----Original Message-----
From: John Coleman [mailto:***@ntlworld.com]
Sent: Tuesday, October 12, 2004 7:41 PM
To: hivemind-***@jakarta.apache.org
Subject: access hibernate session

I want to access HiveMind services in my Tapestry application.

In my engine I put this:-

protected Object createGlobal(RequestContext context) {
Global global = (Global) super.createGlobal(context);
global.initResitry(context);
return global;
}

public UserService getUserService() {
if (userService == null) {
userService = (UserService) ((Global)
getGlobal()).getRegistry().getService(UserService.class);
}
return userService;
}

I use the engine to instantiate the Global object with the registry:-

// for services
public void initResitry(RequestContext context) {
if (registry == null) {
registry = HiveMindFilter.getRegistry(context.getRequest());
}
}

I am interested in comments on this design. How are others dealing with
their HiveMind service references in Tapestry?

My main question is about how services inside HiveMind will share a
"SessionManager" service, and can I make that service private to classes
inside HiveMind.

I have considered a SessionManager interface but at the moment simply have a
implementation like this:-

public class HibernateSessionManager {

private static final SessionFactory sessionFactory;

static {
// Create the SessionFactory
try {
sessionFactory = new
Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
// variable to hold a session object for a thread
public static final ThreadLocal session = new ThreadLocal();

// obtain the session of the current thread
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}

// close the session on the current thread
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null) s.close();
}

}

I suppose as everything is static I can just use static access, but is that
best practice as that will tie me to an implemenation class! I would rather
create an interface and be get a ref to the implementing class that is
defined in the xml configs.

Is there an example xml to show me this please?

TIA
John


---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-***@jakarta.apache.org
For additional commands, e-mail: hivemind-user-***@jakarta.apache.org
Jean-Francois Poilpret
2004-10-14 15:19:10 UTC
Permalink
Hi all,

I was thinking about James' remark regarding the fact that we should work on
a generic Transaction Service utility for Hivemind.
This service would have implementations for JDBC connections/transactions,
JTA transactions, Hibernate transactions...
I started to have some reflection about that and dramatically refactored
code that I had started to write for Hibernate support. This is quite a lot
of work actually!

About Hibernate I was wondering about one important point:
- outside the context of JTA, does it make sense to allow creating more than
one SessionFactory (ie, more than one DB to connect to)? If so, then how
should we manage transactions? I mean, if your code works at the same time
with 2 sessions (referencing 2 different databases), when the time comes for
the transaction service to commit the work, what should it do to commit 2
transactions independently of one another (no JTA), what should happen in
case of a problem?
- wouldn't it sound better (I mean, more logical) to restrict usage of only
one SessionFactory when there is no JTA transaction service available?

Actually, the same question applies as well to JDBC: should we allow having
more than one DataSource in the system?

Some ideas about that?

If I have more time this week-end I will try to come up with a first version
including the following:
- TransactionService interface + dependent classes (the "transaction
framework"...)
- JdbcTransactionService + simple example
- HibernateTransactionService (draft) in "mono-SessionFactory" + simple
example

It could be ready for upload during next week.

JTA will certainly not come until much later (I have to self-learn about it
first and find out a JTA Manager that can work out of the box (ie, not
inside a complete EJB container)).
Howard Lewis Ship
2004-10-14 19:49:34 UTC
Permalink
I've been emailing back and forth with Rod Johnson; I'd much rather
leverage their code than re-invent it. Seems like we should be able
to create a HiveMind wrapper around the Spring transaction interceptor
and be done with it.


On Thu, 14 Oct 2004 22:19:10 +0700, Jean-Francois Poilpret
Post by Jean-Francois Poilpret
Hi all,
I was thinking about James' remark regarding the fact that we should work on
a generic Transaction Service utility for Hivemind.
This service would have implementations for JDBC connections/transactions,
JTA transactions, Hibernate transactions...
I started to have some reflection about that and dramatically refactored
code that I had started to write for Hibernate support. This is quite a lot
of work actually!
- outside the context of JTA, does it make sense to allow creating more than
one SessionFactory (ie, more than one DB to connect to)? If so, then how
should we manage transactions? I mean, if your code works at the same time
with 2 sessions (referencing 2 different databases), when the time comes for
the transaction service to commit the work, what should it do to commit 2
transactions independently of one another (no JTA), what should happen in
case of a problem?
- wouldn't it sound better (I mean, more logical) to restrict usage of only
one SessionFactory when there is no JTA transaction service available?
Actually, the same question applies as well to JDBC: should we allow having
more than one DataSource in the system?
Some ideas about that?
If I have more time this week-end I will try to come up with a first version
- TransactionService interface + dependent classes (the "transaction
framework"...)
- JdbcTransactionService + simple example
- HibernateTransactionService (draft) in "mono-SessionFactory" + simple
example
It could be ready for upload during next week.
JTA will certainly not come until much later (I have to self-learn about it
first and find out a JTA Manager that can work out of the box (ie, not
inside a complete EJB container)).
---------------------------------------------------------------------
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com
German de la Cruz
2005-07-04 14:12:33 UTC
Permalink
Hi, folks!

Apologies if this has been asked and answered before, but I can't find an
answer to this problem.

Is there a way to put a default value to a read-attribute rule of a
configuration-point? I mean, something like skip-if-null, but where there is
a null, it put a defined default value. Something like

<read-attribute property="attribute1" attribute="attribute1"
value-if-null="${some.default.value}"/>

Well, I hope this is clear enough. Thanks in advance

German.-
Johan Lindquist
2005-07-04 14:30:04 UTC
Permalink
Hi German,

You can put the default value into the hivemind.FactoryDefaults
configuration point and HiveMind will use that if no other values are found.

<contribution configuration-id="hivemind.FactoryDefaults">
<default symbol="some.default.value" value="the-default-value"/>
</contribution>

Hope that helps,

Johan
Post by Alistair Israel
Hi, folks!
Apologies if this has been asked and answered before, but I can't find an
answer to this problem.
Is there a way to put a default value to a read-attribute rule of a
configuration-point? I mean, something like skip-if-null, but where there is
a null, it put a defined default value. Something like
<read-attribute property="attribute1" attribute="attribute1"
value-if-null="${some.default.value}"/>
Well, I hope this is clear enough. Thanks in advance
German.-
---------------------------------------------------------------------
- --
you too?
German de la Cruz
2005-07-04 15:00:00 UTC
Permalink
Ok, this is the solution I found. I put a default value in FactoryDefaults
and then I write an attribute in the service that is contributed with my
contribution.

The problem is want to put the default value in the contribution itself in a
way to avoid putting this attribute in the service because I think it's not
a responsibility of the service but the contribution.

This is the solution I implement....

<service-point id="OperationService" interface="OperationService">
<invoke-factory service-id="hivemind.BuilderFactory">
<construct class="OperationServiceDefault">
<set-configuration configuration-id="Operations" property="operations"/>
<set property="defaultLanguage" value="${defaults.default-el}"/>
</construct>
</invoke-factory>
</service-point>

<configuration-point id="Operations">
<schema>
<element name="operation">
<attribute name="target" required="true"/>
<attribute name="operation" required="true"/>
<attribute name="language" required="false"/>
<attribute name="message-key"/>
<rules>
<create-object class="OperationImpl"/>
<read-attribute property="target" attribute="target" translator="class"/>
<read-attribute property="operation" attribute="operation"/>
<read-attribute property="messageKey" attribute="message-key"/>
<read-attribute property="language" attribute="language"
skip-if-null="true"/>
<read-content property="content"/>
<invoke-parent method="addElement"/>
</rules>
</element>
</schema>
</configuration-point>

<contribution configuration-id="hivemind.FactoryDefaults">
<default symbol="defaults.default-el" value="groovy"/>
</contribution>
.



And this is an approach that I want to....

<service-point id="OperationService" interface="OperationService">
<invoke-factory service-id="hivemind.BuilderFactory">
<construct class="OperationServiceDefault">
<set-configuration configuration-id="Operations" property="operations"/>
</construct>
</invoke-factory>
</service-point>

<configuration-point id="Operations">
<schema>
<element name="operation">
<attribute name="target" required="true"/>
<attribute name="operation" required="true"/>
<attribute name="language" required="false"/>
<attribute name="message-key"/>
<rules>
<create-object class="OperationImpl"/>
<read-attribute property="target" attribute="target" translator="class"/>
<read-attribute property="operation" attribute="operation"/>
<read-attribute property="messageKey" attribute="message-key"/>
<read-attribute property="language" attribute="language"
value-if-null="${defaults.default-el}"/>
<read-content property="content"/>
<invoke-parent method="addElement"/>
</rules>
</element>
</schema>
</configuration-point>

<contribution configuration-id="hivemind.FactoryDefaults">
<default symbol="defaults.default-el" value="groovy"/>
</contribution>


Thanks!

-----Mensaje original-----
De: Johan Lindquist [mailto:***@kawoo.co.uk]
Enviado el: Lunes, 04 de Julio de 2005 11:30 a.m.
Para: hivemind-***@jakarta.apache.org
Asunto: Re: putting a default value to a read-attribute rule in a
configuration-point

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi German,

You can put the default value into the hivemind.FactoryDefaults
configuration point and HiveMind will use that if no other values are found.

<contribution configuration-id="hivemind.FactoryDefaults">
<default symbol="some.default.value" value="the-default-value"/>
</contribution>

Hope that helps,

Johan
Post by Alistair Israel
Hi, folks!
Apologies if this has been asked and answered before, but I can't find an
answer to this problem.
Is there a way to put a default value to a read-attribute rule of a
configuration-point? I mean, something like skip-if-null, but where there is
a null, it put a defined default value. Something like
<read-attribute property="attribute1" attribute="attribute1"
value-if-null="${some.default.value}"/>
Well, I hope this is clear enough. Thanks in advance
German.-
---------------------------------------------------------------------
- --
you too?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCyUfrHS6c76+IdrwRAqzfAJ9YXyGQpvsyYixItSZYGmh2ZXOGGACg5puv
iT+lG+EleqaDkmoTqkZkEII=
=RW7A
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-***@jakarta.apache.org
For additional commands, e-mail: hivemind-user-***@jakarta.apache.org
Hensley, Richard
2004-10-13 20:08:10 UTC
Permalink
To integrate HiveMind and Tapestry, we use the hivemind servlet filter. It
manages all the thread and pooled type services very well.

Our web.xml has

<filter>
<filter-name>HiveMindFilter</filter-name>

<filter-class>org.apache.hivemind.servlet.HiveMindFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>HiveMindFilter</filter-name>
<servlet-name>wo</servlet-name>
</filter-mapping>

And our Engine has the following:

protected Object createGlobal(RequestContext arg0) {
Global global = (Global) super.createGlobal(arg0);
global.setRegistry(HiveMindFilter.getRegistry(arg0.getRequest()));
return global;
}

And our global has a method that returns the services required by the
application. Our application only has about 8 services, so this is a
workable design for us.

/**
* Return the Security service
* @return
*/
public Security getSecurity() {
return (Security) getService(Security.class);
}

private Object getService(Class clazz) {
return this.registry.getService(clazz.getName(), clazz);
}

public void setRegistry(Registry registry) {
SC.checkstate(this.registry == null);
SC.checknull(registry);
this.registry = registry;
}

As for how to access Hibernate, I would investigate Threaded services. A new
instance is created each time a thread needs it. The Hivemind filter manages
notification and throwing away Threaded services at the end of the http
request cycle. Seems to me that this is what you are looking for.

If Session is an interface, I would create a Session service. That service
would be injected with a SessionFactory service. I would make the Session
service threaded. It would implement the Discardable interface. That
interface supports a method called 'threadDidDiscardService' which is called
when the service is no longer needed by a thread. The HiveMindFilter manages
the threaded services for you in a web application. To implement such a
service, the first access to the session would have to get a session from
the factory and start a transaction. I'm not sure what the discard would
have to do, possibly commit the transaction and close the session, or you
might not want to deal with transactions in the SessionService. The way
HiveMind works, a transaction could be a separate service that is injected
with the SessionService. This could work by maybe beginning a transaction
when you get the service. At the discard time it could rollback the
transaction if it has not been committed.

Another alternative would be to check out the Spring/HiveMind integration
because I've heard that Spring does a really nice job of exposing Hibernate
in a IoC container. If you check out the HiveMind wiki, there are some
Hibernate integration ideas. If you come up with something working and cool
you might want to throw your ideas on the pile.

We don't happen to Hibernate, but we had a very similar problem with the ORM
we use.

By the way, if you really want to twist your brain and know about something
cool, check out how HiveMind proxies all the thread service and pooled
service stuff so that all threads have the same object instance, yet have
their own private executing instance of a service for the thread. It is
magic.

Richard
Hensley, Richard
2004-10-14 20:54:25 UTC
Permalink
Would using the Spring code with a HiveMind wrapper imply any spring
dependencies?

Richard

-----Original Message-----
From: Howard Lewis Ship [mailto:***@gmail.com]
Sent: Thursday, October 14, 2004 12:50 PM
To: hivemind-***@jakarta.apache.org
Subject: Re: Transaction Service, Hibernate without JTA


I've been emailing back and forth with Rod Johnson; I'd much rather
leverage their code than re-invent it. Seems like we should be able
to create a HiveMind wrapper around the Spring transaction interceptor
and be done with it.


On Thu, 14 Oct 2004 22:19:10 +0700, Jean-Francois Poilpret
Post by Jean-Francois Poilpret
Hi all,
I was thinking about James' remark regarding the fact that we should work
on
Post by Jean-Francois Poilpret
a generic Transaction Service utility for Hivemind.
This service would have implementations for JDBC connections/transactions,
JTA transactions, Hibernate transactions...
I started to have some reflection about that and dramatically refactored
code that I had started to write for Hibernate support. This is quite a
lot
Post by Jean-Francois Poilpret
of work actually!
- outside the context of JTA, does it make sense to allow creating more
than
Post by Jean-Francois Poilpret
one SessionFactory (ie, more than one DB to connect to)? If so, then how
should we manage transactions? I mean, if your code works at the same time
with 2 sessions (referencing 2 different databases), when the time comes
for
Post by Jean-Francois Poilpret
the transaction service to commit the work, what should it do to commit 2
transactions independently of one another (no JTA), what should happen in
case of a problem?
- wouldn't it sound better (I mean, more logical) to restrict usage of
only
Post by Jean-Francois Poilpret
one SessionFactory when there is no JTA transaction service available?
Actually, the same question applies as well to JDBC: should we allow
having
Post by Jean-Francois Poilpret
more than one DataSource in the system?
Some ideas about that?
If I have more time this week-end I will try to come up with a first
version
Post by Jean-Francois Poilpret
- TransactionService interface + dependent classes (the "transaction
framework"...)
- JdbcTransactionService + simple example
- HibernateTransactionService (draft) in "mono-SessionFactory" + simple
example
It could be ready for upload during next week.
JTA will certainly not come until much later (I have to self-learn about
it
Post by Jean-Francois Poilpret
first and find out a JTA Manager that can work out of the box (ie, not
inside a complete EJB container)).
---------------------------------------------------------------------
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-***@jakarta.apache.org
For additional commands, e-mail: hivemind-user-***@jakarta.apache.org
Howard Lewis Ship
2004-10-15 14:21:41 UTC
Permalink
Yes, the spring.jar would be on the classpath, but you would not be
firing up a Spring BeanContext; we'd be using Spring as a library
rather than as a framework.


On Thu, 14 Oct 2004 16:54:25 -0400, Hensley, Richard
Post by Hensley, Richard
Would using the Spring code with a HiveMind wrapper imply any spring
dependencies?
Richard
-----Original Message-----
Sent: Thursday, October 14, 2004 12:50 PM
Subject: Re: Transaction Service, Hibernate without JTA
I've been emailing back and forth with Rod Johnson; I'd much rather
leverage their code than re-invent it. Seems like we should be able
to create a HiveMind wrapper around the Spring transaction interceptor
and be done with it.
On Thu, 14 Oct 2004 22:19:10 +0700, Jean-Francois Poilpret
Post by Jean-Francois Poilpret
Hi all,
I was thinking about James' remark regarding the fact that we should work
on
Post by Jean-Francois Poilpret
a generic Transaction Service utility for Hivemind.
This service would have implementations for JDBC connections/transactions,
JTA transactions, Hibernate transactions...
I started to have some reflection about that and dramatically refactored
code that I had started to write for Hibernate support. This is quite a
lot
Post by Jean-Francois Poilpret
of work actually!
- outside the context of JTA, does it make sense to allow creating more
than
Post by Jean-Francois Poilpret
one SessionFactory (ie, more than one DB to connect to)? If so, then how
should we manage transactions? I mean, if your code works at the same time
with 2 sessions (referencing 2 different databases), when the time comes
for
Post by Jean-Francois Poilpret
the transaction service to commit the work, what should it do to commit 2
transactions independently of one another (no JTA), what should happen in
case of a problem?
- wouldn't it sound better (I mean, more logical) to restrict usage of
only
Post by Jean-Francois Poilpret
one SessionFactory when there is no JTA transaction service available?
Actually, the same question applies as well to JDBC: should we allow
having
Post by Jean-Francois Poilpret
more than one DataSource in the system?
Some ideas about that?
If I have more time this week-end I will try to come up with a first
version
Post by Jean-Francois Poilpret
- TransactionService interface + dependent classes (the "transaction
framework"...)
- JdbcTransactionService + simple example
- HibernateTransactionService (draft) in "mono-SessionFactory" + simple
example
It could be ready for upload during next week.
JTA will certainly not come until much later (I have to self-learn about
it
Post by Jean-Francois Poilpret
first and find out a JTA Manager that can work out of the box (ie, not
inside a complete EJB container)).
---------------------------------------------------------------------
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com
---------------------------------------------------------------------
---------------------------------------------------------------------
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com
Istvan Orban
2004-10-16 12:52:42 UTC
Permalink
Hi,

I have some services which are loaded <contribution
configuration-id="hivemind.EagerLoad">
one of this service creates a pool to a server. and manages the pool itself.

I'm supposed to delete this pool from the remote server when I do not
need it anymore.

the final application will run inside Tomcat, and many Threads will
requests clients from the Pool which is managed by the service I wrote.
When the application is stopped I guess I should stop Hivemind too, with
all my services, and do the necessary clean-ups.

Is there a standard way of doing this??

Thanks, sorrry for the lame question..

Istvano
Filip S. Adamsen
2004-10-16 13:14:02 UTC
Permalink
Please check out the following API docs:

http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/Regi
stry.html#shutdown()

http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/even
ts/RegistryShutdownListener.html

http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/Disc
ardable.html

Hope this helps.

-Filip
Post by James Carman
-----Original Message-----
Sent: Saturday, October 16, 2004 2:53 PM
Subject: Multi-threaded question
Hi,
I have some services which are loaded <contribution
configuration-id="hivemind.EagerLoad">
one of this service creates a pool to a server. and manages the pool itself.
I'm supposed to delete this pool from the remote server when I do not
need it anymore.
the final application will run inside Tomcat, and many Threads will
requests clients from the Pool which is managed by the service I wrote.
When the application is stopped I guess I should stop Hivemind too, with
all my services, and do the necessary clean-ups.
Is there a standard way of doing this??
Thanks, sorrry for the lame question..
Istvano
---------------------------------------------------------------------
Istvan Orban
2004-10-16 14:22:15 UTC
Permalink
Thanks it helped a lot...

But I must be doing somewhing wrong as the "registryDidShutdown" never
get called.

I have this interface->

public interface ClientSource {
public abstract Client getClient();
public abstract void releaseClient(Client client);
}

this is the core service ->

public class ClientSourceImpl implements ClientSource,
RegistryShutdownListener {
....
public void registryDidShutdown() {
System.out.println("!!!!! SHUTDOWN !!!!!!");
}

public void initializeService() {
System.out.println("!!!!! STARTUP !!!!!!");
}

}

<?xml version="1.0"?>
<module id="service" version="1.0.0">
<contribution configuration-id="hivemind.EagerLoad">
<load service-id="MyClientSource"/>
</contribution>
<service-point id="MyClientSource" interface="....ClientSource">
<invoke-factory service-id="hivemind.BuilderFactory">
<construct class="....ClientSourceImpl">
<set property="configFile" value="my.properties"/>
</construct>
</invoke-factory>
<interceptor service-id="hivemind.LoggingInterceptor"/>
</service-point>
</module>

everything works fine

Registry registry = RegistryBuilder.constructDefaultRegistry();
ClientSource cs = (ClientSource)
registry.getService(ClientSource.class);
.......
System.out.println("before Shutdown");
registry.shutdown();
System.out.println("after Shutdown");


log:

Creating SingletonProxy for service service.MyClientSource
Constructing core service implementation for service service.MyClientSource
Autowired property log to
***@1ec6696
Set property configFile to my.properties
Applying interceptor factory hivemind.LoggingInterceptor
.....
before Shutdown
after Shutdown

Any idea what I'm doing wrong ???

THANKS A LOT!!!!
Post by Filip S. Adamsen
http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/Regi
stry.html#shutdown()
http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/even
ts/RegistryShutdownListener.html
http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/Disc
ardable.html
Hope this helps.
-Filip
Post by James Carman
-----Original Message-----
Sent: Saturday, October 16, 2004 2:53 PM
Subject: Multi-threaded question
Hi,
I have some services which are loaded <contribution
configuration-id="hivemind.EagerLoad">
one of this service creates a pool to a server. and manages the pool itself.
I'm supposed to delete this pool from the remote server when I do not
need it anymore.
the final application will run inside Tomcat, and many Threads will
requests clients from the Pool which is managed by the service I wrote.
When the application is stopped I guess I should stop Hivemind too, with
all my services, and do the necessary clean-ups.
Is there a standard way of doing this??
Thanks, sorrry for the lame question..
Istvano
---------------------------------------------------------------------
---------------------------------------------------------------------
Jean-Francois Poilpret
2004-10-16 15:53:33 UTC
Permalink
Hi Istvano,

This is not really clear in the doc but if you want your service to be
notified of shutdown events, it is not sufficient to have it implement
RegistryShutdownListener. In addition, in the configuration, you must
declare it listens for events from the ShutdownCoordinator.

Try that:
<invoke-factory service-id="hivemind.BuilderFactory">
<construct class="....ClientSourceImpl">
<event-listener service-id="hivemind.ShutdownCoordinator"/>
<set property="configFile" value="my.properties"/>
</construct>
</invoke-factory>

This should do the trick (I got stuck with the same problem a few weeks
ago;-))


-----Original Message-----
From: Istvan Orban [mailto:***@mailbox.hu]
Sent: Saturday, October 16, 2004 9:22 PM
To: hivemind-***@jakarta.apache.org
Subject: Re: Multi-threaded question

Thanks it helped a lot...

But I must be doing somewhing wrong as the "registryDidShutdown" never
get called.

I have this interface->

public interface ClientSource {
public abstract Client getClient();
public abstract void releaseClient(Client client);
}

this is the core service ->

public class ClientSourceImpl implements ClientSource,
RegistryShutdownListener {
....
public void registryDidShutdown() {
System.out.println("!!!!! SHUTDOWN !!!!!!");
}

public void initializeService() {
System.out.println("!!!!! STARTUP !!!!!!");
}

}

<?xml version="1.0"?>
<module id="service" version="1.0.0">
<contribution configuration-id="hivemind.EagerLoad">
<load service-id="MyClientSource"/>
</contribution>
<service-point id="MyClientSource" interface="....ClientSource">
<invoke-factory service-id="hivemind.BuilderFactory">
<construct class="....ClientSourceImpl">
<set property="configFile" value="my.properties"/>
</construct>
</invoke-factory>
<interceptor service-id="hivemind.LoggingInterceptor"/>
</service-point>
</module>

everything works fine

Registry registry = RegistryBuilder.constructDefaultRegistry();
ClientSource cs = (ClientSource)
registry.getService(ClientSource.class);
.......
System.out.println("before Shutdown");
registry.shutdown();
System.out.println("after Shutdown");


log:

Creating SingletonProxy for service service.MyClientSource
Constructing core service implementation for service service.MyClientSource
Autowired property log to
***@1ec6696
Set property configFile to my.properties
Applying interceptor factory hivemind.LoggingInterceptor
.....
before Shutdown
after Shutdown

Any idea what I'm doing wrong ???

THANKS A LOT!!!!
Post by Filip S. Adamsen
http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/Reg
i
Post by Filip S. Adamsen
stry.html#shutdown()
http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/eve
n
Post by Filip S. Adamsen
ts/RegistryShutdownListener.html
http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/Dis
c
Post by Filip S. Adamsen
ardable.html
Hope this helps.
-Filip
Post by James Carman
-----Original Message-----
Sent: Saturday, October 16, 2004 2:53 PM
Subject: Multi-threaded question
Hi,
I have some services which are loaded <contribution
configuration-id="hivemind.EagerLoad">
one of this service creates a pool to a server. and manages the pool itself.
I'm supposed to delete this pool from the remote server when I do not
need it anymore.
the final application will run inside Tomcat, and many Threads will
requests clients from the Pool which is managed by the service I wrote.
When the application is stopped I guess I should stop Hivemind too, with
all my services, and do the necessary clean-ups.
Is there a standard way of doing this??
Thanks, sorrry for the lame question..
Istvano
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-***@jakarta.apache.org
For additional commands, e-mail: hivemind-user-***@jakarta.apache.org
Istvan Orban
2004-10-16 16:04:29 UTC
Permalink
Hi,

Thanks, it works great,
yep, it's not 100% in the Doc, although I guess there are still more
important things left to do...

ps: I was playing around with that thing too (as I suspected the same)
but with no success. :))))

I hope in the version 1.1 there will be a sample application which uses
most of the tricks you can do with this fantastic framework !!!!!!!!!

Istvano
Post by Jean-Francois Poilpret
Hi Istvano,
This is not really clear in the doc but if you want your service to be
notified of shutdown events, it is not sufficient to have it implement
RegistryShutdownListener. In addition, in the configuration, you must
declare it listens for events from the ShutdownCoordinator.
<invoke-factory service-id="hivemind.BuilderFactory">
<construct class="....ClientSourceImpl">
<event-listener service-id="hivemind.ShutdownCoordinator"/>
<set property="configFile" value="my.properties"/>
</construct>
</invoke-factory>
This should do the trick (I got stuck with the same problem a few weeks
ago;-))
Loading...