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.test.profileservice.support; 23 24 import java.io.IOException; 25 26 import org.jboss.kernel.plugins.deployment.BasicKernelDeployer; 27 import org.jboss.profileservice.spi.Profile; 28 import org.jboss.profileservice.spi.ProfileKey; 29 import org.jboss.profileservice.spi.ProfileService; 30 import org.jboss.test.profileservice.simple1.ProfileServiceImpl; 31 32 public class Simple1PSBootstrap extends ProfileServiceBootstrap 33 { 34 private BasicKernelDeployer deployer; 35 protected ProfileService profileService; 36 37 public Simple1PSBootstrap() throws IOException 38 { 39 this("default"); 40 } 41 42 public Simple1PSBootstrap(String name) throws IOException 43 { 44 super(name); 45 profileService = new ProfileServiceImpl(); 46 } 47 48 49 public ProfileService getProfileService() 50 { 51 return profileService; 52 } 53 54 /** 55 * Get the named profile from the profile service 56 * TODO: who owns the VFS configuration 57 */ 58 protected void loadProfile(String name) throws Throwable 59 { 60 deployer = new BasicKernelDeployer(super.getKernel()); 61 62 // Load the named profile 63 ProfileKey key = new ProfileKey(name); 64 Profile profile = profileService.getProfile(key); 65 /* TODO 66 Deployment[] profileDeployments = profile.getDeployments(); 67 for(Deployment d : profileDeployments) 68 { 69 log.debug("Deploying: "+d); 70 AbstractKernelDeployment kernelDeployment = new AbstractKernelDeployment(); 71 kernelDeployment.setName(d.getName()); 72 73 // Setup the class loader from the deployment root URL/files 74 URL rootURL = d.getRootURL(); 75 VFSFactory factory = VFSFactoryLocator.getFactory(rootURL); 76 ReadOnlyVFS vfs = factory.getVFS(rootURL); 77 String[] searchCtxts = d.getFiles(); 78 VFSClassLoader cl = new VFSClassLoader(searchCtxts, vfs); 79 AbstractClassLoaderMetaData clMD = new AbstractClassLoaderMetaData(); 80 AbstractValueMetaData value = new AbstractValueMetaData(cl); 81 clMD.setClassLoader(value); 82 */ 83 /* 84 DeploymentBean<BeanMetaData>[] beans = d.getBeans(); 85 ArrayList<BeanMetaData> beanFactories = new ArrayList<BeanMetaData>(); 86 for(DeploymentBean<BeanMetaData> db: beans) 87 { 88 log.debug("Adding bean: "+db); 89 String beanName = db.getName(); 90 BeanMetaData kbean = db.getBeanMetaData(); 91 // TODO: what other metdata settings need to be set at this level? 92 kbean.setClassLoader(clMD); 93 beanFactories.add(kbean); 94 } 95 kernelDeployment.setBeans(beanFactories); // TODO ???? 96 */ 97 98 /* TODO 99 deployer.deploy(kernelDeployment); 100 } 101 */ 102 103 } 104 105 } 106