You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leif Mortenson <le...@tanukisoftware.com> on 2002/08/21 08:30:25 UTC

[Commit] New Servlet and Creator tools in the component package

I went ahead and committed a couple of tools which I have been using for 
some time to ease the use of the ECM.

1)
The first is the ExcaliburComponentManagerCreator class.  It is used to 
manage the entire lifecycle of the ECM, RoleManager, LoggerManager and
optionally the InstrumentManager.  And it can all be done with the
following code.  Much simpler than having to everything manually each
time it is used:

Initialization:
---
m_componentManagerCreator = new ExcaliburComponentManagerCreator(
    null, // Optional Context
    new File( "../conf/logkit.xml" ),
    new File( "../conf/roles.xml" ),
    new File( "../conf/components.xml"),
    new File( "../conf/instrument.xml" ) );
---

Accessing the ECM:
---
m_componentManager = m_componentManagerCreator.getComponentManager();
m_loggerManager = m_componentManagerCreator.getLoggerManager();
m_instrumentManager = m_componentManagerCreator.getInstrumentManager();
---

Shutdown:
---
m_componentManagerCreator.dispose();
m_componentManagerCreator = null;
---

It is as easy as that.

2)
The second utility class is the ExcaliburComponentManagerServlet.  It is 
located in the servlet subpackage and built into a seperate jar file: 
excalibur-component-servlet-1.0.jar
The ECMServlet allows users who wish to use the ECM in a Servlet 
environment to do so painlessly.

>From the javadocs: (Prettier in the javadocs)
---
Makes it possible for servlets to work with Avalon components without 
having to do any coding to setup and manage the lifecycle of the 
ComponentManager.  To make use of the ExcaliburComponentManagerServet.
You will need to define the servlet in your web.xml file as follows:
<!-- ExcaliburComponentManagerServlet (for initializing 
ComponentManager). -->
<servlet>
<servlet-name>ExcaliburComponentManagerServlet</servlet-name>
<display-name>ExcaliburComponentManagerServlet</display-name>
<description>Creates component manager, does not service 
requests.</description>
<servlet-class>
org.apache.avalon.excalibur.component.servlet.ExcaliburComponentManagerServlet
</servlet-class>

<!-- This parameter points to the logkit configuration file. -->
<!-- Note that the path is specified in absolute notation but it will be -->
<!-- resolved relative to the servlets webapp context path -->
<init-param>
<param-name>logkit</param-name>
<param-value>/WEB-INF/logkit.xml</param-value>
</init-param>

<!-- This parameter points to the components configuration file. -->
<init-param>
<param-name>components</param-name>
<param-value>/WEB-INF/components.xml</param-value>
</init-param>

<!-- Roles file supplements configuration file to make the latter -->
<!-- more readable. Most likely you don't want to change the roles -->
<!-- file -->
<init-param>
<param-name>roles</param-name>
<param-value>/WEB-INF/roles.xml</param-value>
</init-param>

<!-- This parameter points to the instrument manager configuration file. -->
<init-param>
<param-name>instrument</param-name>
<param-value>/WEB-INF/instrument.xml</param-value>
</init-param>

<load-on-startup>1</load-on-startup>
</servlet>

Please pay particular attention to the load-on-startup element. It is 
used to control the order in which servlets are started by the servlet 
engine. It must have a value which is less than any other servlets 
making use of the ComponentManager. This is to ensure that the 
ComponentManager is initialized before any other servlets attempt to 
start using it.
All of the configuration files are located in the WEB-INF directory by 
default. The instrument configuration file is optional. Please see the 
ExcaliburComponentManagerCreator class for details on 
what goes into these configuration files. Note that the lifecycle of the 
ExcaliburComponentManagerCreator is managed automatically by this 
servlet, so there is no need to access the class directly.
Once the servlet has been configured, other servlets may gain access to 
the ComponentManager, InstrumentManager and LoggerManager via the 
ServletContext using the following code within a servlet:
// Get a reference to the ServletContext
ServletContext servletContext = getServletContext();

