KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > dd > impl > common > GetAllEjbs


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /**
21  * Superclass that implements DescriptionInterface for Servlet2.4 beans.
22  *
23  * @author Milan Kuchtiak
24  */

25
26 package org.netbeans.modules.j2ee.dd.impl.common;
27
28 import org.netbeans.modules.schema2beans.BaseBean;
29 import org.netbeans.modules.schema2beans.Version;
30 import org.netbeans.modules.j2ee.dd.api.ejb.Entity;
31 import org.netbeans.modules.j2ee.dd.api.ejb.MessageDriven;
32 import org.netbeans.modules.j2ee.dd.api.ejb.Session;
33 import org.netbeans.modules.j2ee.dd.api.ejb.Ejb;
34 import org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException;
35
36 public abstract class GetAllEjbs extends EnclosingBean {
37     
38     public GetAllEjbs(java.util.Vector JavaDoc comps, Version version) {
39         super(comps, version);
40     }
41     
42     public abstract Entity[] getEntity();
43     public abstract MessageDriven[] getMessageDriven();
44     public abstract Session[] getSession();
45     
46     public abstract int sizeSession();
47     public abstract int sizeEntity();
48     public abstract int sizeMessageDriven();
49     public abstract int removeSession(Session s);
50     public abstract int removeEntity(Entity e);
51     public abstract int removeMessageDriven(MessageDriven m);
52     
53     public void removeEjb(Ejb value){
54         
55         if(value instanceof Entity){
56             removeEntity((Entity) value);
57         }
58         else if(value instanceof Session){
59             removeSession((Session) value);
60         }
61         else if(value instanceof MessageDriven){
62             removeMessageDriven((MessageDriven) value);
63         }
64         
65         
66     }
67     public Ejb[] getEjbs(){
68         int sizeEntity = sizeEntity();
69         int sizeSession = sizeSession();
70         int sizeMessageDriven = sizeMessageDriven();
71         int size = sizeEntity + sizeSession + sizeMessageDriven;
72         
73         Ejb[] ejbs = new Ejb[size];
74         Entity[] enBeans = getEntity();
75         Session[] ssbeans = getSession();
76         MessageDriven[] mdbeans = getMessageDriven();
77         int addindex=0;
78         for(int i=0; i<sizeEntity ; i++){
79             ejbs[addindex] = (Ejb)enBeans[i];
80             addindex++;
81         }
82         for(int j=0; j<sizeSession ; j++){
83             ejbs[addindex] = (Ejb)ssbeans[j];
84             addindex++;
85         }
86         
87         for(int j=0; j<sizeMessageDriven ; j++){
88             ejbs[addindex] = (Ejb)mdbeans[j];
89             addindex++;
90         }
91         return ejbs;
92     }
93     
94 }
95
Popular Tags