You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2004/03/09 19:00:57 UTC
cvs commit: incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service GBeanAdapter.java GBeanHelper.java ServiceGBeanAdapter.java ServiceConfigBuilder.java
djencks 2004/03/09 10:00:57
Modified: modules/deployment/src/java/org/apache/geronimo/deployment/service
ServiceConfigBuilder.java
Added: modules/deployment/src/java/org/apache/geronimo/deployment/service
GBeanAdapter.java GBeanHelper.java
ServiceGBeanAdapter.java
Log:
use adapters to schema specific xmlbean classes to allow code reuse
Revision Changes Path
1.10 +7 -35 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Index: ServiceConfigBuilder.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ServiceConfigBuilder.java 25 Feb 2004 09:57:38 -0000 1.9
+++ ServiceConfigBuilder.java 9 Mar 2004 18:00:57 -0000 1.10
@@ -32,19 +32,17 @@
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
+
import javax.management.MalformedObjectNameException;
import org.apache.geronimo.deployment.ConfigurationBuilder;
import org.apache.geronimo.deployment.DeploymentContext;
import org.apache.geronimo.deployment.DeploymentException;
-import org.apache.geronimo.deployment.xbeans.AttributeType;
import org.apache.geronimo.deployment.xbeans.ConfigurationDocument;
import org.apache.geronimo.deployment.xbeans.ConfigurationType;
import org.apache.geronimo.deployment.xbeans.DependencyType;
import org.apache.geronimo.deployment.xbeans.ExecutableType;
import org.apache.geronimo.deployment.xbeans.GbeanType;
-import org.apache.geronimo.deployment.xbeans.ReferenceType;
-import org.apache.geronimo.deployment.xbeans.ReferencesType;
import org.apache.geronimo.deployment.xbeans.ServiceDocument;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
@@ -152,7 +150,11 @@
addIncludes(context, configType);
addDependencies(context, configType.getDependencyArray());
ClassLoader cl = context.getClassLoader(repository);
- addGBeans(context, configType.getGbeanArray(), cl);
+ GbeanType[] gbeans = configType.getGbeanArray();
+ for (int i = 0; i < gbeans.length; i++) {
+ GBeanHelper.addGbean(new ServiceGBeanAdapter(gbeans[i]), cl, context);
+
+ }
context.close();
os.flush();
}
@@ -231,36 +233,6 @@
}
}
return uri;
- }
-
- private void addGBeans(DeploymentContext context, GbeanType[] gbeans, ClassLoader cl) throws DeploymentException {
- for (int i = 0; i < gbeans.length; i++) {
- GbeanType gbean = gbeans[i];
- GBeanBuilder builder = new GBeanBuilder(gbean.getName(), cl, gbean.getClass1());
-
- // set up attributes
- AttributeType[] attrs = gbean.getAttributeArray();
- for (int j = 0; j < attrs.length; j++) {
- AttributeType attr = attrs[j];
- builder.setAttribute(attr.getName(), attr.getType(), attr.getStringValue());
- }
-
- // set up all single pattern references
- ReferenceType[] refs = gbean.getReferenceArray();
- for (int j = 0; j < refs.length; j++) {
- ReferenceType ref = refs[j];
- builder.setReference(ref.getName(), ref.getStringValue());
- }
-
- // set up app multi-patterned references
- ReferencesType[] refs2 = gbean.getReferencesArray();
- for (int j = 0; j < refs2.length; j++) {
- ReferencesType type = refs2[j];
- builder.setReference(type.getName(), type.getPatternArray());
- }
-
- context.addGBean(builder.getName(), builder.getGBean());
- }
}
public static final GBeanInfo GBEAN_INFO;
1.1 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanAdapter.java
Index: GBeanAdapter.java
===================================================================
package org.apache.geronimo.deployment.service;
/**
* adapter interface for multiple copies of xml gbean type.
*
* @version $Revision: 1.1 $ $Date: 2004/03/09 18:00:57 $
*
* */
public interface GBeanAdapter {
String getName();
String getClass1();
int getAttributeCount();
String getAttributeName(int i);
String getAttributeType(int i);
String getAttributeStringValue(int i);
int getReferenceCount();
String getReferenceName(int i);
String getReferenceStringValue(int i);
int getReferencesCount();
String getReferencesName(int i);
String[] getReferencesPatternArray(int i);
}
1.1 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
Index: GBeanHelper.java
===================================================================
/**
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.geronimo.deployment.service;
import org.apache.geronimo.deployment.DeploymentContext;
import org.apache.geronimo.deployment.DeploymentException;
/**
*
*
* @version $Revision: 1.1 $ $Date: 2004/03/09 18:00:57 $
*
* */
public class GBeanHelper {
public static void addGbean(GBeanAdapter gbean, ClassLoader cl, DeploymentContext context) throws DeploymentException {
GBeanBuilder builder = new GBeanBuilder(gbean.getName(), cl, gbean.getClass1());
// set up attributes
for (int j = 0; j < gbean.getAttributeCount(); j++) {
builder.setAttribute(gbean.getAttributeName(j), gbean.getAttributeType(j), gbean.getAttributeStringValue(j));
}
// set up all single pattern references
for (int j = 0; j < gbean.getReferenceCount(); j++) {
builder.setReference(gbean.getReferenceName(j), gbean.getReferenceStringValue(j));
}
// set up app multi-patterned references
for (int j = 0; j < gbean.getReferencesCount(); j++) {
builder.setReference(gbean.getReferencesName(j), gbean.getReferencesPatternArray(j));
}
context.addGBean(builder.getName(), builder.getGBean());
}
}
1.1 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceGBeanAdapter.java
Index: ServiceGBeanAdapter.java
===================================================================
/**
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.geronimo.deployment.service;
import org.apache.geronimo.deployment.xbeans.GbeanType;
/**
*
*
* @version $Revision: 1.1 $ $Date: 2004/03/09 18:00:57 $
*
* */
public class ServiceGBeanAdapter implements GBeanAdapter {
private final GbeanType gbean;
public ServiceGBeanAdapter(GbeanType gbean) {
this.gbean = gbean;
}
public String getName() {
return gbean.getName();
}
public String getClass1() {
return gbean.getClass1();
}
public int getAttributeCount() {
return gbean.getAttributeArray().length;
}
public String getAttributeName(int i) {
return gbean.getAttributeArray(i).getName();
}
public String getAttributeType(int i) {
return gbean.getAttributeArray(i).getType();
}
public String getAttributeStringValue(int i) {
return gbean.getAttributeArray(i).getStringValue();
}
public int getReferenceCount() {
return gbean.getReferenceArray().length;
}
public String getReferenceName(int i) {
return gbean.getReferenceArray(i).getName();
}
public String getReferenceStringValue(int i) {
return gbean.getReferenceArray(i).getStringValue();
}
public int getReferencesCount() {
return gbean.getReferencesArray().length;
}
public String getReferencesName(int i) {
return gbean.getReferencesArray(i).getName();
}
public String[] getReferencesPatternArray(int i) {
return gbean.getReferencesArray(i).getPatternArray();
}
}