001: package com.bm.utils.substitues;
002:
003: import java.security.Principal;
004: import java.util.Hashtable;
005: import java.util.Properties;
006:
007: import javax.ejb.EJBHome;
008: import javax.ejb.EJBLocalHome;
009: import javax.ejb.EJBLocalObject;
010: import javax.ejb.EJBObject;
011: import javax.ejb.SessionContext;
012: import javax.ejb.TimerService;
013: import javax.naming.Context;
014: import javax.naming.InitialContext;
015: import javax.naming.NamingException;
016: import javax.transaction.UserTransaction;
017: import javax.xml.rpc.handler.MessageContext;
018:
019: import org.apache.commons.lang.NotImplementedException;
020:
021: import com.bm.jndi.MemoryContextFactory;
022:
023: /**
024: * Represnts a dummy implementation for a session context. Later we can
025: * implements more functionality here.
026: *
027: * @author Daniel Wiese
028: *
029: */
030: public class FakedSessionContext implements SessionContext {
031:
032: private final InitialContext ctx;
033:
034: public FakedSessionContext() {
035: Hashtable<String, String> env = new Hashtable<String, String>();
036: env.put(Context.INITIAL_CONTEXT_FACTORY,
037: MemoryContextFactory.class.getName());
038: try {
039: ctx = new InitialContext(env);
040: } catch (NamingException e) {
041: throw new RuntimeException(
042: "Can't setup JNDI context for testing");
043: }
044: }
045:
046: /**
047: * {@inheritDoc}
048: */
049: public <T> T getBusinessObject(Class<T> businessInterface) {
050: throw new NotImplementedException("Not yet implemented");
051: }
052:
053: /**
054: * {@inheritDoc}
055: */
056: public EJBLocalObject getEJBLocalObject() {
057: throw new NotImplementedException("Not yet implemented");
058: }
059:
060: /**
061: * {@inheritDoc}
062: */
063: public EJBObject getEJBObject() {
064: throw new NotImplementedException("Not yet implemented");
065: }
066:
067: /**
068: * {@inheritDoc}
069: */
070: public Class getInvokedBusinessInterface() {
071: throw new NotImplementedException("Not yet implemented");
072: }
073:
074: /**
075: * {@inheritDoc}
076: */
077: public MessageContext getMessageContext() {
078: throw new NotImplementedException("Not yet implemented");
079: }
080:
081: /**
082: * {@inheritDoc}
083: */
084: public Principal getCallerPrincipal() {
085: throw new NotImplementedException("Not yet implemented");
086: }
087:
088: /**
089: * {@inheritDoc}
090: */
091: public EJBHome getEJBHome() {
092: throw new NotImplementedException("Not yet implemented");
093: }
094:
095: /**
096: * {@inheritDoc}
097: */
098: public EJBLocalHome getEJBLocalHome() {
099: throw new NotImplementedException("Not yet implemented");
100: }
101:
102: /**
103: * {@inheritDoc}
104: */
105: public Properties getEnvironment() {
106: throw new NotImplementedException("Not yet implemented");
107: }
108:
109: /**
110: * {@inheritDoc}
111: */
112: public boolean getRollbackOnly() {
113: throw new NotImplementedException("Not yet implemented");
114: }
115:
116: /**
117: * {@inheritDoc}
118: */
119: public TimerService getTimerService() {
120: throw new NotImplementedException(
121: "Please use injection for timer: @Resource private TimerService timerService;");
122: }
123:
124: /**
125: * {@inheritDoc}
126: */
127: public UserTransaction getUserTransaction() {
128: throw new NotImplementedException("Not yet implemented");
129: }
130:
131: /**
132: * {@inheritDoc}
133: */
134: @SuppressWarnings("deprecation")
135: public boolean isCallerInRole(java.security.Identity role) {
136: throw new NotImplementedException("Not yet implemented");
137: }
138:
139: /**
140: * {@inheritDoc}
141: */
142: public boolean isCallerInRole(String roleName) {
143: throw new NotImplementedException("Not yet implemented");
144: }
145:
146: /**
147: * {@inheritDoc}
148: */
149: public Object lookup(String name) {
150: try {
151: return ctx.lookup(name);
152: } catch (NamingException e) {
153: throw new RuntimeException(e);
154: }
155: }
156:
157: /**
158: * {@inheritDoc}
159: */
160: public void setRollbackOnly() {
161: throw new NotImplementedException("Not yet implemented");
162: }
163:
164: /**
165: * {@inheritDoc}
166: */
167: @SuppressWarnings("deprecation")
168: public java.security.Identity getCallerIdentity() {
169: throw new NotImplementedException("Not yet implemented");
170: }
171:
172: }
|