Ok, I've done this:




  try

   {

     Class<?> jamesContext = 
Class.forName("org.apache.james.mailetcontainer.impl.JamesMailetContext");

     log.info("got jamesContext class " + jamesContext);



     Method method = jamesContext.getMethod("getInstance");

     log.info("got getInstance method" + method);

    

     mailetContext = (MailetContext)method.invoke(null, (Object[])null);

     log.info("Successfully got mailet context " + mailetContext);

   }

   catch (Exception e)

   {

   e.printStackTrace();

   throw new MailboxException();

   }







But now I feel really dirty :-(





If there is a better way of doing this, please let me know.



-tim





On Sat Oct 13 22:06:07 EDT 2012, tim <[email protected]> wrote:
> 
> Ok, I've figured out where it is instantiated from, it looks like it is a 
> bean:
> 
> 
> 
> instantiating JamesMailetContext
> 
> java.lang.Exception: hi
> 
> at 
> org.apache.james.mailetcontainer.impl.JamesMailetContext.<init>(JamesMailetContext.java:73)
> 
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 
> at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
> 
> at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 
> at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
> 
> at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
> 
> at 
> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76)
> 
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
> 
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
> 
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
> 
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
> 
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
> 
> at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
> 
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
> 
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
> 
> at 
> org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:442)
> 
> at 
> org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416)
> 
> at 
> org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:549)
> 
> at 
> org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:159)
> 
> at 
> org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
> 
> at 
> org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
> 
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
> 
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
> 
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
> 
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
> 
> at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
> 
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
> 
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
> 
> at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
> 
> at 
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
> 
> at 
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
> 
> at 
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
> 
> at 
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
> 
> at 
> org.apache.james.container.spring.context.JamesServerApplicationContext.<init>(JamesServerApplicationContext.java:39)
> 
> at 
> org.apache.james.app.spring.JamesAppSpringMain.init(JamesAppSpringMain.java:61)
> 
> at 
> org.apache.james.app.spring.JamesAppSpringMain.main(JamesAppSpringMain.java:42)
> 
> 
> 
> 
> 
> I'm wondering whether or not there is a trivial way of getting this 
> JamesMailetContext as a bean.
> 
> Will research tomorrow.
> 
> 
> 
> If anyone has any input, please let me know.
> 
> 
> 
> -tim
> 
> 
> 
> 
> 
> 
> 
> On Sat Oct 13 17:05:24 EDT 2012, tim <[email protected]> wrote:
> > 
> > Ok, I've finally found the JamesMailetContext.
> > 
> > 
> > 
> > I guess this is my question, and then I can implement this:
> > 
> > Is there a way of getting this object from saving from the mailbox?
> > 
> > 
> > 
> > I'm pondering just hacking it into a singleton which I can then retrieve 
> > get. If I go this route: are there mutliple "JamesMailetContext"s 
> > instantiated during the process?
> > 
> > 
> > 
> > Thanks in advance,
> > 
> > 
> > 
> > -tim
> > 
> > 
> > 
> > 
> > 
> > On Sat Oct 13 16:37:28 EDT 2012, tim <[email protected]> wrote:
> > > 
> > > Greetings again,
> > > 
> > > 
> > > 
> > > So my plan was to refactor RemoteDelivery, and create a "Retry" mailet, 
> > > from which ToRecipients and ToSender would derive.
> > > 
> > > Of course this doesn't work. Because ToRecipientFolder would retry all 
> > > the recipients, so some users would get the mail multiple times.
> > > 
> > > 
> > > 
> > > My alternate action would be to modify the repository. But I don't know 
> > > how to bounce. Because I don't have a mailet context.
> > > 
> > > Or I wonder if I can get the mailet context from the config.
> > > 
> > > 
> > > 
> > > If anyone has any thoughts, feel free to chime in.
> > > 
> > > 
> > > 
> > > Is it possible to bounce a mail without a mailet context?
> > > 
> > > Is it possible to store a mailet context in a DB?
> > > 
> > > 
> > > 
> > > -tim
> > > 
> > > 
> > > 
> > > On Sun Oct 07 10:50:50 EDT 2012, tim <[email protected]> wrote:
> > > > 
> > > > Hey there,
> > > > 
> > > > I thought I would check if anyone has any input before I go ahead and 
> > > > implement this:
> > > > 
> > > > I need to write to a respository which is sometimes disconnected. If it 
> > > > is disconnected at mail-receive time, I need to queue for writing and 
> > > > retry later.
> > > > 
> > > > 
> > > > 
> > > > I plan on implementing this by copying RemoteDelivery, cutting out all 
> > > > of the socket stuff, and inserting the custom write to repository.
> > > > 
> > > > 
> > > > 
> > > > Is there some other way I should attempt which would reuse more and 
> > > > code less?
> > > > 
> > > > 
> > > > 
> > > > Thanks,
> > > > 
> > > > 
> > > > 
> > > > -tim
> > > > 
> > > >

Reply via email to