You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Guido Franz <Gu...@1und1.de> on 2008/02/28 09:06:07 UTC

Spring integration as a Avalon component

Hello

Yesterday I tried to integrate a Spring application context into James,
that can be used within Mailets. It succeeded only halfway. My custom
component will be loaded during startup (I print out some loading
statements and spring logs some stuff), but I cannot access it with the
ServiceManager.

Assembly.xml looks like this:
##########################
  <block name="springcontext"
class="com.oneandone.ccsys.ccl.james.component.SpringContextLoader" />
##########################


The .xinfo of the SpringContextLoader component implements a simple
interface:
##########################
  <services>
    <service
name="com.oneandone.ccsys.ccl.james.component.SpringContext"/>
  </services>
##########################

The interface has a ROLE:
##########################
    String ROLE =
"com.oneandone.ccsys.ccl.james.component.SpringContext";
##########################

But I cannot access the component with the ServiceManager:
#########################
			ServiceManager serviceManager = 
				(ServiceManager)
getMailetContext().getAttribute(
	
Constants.AVALON_COMPONENT_MANAGER);
	SpringContext context =
	
(SpringContext)serviceManager.lookup(SpringContext.ROLE);
#########################


Error Message: 'Unable to provide implementation for SpringContext'.
When debugging, I cannot see my component in the map of the
ServiceManager, but I don't know how to register the component for this.
Do I have to implement a special interface like 'Contextualizable' or
something like that? This is an Avalon issue, but I don't understand how
to create components. There is not much documentation available for
Avalon, or let's say I cannot find it.


Thanks for any hint and greetings from Germany
Guido Franz




---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


AW: Spring integration as a Avalon component

Posted by Guido Franz <Gu...@1und1.de>.
Hello

Thanks for the reply.

Yes, my initial approach was quite similar ;-) But we have about a dozen mailets and high traffic. So these would be a performance leak.

Yesterday I managed it to access my component from mailets. Please see my other reply.

Thanks
Guido Franz



-----Ursprüngliche Nachricht-----
Von: Mark Derricutt [mailto:mark@talios.com]
Gesendet: Fr 29.02.2008 05:25
An: James Users List
Betreff: Re: Spring integration as a Avalon component
 
