KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > profileservice > simple1 > ProfileImpl


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
23 package org.jboss.test.profileservice.simple1;
24
25 import java.io.IOException JavaDoc;
26 import java.net.URL JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.Collections JavaDoc;
29 import java.util.HashMap JavaDoc;
30 import java.util.Map JavaDoc;
31
32 import org.jboss.deployers.spi.structure.DeploymentContext;
33 import org.jboss.profileservice.spi.DeploymentTemplate;
34 import org.jboss.profileservice.spi.NoSuchDeploymentException;
35 import org.jboss.profileservice.spi.Profile;
36
37 /**
38  * A test profile with a fixed default deployment. The contents of the
39  * deployments are expected to be in the
40  *
41  * @author Scott.Stark@jboss.org
42  * @version $Revision$
43  */

44 public class ProfileImpl
45    implements Profile
46 {
47    private HashMap JavaDoc<String JavaDoc, DeploymentContext> deployments;
48
49    public ProfileImpl() throws IOException JavaDoc
50    {
51       deployments = new HashMap JavaDoc<String JavaDoc, DeploymentContext>();
52       String JavaDoc deployDir = SecurityActions.getSystemProperty("jbosstest.deploy.dir");
53       URL JavaDoc libURL;
54       if( deployDir == null )
55       {
56          // Used codesource + ../lib
57
URL JavaDoc classes = getClass().getProtectionDomain().getCodeSource().getLocation();
58          libURL = new URL JavaDoc(classes, "../lib/");
59       }
60       else
61       {
62          libURL = new URL JavaDoc(deployDir);
63       }
64
65       /* TODO DeploymentImpl p0 = new DeploymentImpl();
66       p0.setName("CoreServices");
67       p0.setRootURL(libURL);
68       String[] files = {"p0.jar"};
69       p0.setFiles(files); */

70       /*
71       ArrayList<DeploymentBean> beans = new ArrayList<DeploymentBean>();
72       // NamingService
73       String nsName = "TheNamingService";
74       String nsType = "org.jboss.test.profileservice.profiles.p0.beans.NamingService";
75       DeploymentBeanImpl<BeanMetaData> ns = new DeploymentBeanImpl<BeanMetaData>(nsName, nsType);
76       AbstractBeanMetaData nsMetaData = new AbstractBeanMetaData(nsName, nsType);
77       ns.setBeanMetaData(nsMetaData);
78       beans.add(ns);
79       // JTA
80       String txName = "TheTxMgr";
81       String txType = "org.jboss.test.profileservice.profiles.p0.beans.TxMgr";
82       DeploymentBeanImpl<BeanMetaData> txMgr = new DeploymentBeanImpl<BeanMetaData>(txName, txType);
83       AbstractBeanMetaData txMetaData = new AbstractBeanMetaData(txName, txType);
84       HashSet<DemandMetaData> txDemands = new HashSet<DemandMetaData>();
85       txDemands.add(new AbstractDemandMetaData(nsName));
86       txMetaData.setDemands(txDemands);
87       txMgr.setBeanMetaData(txMetaData);
88       beans.add(txMgr);
89       // JCA
90       String jcaName = "TheJCAMgr";
91       String jcaType = "org.jboss.test.profileservice.profiles.p0.beans.JCAMgr";
92       DeploymentBeanImpl<BeanMetaData> jca = new DeploymentBeanImpl<BeanMetaData>(jcaName, jcaType);
93       AbstractBeanMetaData jcaMetaData = new AbstractBeanMetaData(jcaName, jcaType);
94       HashSet<DemandMetaData> jcaDemands = new HashSet<DemandMetaData>();
95       jcaDemands.add(new AbstractDemandMetaData(nsName));
96       jcaDemands.add(new AbstractDemandMetaData(txName));
97       jcaMetaData.setDemands(jcaDemands);
98       jca.setBeanMetaData(jcaMetaData);
99       beans.add(jca);
100       */

101       /* TODO deployments.put("CoreServices", p0); */
102    }
103
104    public String JavaDoc getVersion()
105    {
106       return "1.0.0";
107    }
108
109    public DeploymentTemplate getTemplate(String JavaDoc name)
110    {
111       return null;
112    }
113
114    public void addDeployment(DeploymentContext d)
115    {
116       throw new UnsupportedOperationException JavaDoc("simple1 is read-only");
117    }
118
119    public void removeDeployment(String JavaDoc name)
120    {
121       throw new UnsupportedOperationException JavaDoc("simple1 is read-only");
122    }
123
124    public Collection JavaDoc<DeploymentContext> getDeployments()
125    {
126       return Collections.unmodifiableCollection(deployments.values());
127    }
128
129    public Map JavaDoc<String JavaDoc, Object JavaDoc> getConfig()
130    {
131       return null;
132    }
133
134    public DeploymentContext getDeployment(String JavaDoc name)
135       throws NoSuchDeploymentException
136    {
137       DeploymentContext d = deployments.get(name);
138       if( d == null )
139          throw new NoSuchDeploymentException(name);
140       return d;
141    }
142
143    public void addBootstrap(DeploymentContext d)
144    {
145       // @todo addBootstrap
146
throw new org.jboss.util.NotImplementedException("addBootstrap");
147    }
148
149    public void addDeployer(DeploymentContext d)
150    {
151       // @todo addDeployer
152
throw new org.jboss.util.NotImplementedException("addDeployer");
153    }
154
155    public DeploymentContext getBootstrap(String JavaDoc name) throws NoSuchDeploymentException
156    {
157       // @todo getBootstrap
158
throw new org.jboss.util.NotImplementedException("getBootstrap");
159    }
160
161    public Collection JavaDoc<DeploymentContext> getBootstraps()
162    {
163       // @todo getBootstraps
164
throw new org.jboss.util.NotImplementedException("getBootstraps");
165    }
166
167    public DeploymentContext getDeployer(String JavaDoc name) throws NoSuchDeploymentException
168    {
169       // @todo getDeployer
170
throw new org.jboss.util.NotImplementedException("getDeployer");
171    }
172
173    public Collection JavaDoc<DeploymentContext> getDeployers()
174    {
175       // @todo getDeployers
176
throw new org.jboss.util.NotImplementedException("getDeployers");
177    }
178
179    public void removeBootstrap(String JavaDoc name)
180    {
181       // @todo removeBootstrap
182
throw new org.jboss.util.NotImplementedException("removeBootstrap");
183    }
184
185    public void removeDeployer(String JavaDoc name)
186    {
187       // @todo removeDeployer
188
throw new org.jboss.util.NotImplementedException("removeDeployer");
189    }
190 }
191
Popular Tags