// Acquire the LoggerManager
LoggerManager loggerManager =
(LoggerManager)m_servletContext.getAttribute( 
LoggerManager.class.getName() );

// Acquire the InstrumentManager
InstrumentManager instrumentManager =
(InstrumentManager)m_servletContext.getAttribute( 
InstrumentManager.class.getName() );

// Acquire the ComponentManager
ComponentManager componentManager =
(ComponentManager)m_servletContext.getAttribute( 
ComponentManager.class.getName() );

The ExcaliburComponentManagerServlet makes use of a proxy system to 
manage reference to the above managers, so it is not necessary to 
release them when a servlet is done using them.
---

Cheers,
Leif



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Commit] New Servlet and Creator tools in the component package

Posted by Stephen McConnell <mc...@apache.org>.

Leif Mortenson wrote:

> I had been trying to get into Fortress when all the childish 
> mudslinging started.  Tried
> sifting through it for a while to get to the meat of the issues.  But 
> ended up deciding to
> wait a couple weeks for certain committers to maybe grow up a bit.  
> Then see where
> the dust settles.
>

Having slung some mud recently - my applogies.

Steve.




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Commit] New Servlet and Creator tools in the component package

Posted by Peter Royal <pr...@apache.org>.
On Thursday 22 August 2002 08:51 am, Berin Loritsch wrote:
> Nope, that's where your wrong.  Fortress will give you a selector if
> you ask for the MyComponent.ROLE + "Selector" ending.

Where in the code does this happen? 
-pete

-- 
peter royal -> proyal@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Commit] New Servlet and Creator tools in the component package

Posted by Leif Mortenson <le...@tanukisoftware.com>.

Berin Loritsch wrote:

>>Nothing wrong with Fortress. :-)  I am playing around with it 
>>some.  But 
>>I do have a bunch of
>>code which is written to use the ECM along with the Selectors.   
>>Fortress doesn't support
>>selectors, so that code would have to be rewritten.
>>    
>>
>
>Nope, that's where your wrong.  Fortress will give you a selector if
>you ask for the MyComponent.ROLE + "Selector" ending.
>
>If there are multiple components that implement the same interface,
>and you don't ask for a "Selector" it will return the default.  The
>default is the first component read from the config file, unless you
>specify default="true" as an attribute of the component config element.
>
Great, glad to hear it is in there.  I'll give it a try.

>>While all that is happening, the tried and true ECM is there.
>>    
>>
>
>The soon-to-be-retired ECM.  All of this "mudslinging" is to get
>the correct meta model so that all components are implemented and
>described the same way--regardless of the container that is using
>it.  Fortress is very similar to ECM in the way components are
>described--with a few subtle differences.  Merlin is more similar
>to the Phoenix way of doing things.  Anytime we need to converge
>on standards things get heated.
>
Heated discussions are good.  A lot of good ideas usually come out of 
people being
forced things out well enough to get everyone to agree.  But for a 
couple of days, there
was not a lot more than fighting.  That is what I was referring to. 
 Anyway.  It looks like
it has passed.

>>Sounds good, but it is not going to happen on the project I 
>>am working on right now.  Next project sure. It is going to 
>>have to be around for a while.  It is still the main CM 
>>in the latest released
>>version of Avalon.
>>    
>>
>
>Yep.  We are nearing the place where that will no longer be true.
>
Ok, I'll go in and take a closer look.

Cheers,
Leif



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [Commit] New Servlet and Creator tools in the component package