I'm currently spring from within my own Mailet as well, in my instance I
have the mailet initializing its own context (I only have the one mailet) :

    public void init(MailetConfig mailetConfig) throws MessagingException {
        super.init(mailetConfig);

        if (LoggingUtils.noAppendersConfigured()) { // is has logging been
initialised already?
            PropertyConfigurator.configureAndWatch(new
LoggingUtils().getPropertiesFile().getPath(), LOG4J_TIMEOUT);
        }

        XmlBeanFactory springContext = new XmlBeanFactory(
                new ClassPathResource("/rmi-service-context.xml"));

        try {
            PropertyPlaceholderConfigurer ppc = new
PropertyPlaceholderConfigurer();
            Properties props = new Properties();
            props.load(new
FileInputStream("/etc/bulletinwireless/bulletinmail/bulletinmail.properties"));
            ppc.setProperties(props);
            ppc.postProcessBeanFactory(springContext);
        } catch (IOException e) {
            throw new MessagingException(e.getMessage());
        }

        springContext.autowireBeanProperties(this,
AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
    }

Seems to work for me...

On 2/28/08, Guido Franz <Gu...@1und1.de> wrote:
>
> Hello
>
> Yesterday I tried to integrate a Spring application context into James,
> that can be used within Mailets. It succeeded only halfway. My custom
> component will be loaded during startup (I print out some loading
>
>
-- 
"The L in LAMP stands for Linux, not Looney" - Jonathan Schwartz, Sun
Microsystems, Inc.



Re: Spring integration as a Avalon component

Posted by Mark Derricutt <ma...@talios.com>.
I'm currently spring from within my own Mailet as well, in my instance I
have the mailet initializing its own context (I only have the one mailet) :

    public void init(MailetConfig mailetConfig) throws MessagingException {
        super.init(mailetConfig);

        if (LoggingUtils.noAppendersConfigured()) { // is has logging been
initialised already?
            PropertyConfigurator.configureAndWatch(new
LoggingUtils().getPropertiesFile().getPath(), LOG4J_TIMEOUT);
        }

        XmlBeanFactory springContext = new XmlBeanFactory(
                new ClassPathResource("/rmi-service-context.xml"));

        try {
            PropertyPlaceholderConfigurer ppc = new
PropertyPlaceholderConfigurer();
            Properties props = new Properties();
            props.load(new
FileInputStream("/etc/bulletinwireless/bulletinmail/bulletinmail.properties"));
            ppc.setProperties(props);
            ppc.postProcessBeanFactory(springContext);
        } catch (IOException e) {
            throw new MessagingException(e.getMessage());
        }

        springContext.autowireBeanProperties(this,
AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
    }

Seems to work for me...

On 2/28/08, Guido Franz <Gu...@1und1.de> wrote:
>
> Hello
>
> Yesterday I tried to integrate a Spring application context into James,
> that can be used within Mailets. It succeeded only halfway. My custom
> component will be loaded during startup (I print out some loading
>
>
-- 
"The L in LAMP stands for Linux, not Looney" - Jonathan Schwartz, Sun
Microsystems, Inc.

AW: Spring integration as a Avalon component

Posted by Guido Franz <Gu...@1und1.de>.
Hello Bernd


Yes, I have to add my custom component to the James-block in assembly.xml:

1. Create a custom component
2. Add it to assembly.xml
3. Add a Provider to the James-block in assembly.xml
4. Add a dependency to JamesMailetLoader.xinfo
5. Access it with the ServiceManager

Thanks
Guido Franz


-----Ursprüngliche Nachricht-----
Von: Bernd Fondermann [mailto:bernd.fondermann@googlemail.com]
Gesendet: Do 28.02.2008 22:18
An: James Users List
Betreff: Re: Spring integration as a Avalon component
 
On Thu, Feb 28, 2008 at 9:06 AM, Guido Franz <Gu...@1und1.de> wrote:
> Hello
>
>  Yesterday I tried to integrate a Spring application context into James,
>  that can be used within Mailets. It succeeded only halfway. My custom
>  component will be loaded during startup (I print out some loading
>  statements and spring logs some stuff), but I cannot access it with the
>  ServiceManager.
>
>  Assembly.xml looks like this:
>  ##########################
>   <block name="springcontext"
>  class="com.oneandone.ccsys.ccl.james.component.SpringContextLoader" />
>  ##########################
>
>
>  The .xinfo of the SpringContextLoader component implements a simple
>  interface:
>  ##########################
>   <services>
>     <service
>  name="com.oneandone.ccsys.ccl.james.component.SpringContext"/>
>   </services>
>  ##########################
>
>  The interface has a ROLE:
>  ##########################
>     String ROLE =
>  "com.oneandone.ccsys.ccl.james.component.SpringContext";
>  ##########################
>
>  But I cannot access the component with the ServiceManager:
>  #########################
>                         ServiceManager serviceManager =
>                                 (ServiceManager)
>  getMailetContext().getAttribute(
>
>  Constants.AVALON_COMPONENT_MANAGER);
>         SpringContext context =
>
>  (SpringContext)serviceManager.lookup(SpringContext.ROLE);
>  #########################
>
>
>  Error Message: 'Unable to provide implementation for SpringContext'.
>  When debugging, I cannot see my component in the map of the
>  ServiceManager, but I don't know how to register the component for this.
>  Do I have to implement a special interface like 'Contextualizable' or
>  something like that? This is an Avalon issue, but I don't understand how
>  to create components. There is not much documentation available for
>  Avalon, or let's say I cannot find it.

As far as I understand Avalon's overengineered component model, the
missing link is that you'd have to make the component known to the
_receiving_ component, too. Only then will it appear in the specific
serviceManager map. You can do this by adding a <dependency /> to
JamesMailetLoader.xinfo.

  Bernd

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org




Re: Spring integration as a Avalon component

Posted by Bernd Fondermann <be...@googlemail.com>.
On Thu, Feb 28, 2008 at 9:06 AM, Guido Franz <Gu...@1und1.de> wrote:
> Hello
>
>  Yesterday I tried to integrate a Spring application context into James,
>  that can be used within Mailets. It succeeded only halfway. My custom
>  component will be loaded during startup (I print out some loading
>  statements and spring logs some stuff), but I cannot access it with the
>  ServiceManager.
>
>  Assembly.xml looks like this:
>  ##########################
>   <block name="springcontext"
>  class="com.oneandone.ccsys.ccl.james.component.SpringContextLoader" />
>  ##########################
>
>
>  The .xinfo of the SpringContextLoader component implements a simple
>  interface:
>  ##########################
>   <services>
>     <service
>  name="com.oneandone.ccsys.ccl.james.component.SpringContext"/>
>   </services>
>  ##########################
>
>  The interface has a ROLE:
>  ##########################
>     String ROLE =
>  "com.oneandone.ccsys.ccl.james.component.SpringContext";
>  ##########################
>
>  But I cannot access the component with the ServiceManager:
>  #########################
>                         ServiceManager serviceManager =
>                                 (ServiceManager)
>  getMailetContext().getAttribute(
>
>  Constants.AVALON_COMPONENT_MANAGER);
>         SpringContext context =
>
>  (SpringContext)serviceManager.lookup(SpringContext.ROLE);
>  #########################
>
>
>  Error Message: 'Unable to provide implementation for SpringContext'.
>  When debugging, I cannot see my component in the map of the
>  ServiceManager, but I don't know how to register the component for this.
>  Do I have to implement a special interface like 'Contextualizable' or
>  something like that? This is an Avalon issue, but I don't understand how
>  to create components. There is not much documentation available for
>  Avalon, or let's say I cannot find it.

As far as I understand Avalon's overengineered component model, the
missing link is that you'd have to make the component known to the
_receiving_ component, too. Only then will it appear in the specific
serviceManager map. You can do this by adding a <dependency /> to
JamesMailetLoader.xinfo.

  Bernd

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org