View Javadoc

1   /*
2    * $Id: DummyInitialContextFactory.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.test.integration.config;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.lifecycle.InitialisationCallback;
15  import org.mule.api.lifecycle.InitialisationException;
16  import org.mule.api.object.ObjectFactory;
17  import org.mule.api.service.Service;
18  import org.mule.component.simple.EchoComponent;
19  import org.mule.jndi.SimpleContext;
20  import org.mule.module.management.agent.Log4jAgent;
21  import org.mule.module.xml.transformer.XmlToObject;
22  import org.mule.tck.MuleTestUtils;
23  import org.mule.transport.vm.VMConnector;
24  
25  /**
26   * A dummy property factory for creating a Jndi context
27   */
28  public class DummyInitialContextFactory implements ObjectFactory
29  {
30      private MuleContext muleContext;
31  
32      public DummyInitialContextFactory(MuleContext muleContext)
33      {
34          this.muleContext = muleContext;
35      }
36  
37      public Object getInstance(MuleContext muleContext) throws Exception
38      {
39          SimpleContext c = new SimpleContext();
40          c.bind("vmConnector", new VMConnector(muleContext));
41          c.bind("endpointRef", "vm://my.object");
42          c.bind("Log4JAgent", new Log4jAgent());
43          c.bind("XmlToObject", new XmlToObject());
44          Service d = MuleTestUtils.getTestService("EchoUMO", EchoComponent.class, this.muleContext);
45          c.bind("EchoUMO", d);
46          return c;
47      }
48  
49      public void initialise() throws InitialisationException
50      {
51          // do nothing
52      }
53  
54      public void dispose()
55      {
56          // do nothing
57      }
58  
59      public void release(Object arg0)
60      {
61          // do nothing
62      }
63  
64      public Class<?> getObjectClass()
65      {
66          throw new UnsupportedOperationException();
67      }
68  
69      public void addObjectInitialisationCallback(InitialisationCallback callback)
70      {
71          throw new UnsupportedOperationException();        
72      }
73  
74      public boolean isSingleton()
75      {
76          return false;
77      }
78  
79      public boolean isExternallyManagedLifecycle()
80      {
81          return false;
82      }
83  
84      public boolean isAutoWireObject()
85      {
86          return false;
87      }
88  }