Posted by Berin Loritsch <bl...@apache.org>.
> From: Leif Mortenson [mailto:leif@tanukisoftware.com] 
> 
> Berin Loritsch wrote:
> 
> >>From: Leif Mortenson [mailto:leif@tanukisoftware.com]
> >>
> >>I went ahead and committed a couple of tools which I have
> >>been using for 
> >>some time to ease the use of the ECM.
> >>
> >>1)
> >>The first is the ExcaliburComponentManagerCreator class.  It
> >>is used to 
> >>manage the entire lifecycle of the ECM, RoleManager, 
> >>LoggerManager and optionally the InstrumentManager.  And it 
> >>can all be done with the following code.  Much simpler than 
> >>having to everything manually each time it is used:
> >>
> >>Initialization:
> >>---
> >>m_componentManagerCreator = new ExcaliburComponentManagerCreator(
> >>    null, // Optional Context
> >>    new File( "../conf/logkit.xml" ),
> >>    new File( "../conf/roles.xml" ),
> >>    new File( "../conf/components.xml"),
> >>    new File( "../conf/instrument.xml" ) );
> >>---
> >>    
> >>
> >
> >You mean you don't want to use Fortress?  It has the same basic 
> >approach, and is just as easy to use.
> >
> Nothing wrong with Fortress. :-)  I am playing around with it 
> some.  But 
> I do have a bunch of
> code which is written to use the ECM along with the Selectors.   
> Fortress doesn't support
> selectors, so that code would have to be rewritten.

Nope, that's where your wrong.  Fortress will give you a selector if
you ask for the MyComponent.ROLE + "Selector" ending.

If there are multiple components that implement the same interface,
and you don't ask for a "Selector" it will return the default.  The
default is the first component read from the config file, unless you
specify default="true" as an attribute of the component config element.


> How stable is Fortress now?  With all of the 
> Merlin/Fortress/ContainerKit arguments
> going on right now.  It seems like things are still in flux a bit. 
>  Fortress is the only one I
> have done anything with and so far I like it.  But the ECM is 
> still the 
> current tried
> and true CM.  These tools do not add new functionality to them.  They 
> simply make
> the ECM easier to use.

Code hasn't changed all that much.  Right now, Fortress is pretty
stable.  Since Fortress supports multiple concrete Container types,
I am experimenting with a Merlin compatible container.

The main thing that is in contest is the meta model/meta data
discussions.  Fortress as it stands right now does not make use
of it *yet*.  I want to make sure that Fortress uses the correct
meta model.


> I had been trying to get into Fortress when all the childish 
> mudslinging 
> started.  Tried
> sifting through it for a while to get to the meat of the issues.  But 
> ended up deciding to
> wait a couple weeks for certain committers to maybe grow up a 
> bit.  Then 
> see where
> the dust settles.
> 
> While all that is happening, the tried and true ECM is there.

The soon-to-be-retired ECM.  All of this "mudslinging" is to get
the correct meta model so that all components are implemented and
described the same way--regardless of the container that is using
it.  Fortress is very similar to ECM in the way components are
described--with a few subtle differences.  Merlin is more similar
to the Phoenix way of doing things.  Anytime we need to converge
on standards things get heated.


> >>2)
> >>The second utility class is the
> >>ExcaliburComponentManagerServlet.  It is 
> >>located in the servlet subpackage and built into a seperate 
> jar file: 
> >>excalibur-component-servlet-1.0.jar
> >>The ECMServlet allows users who wish to use the ECM in a Servlet 
> >>environment to do so painlessly.
> >>    
> >>
> >I would really like it if we started divorcing ourselves from ECM.
> >
> Sounds good, but it is not going to happen on the project I 
> am working on right now.  Next project sure. It is going to 
> have to be around for a while.  It is still the main CM 
> in the latest released
> version of Avalon.

Yep.  We are nearing the place where that will no longer be true.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Commit] New Servlet and Creator tools in the component package

Posted by Leif Mortenson <le...@tanukisoftware.com>.
Berin Loritsch wrote:

