001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)RemoteJBIAdminCommandsFactory.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.ui.client;
030:
031: import com.sun.jbi.ui.common.JBIRemoteException;
032: import com.sun.jbi.ui.common.JBIResultXmlBuilder;
033: import com.sun.jbi.ui.common.JMXConnectionException;
034: import java.util.Properties;
035:
036: /** This class is a factory class to create the RemoteJBIAdminCommands implemenation.
037: *
038: * @author Sun Microsystems, Inc.
039: */
040:
041: public abstract class RemoteJBIAdminCommandsFactory {
042: /** property name for class to load */
043: public static final String FACTORY_IMPL_CLASS_PROP = "com.sun.jbi.ui.client.RemoteJBIAdminCommandsFactory";
044: /** if no property set, try load this impl class */
045: public static final String FACTORY_IMPL_CLASS = "com.sun.jbi.internal.ui.client.RemoteJBIAdminCommandsFactoryImpl";
046:
047: /**
048: * constructor
049: */
050: protected RemoteJBIAdminCommandsFactory() {
051: // check system properties and initailize the builders.
052: }
053:
054: /**
055: * Creates a Factory class depending on the system settings. The order it looks for
056: * creating the factory implementation is look for the system property
057: * com.sun.jbi.ui.ant.client.RemoteJBIAdminCommandsFactory for the class name to
058: * load and then to the standard com.sun.jbi.internal.ui.client.RemoteJBIAdminCommandsFactoryImpl
059: * or a default implementation com.sun.jbi.ui.ant.client.RemoteJBIAdminCommandsFactory.Impl
060: *
061: * @return The instance of the JBIAdminCommandsFactory
062: */
063: public static RemoteJBIAdminCommandsFactory newInstance() {
064: String factoryImplClass = System.getProperty(
065: FACTORY_IMPL_CLASS_PROP, FACTORY_IMPL_CLASS);
066:
067: RemoteJBIAdminCommandsFactory impl = null;
068: try {
069: impl = (RemoteJBIAdminCommandsFactory) Class.forName(
070: factoryImplClass).newInstance();
071: } catch (Exception ex) {
072: // any exception, just load the default class
073: impl = new DefaultFactoryImpl();
074: }
075: return impl;
076: }
077:
078: /** get jbi client interface
079: * @param connProps Connection Properties
080: * @throws JMXConnectionException on error
081: * @return result
082: */
083: public abstract RemoteJBIAdminCommands createRemoteJBIAdminCommands(
084: Properties connProps) throws JMXConnectionException;
085:
086: /**
087: * This class is a default factory implementation.
088: */
089: private static class DefaultFactoryImpl extends
090: RemoteJBIAdminCommandsFactory {
091: /**
092: * constructor.
093: */
094: public DefaultFactoryImpl() {
095: super ();
096: }
097:
098: /** get jbi client interface
099: * @param connProps Connection Properties
100: * @throws JMXConnectionException on error
101: * @return result
102: */
103: public RemoteJBIAdminCommands createRemoteJBIAdminCommands(
104: Properties connProps) throws JMXConnectionException {
105: return new DefaultRemoteJBIAdminCommandsImpl(connProps);
106: }
107:
108: /**
109: * string value of the object
110: * @return string value of the object
111: */
112: public String toString() {
113: return "Default RemoteJBIAdminCommandsFactory Implementation";
114: }
115: }
116:
117: /**
118: * Default implementation of the RemoteJBIAdminCommands
119: */
120: public static class DefaultRemoteJBIAdminCommandsImpl extends
121: AbstractJMXClient implements RemoteJBIAdminCommands {
122: /** host for jmx connection */
123: private String mHost = null;
124:
125: /**
126: * constructor
127: * @param connProps Properties object
128: */
129: public DefaultRemoteJBIAdminCommandsImpl(Properties connProps) {
130: super ();
131: this .mHost = connProps
132: .getProperty(JMXConnectionProperties.HOST_PROP);
133:
134: }
135:
136: /**
137: * remotely deploys service assembly by uploading the file to server side.
138: * Not supported in RI. Using this interface throws unsupported exception in RI.
139: * @return result as a management message xml text
140: * @param zipFilePath fie path
141: * @throws JBIRemoteException on error
142: */
143: public String remoteDeployServiceAssembly(String zipFilePath)
144: throws JBIRemoteException {
145: String msg = JBIResultXmlBuilder.createFailedJbiResultXml(
146: getI18NBundle(),
147: "jbi.ui.client.remote.deploy.not.supported",
148: new Object[] { this .mHost });
149: throw new JBIRemoteException(
150: new UnsupportedOperationException(msg));
151: }
152:
153: /**
154: * remotely install service engine or binding component by uploading the file server side
155: * Not supported in RI. Using this interface throws unsupported exception in RI.
156: * @return result as a management message xml text
157: * @param paramProps Properties object contains name,value pair for parameters.
158: * @param zipFilePath fie path
159: * @throws JBIRemoteException on error
160: */
161: public String remoteInstallComponent(String zipFilePath,
162: Properties params) throws JBIRemoteException {
163: String msg = null;
164: if (params != null && params.size() > 0) {
165: msg = JBIResultXmlBuilder
166: .createFailedJbiResultXml(
167: getI18NBundle(),
168: "jbi.ui.client.remote.install.component.with.params.not.supported",
169: new Object[] { this .mHost });
170:
171: } else {
172: msg = JBIResultXmlBuilder
173: .createFailedJbiResultXml(
174: getI18NBundle(),
175: "jbi.ui.client.remote.install.component.not.supported",
176: new Object[] { this .mHost });
177: }
178:
179: throw new JBIRemoteException(
180: new UnsupportedOperationException(msg));
181: }
182:
183: /**
184: * remotely install service engine or binding component by uploading the file server side
185: * Not supported in RI. Using this interface throws unsupported exception in RI.
186: * @return result as a management message xml text
187: * @param zipFilePath fie path
188: * @throws JBIRemoteException on error
189: */
190: public String remoteInstallComponent(String zipFilePath)
191: throws JBIRemoteException {
192: String msg = JBIResultXmlBuilder
193: .createFailedJbiResultXml(
194: getI18NBundle(),
195: "jbi.ui.client.remote.install.component.not.supported",
196: new Object[] { this .mHost });
197:
198: throw new JBIRemoteException(
199: new UnsupportedOperationException(msg));
200: }
201:
202: /**
203: * remotely install shared library by uploading the file to server side
204: * Not supported in RI. Using this interface throws unsupported exception in RI.
205: * @return result as a management message xml text
206: * @param zipFilePath fie path
207: * @throws JBIRemoteException on error
208: */
209: public String remoteInstallSharedLibrary(String zipFilePath)
210: throws JBIRemoteException {
211: String msg = JBIResultXmlBuilder.createFailedJbiResultXml(
212: getI18NBundle(),
213: "jbi.ui.client.remote.install.slib.not.supported",
214: new Object[] { this .mHost });
215:
216: throw new JBIRemoteException(
217: new UnsupportedOperationException(msg));
218: }
219:
220: }
221:
222: }
|