KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > session > BaseSessionProxyFactory


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.session;
23
24 import javax.ejb.EJBMetaData JavaDoc;
25 import javax.ejb.Handle JavaDoc;
26 import javax.ejb.HomeHandle JavaDoc;
27 import javax.ejb.Remote JavaDoc;
28 import javax.ejb.RemoteHome JavaDoc;
29 import org.jboss.annotation.ejb.RemoteBinding;
30 import org.jboss.aop.Advisor;
31 import org.jboss.ejb3.Container;
32 import org.jboss.ejb3.EJBContainer;
33 import org.jboss.ejb3.ProxyFactory;
34 import org.jboss.logging.Logger;
35 import org.jboss.ejb3.proxy.EJBMetaDataImpl;
36 import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
37
38 /**
39  * Comment
40  *
41  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
42  * @version $Revision: 56117 $
43  */

44 public abstract class BaseSessionProxyFactory implements ProxyFactory
45 {
46    private static final Logger log = Logger.getLogger(BaseSessionProxyFactory.class);
47    
48    protected Container container;
49    protected Advisor advisor;
50   
51    public Object JavaDoc createHomeProxy()
52    {
53       throw new RuntimeException JavaDoc("NYI");
54    }
55    
56    public void setContainer(Container container)
57    {
58       this.container = container;
59       this.advisor = (Advisor) container;
60    }
61    
62    protected void setEjb21Objects(BaseSessionRemoteProxy proxy)
63    {
64       proxy.setHandle(getHandle());
65       proxy.setHomeHandle(getHomeHandle());
66       proxy.setEjbMetaData(getEjbMetaData());
67    }
68    
69    abstract protected Handle JavaDoc getHandle();
70    
71    protected HomeHandle JavaDoc getHomeHandle()
72    {
73       EJBContainer ejbContainer = (EJBContainer)container;
74       
75       HomeHandleImpl homeHandle = null;
76       
77       RemoteBinding remoteBindingAnnotation = (RemoteBinding)ejbContainer.resolveAnnotation(RemoteBinding.class);
78       if (remoteBindingAnnotation != null)
79          homeHandle = new HomeHandleImpl(remoteBindingAnnotation.jndiBinding() + "Home");
80       
81       return homeHandle;
82    }
83    
84    protected EJBMetaData JavaDoc getEjbMetaData()
85    {
86       Class JavaDoc remote = null;
87       Class JavaDoc home = null;
88       Class JavaDoc pkClass = Object JavaDoc.class;
89       HomeHandleImpl homeHandle = null;
90       
91       EJBContainer ejbContainer = (EJBContainer)container;
92       
93       Remote JavaDoc remoteAnnotation = (Remote JavaDoc)ejbContainer.resolveAnnotation(Remote JavaDoc.class);
94       if (remoteAnnotation != null)
95          remote = remoteAnnotation.value()[0];
96       RemoteHome JavaDoc homeAnnotation = (RemoteHome JavaDoc)ejbContainer.resolveAnnotation(RemoteHome JavaDoc.class);
97       if (homeAnnotation != null)
98          home = homeAnnotation.value();
99       RemoteBinding remoteBindingAnnotation = (RemoteBinding)ejbContainer.resolveAnnotation(RemoteBinding.class);
100       if (remoteBindingAnnotation != null)
101          homeHandle = new HomeHandleImpl(remoteBindingAnnotation.jndiBinding());
102       
103       EJBMetaDataImpl metadata = new EJBMetaDataImpl(remote, home, pkClass, true, false, homeHandle);
104       
105       return metadata;
106    }
107
108 }
109
Popular Tags