>>From: Leif Mortenson [mailto:leif@tanukisoftware.com] 
>>
>>I went ahead and committed a couple of tools which I have 
>>been using for 
>>some time to ease the use of the ECM.
>>
>>1)
>>The first is the ExcaliburComponentManagerCreator class.  It 
>>is used to 
>>manage the entire lifecycle of the ECM, RoleManager, 
>>LoggerManager and optionally the InstrumentManager.  And it 
>>can all be done with the following code.  Much simpler than 
>>having to everything manually each time it is used:
>>
>>Initialization:
>>---
>>m_componentManagerCreator = new ExcaliburComponentManagerCreator(
>>    null, // Optional Context
>>    new File( "../conf/logkit.xml" ),
>>    new File( "../conf/roles.xml" ),
>>    new File( "../conf/components.xml"),
>>    new File( "../conf/instrument.xml" ) );
>>---
>>    
>>
>
>You mean you don't want to use Fortress?  It has the same basic
>approach, and is just as easy to use.
>
Nothing wrong with Fortress. :-)  I am playing around with it some.  But 
I do have a bunch of
code which is written to use the ECM along with the Selectors.   
Fortress doesn't support
selectors, so that code would have to be rewritten.

How stable is Fortress now?  With all of the 
Merlin/Fortress/ContainerKit arguments
going on right now.  It seems like things are still in flux a bit. 
 Fortress is the only one I
have done anything with and so far I like it.  But the ECM is still the 
current tried
and true CM.  These tools do not add new functionality to them.  They 
simply make
the ECM easier to use.

I had been trying to get into Fortress when all the childish mudslinging 
started.  Tried
sifting through it for a while to get to the meat of the issues.  But 
ended up deciding to
wait a couple weeks for certain committers to maybe grow up a bit.  Then 
see where
the dust settles.

While all that is happening, the tried and true ECM is there.

>>2)
>>The second utility class is the 
>>ExcaliburComponentManagerServlet.  It is 
>>located in the servlet subpackage and built into a seperate jar file: 
>>excalibur-component-servlet-1.0.jar
>>The ECMServlet allows users who wish to use the ECM in a Servlet 
>>environment to do so painlessly.
>>    
>>
>I would really like it if we started divorcing ourselves from ECM.
>
Sounds good, but it is not going to happen on the project I am working on
right now.  Next project sure.
It is going to have to be around for a while.  It is still the main CM 
in the latest released
version of Avalon.

>>The ExcaliburComponentManagerServlet makes use of a proxy system to 
>>manage reference to the above managers, so it is not necessary to 
>>release them when a servlet is done using them.
>>    
>>
>Excellent,
>
>but can this be done for Fortress?
>
Should be no reason why not.

Cheers,
Leif


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [Commit] New Servlet and Creator tools in the component package

Posted by Berin Loritsch <bl...@apache.org>.
> From: Leif Mortenson [mailto:leif@tanukisoftware.com] 
> 
> I went ahead and committed a couple of tools which I have 
> been using for 
> some time to ease the use of the ECM.
> 
> 1)
> The first is the ExcaliburComponentManagerCreator class.  It 
> is used to 
> manage the entire lifecycle of the ECM, RoleManager, 
> LoggerManager and optionally the InstrumentManager.  And it 
> can all be done with the following code.  Much simpler than 
> having to everything manually each time it is used:
> 
> Initialization:
> ---
> m_componentManagerCreator = new ExcaliburComponentManagerCreator(
>     null, // Optional Context
>     new File( "../conf/logkit.xml" ),
>     new File( "../conf/roles.xml" ),
>     new File( "../conf/components.xml"),
>     new File( "../conf/instrument.xml" ) );
> ---

You mean you don't want to use Fortress?  It has the same basic
approach, and is just as easy to use.


> 2)
> The second utility class is the 
> ExcaliburComponentManagerServlet.  It is 
> located in the servlet subpackage and built into a seperate jar file: 
> excalibur-component-servlet-1.0.jar
> The ECMServlet allows users who wish to use the ECM in a Servlet 
> environment to do so painlessly.

I would really like it if we started divorcing ourselves from ECM.


> The ExcaliburComponentManagerServlet makes use of a proxy system to 
> manage reference to the above managers, so it is not necessary to 
> release them when a servlet is done using them.

Excellent,

but can this be done for Fortress?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>