01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.deployment.plugin.factories;
17:
18: import javax.enterprise.deploy.spi.DeploymentManager;
19: import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
20: import javax.enterprise.deploy.spi.factories.DeploymentFactory;
21:
22: import org.apache.geronimo.kernel.Kernel;
23: import org.apache.geronimo.kernel.util.MainBootstrapper;
24:
25: /**
26: *
27: * @version $Rev: 503905 $ $Date: 2007-02-06 09:20:49 +1100 (Tue, 06 Feb 2007) $
28: */
29: public class DeploymentFactoryBootstrapper implements DeploymentFactory {
30: private final Kernel kernel;
31: private final DeploymentFactory delegate;
32:
33: public DeploymentFactoryBootstrapper()
34: throws DeploymentManagerCreationException {
35: kernel = newKernel();
36:
37: try {
38: delegate = (DeploymentFactory) kernel
39: .getGBean(DeploymentFactory.class);
40: } catch (Exception e) {
41: throw (DeploymentManagerCreationException) new DeploymentManagerCreationException(
42: "See nested").initCause(e);
43: }
44: }
45:
46: public DeploymentManager getDeploymentManager(String uri,
47: String username, String password)
48: throws DeploymentManagerCreationException {
49: return delegate.getDeploymentManager(uri, username, password);
50: }
51:
52: public DeploymentManager getDisconnectedDeploymentManager(String uri)
53: throws DeploymentManagerCreationException {
54: return delegate.getDisconnectedDeploymentManager(uri);
55: }
56:
57: public String getDisplayName() {
58: return delegate.getDisplayName();
59: }
60:
61: public String getProductVersion() {
62: return delegate.getProductVersion();
63: }
64:
65: public boolean handlesURI(String uri) {
66: return delegate.handlesURI(uri);
67: }
68:
69: protected Kernel newKernel()
70: throws DeploymentManagerCreationException {
71: ClassLoader classLoader = DeploymentFactoryBootstrapper.class
72: .getClassLoader();
73:
74: MainBootstrapper bootstrapper = new MainBootstrapper();
75: try {
76: bootstrapper.bootKernel();
77: bootstrapper.loadBootConfiguration(classLoader);
78: bootstrapper.loadPersistentConfigurations();
79: } catch (Exception e) {
80: throw (DeploymentManagerCreationException) new DeploymentManagerCreationException(
81: "See nested").initCause(e);
82: }
83: return bootstrapper.getKernel();
84: }
85:
86: }
|