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