From dev-return-9733-apmail-geronimo-dev-archive=geronimo.apache.org@geronimo.apache.org Tue Nov 02 03:56:49 2004 Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 74987 invoked from network); 2 Nov 2004 03:56:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Nov 2004 03:56:49 -0000 Received: (qmail 84140 invoked by uid 500); 2 Nov 2004 03:56:14 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 84095 invoked by uid 500); 2 Nov 2004 03:56:14 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@geronimo.apache.org Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 84082 invoked by uid 99); 2 Nov 2004 03:56:13 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [166.84.147.110] (HELO alan.toolazydogs.com) (166.84.147.110) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 01 Nov 2004 19:56:13 -0800 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: svn commit: rev 56340 - in geronimo/trunk/modules: deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/service kernel/src/java/org/apache/geronimo/gbean kernel/src/java/org/apache/geronimo/gbean/jmx ke X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Mon, 1 Nov 2004 22:53:20 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: svn commit: rev 56340 - in geronimo/trunk/modules: deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/service kernel/src/java/org/apache/geronimo/gbean kernel/src/java/org/apache/geronimo/gbean/jmx ke Thread-Index: AcTAjo6QxHHVDuPVR2Cg2IIht+QDuAAAN1ZA From: "Alan D. Cabrera" To: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I kinda thought that it would be nice to have a mock module. If it goes into tests, then it's not available for other modules. Regards, Alan > -----Original Message----- > From: David Jencks [mailto:david_jencks@yahoo.com] > Sent: Monday, November 01, 2004 10:49 PM > To: dev@geronimo.apache.org > Subject: Re: svn commit: rev 56340 - in geronimo/trunk/modules: > deployment/src/java/org/apache/geronimo/deployment > deployment/src/java/org/apache/geronimo/deployment/service > kernel/src/java/org/apache/geronimo/gbean > kernel/src/java/org/apache/geronimo/gbean/jmx ke >=20 > Is MockGBean really supposed to be in java rather than test? >=20 > david jencks >=20 > On Nov 1, 2004, at 7:45 PM, dain@apache.org wrote: >=20 > > Author: dain > > Date: Mon Nov 1 19:45:48 2004 > > New Revision: 56340 > > > > Added: > > > > geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/ > > configuration/MockGBean.java > > Modified: > > > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/DeploymentContext.java > > > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanBuilder.java > > > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanHelper.java > > > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/ > > GBeanData.java > > > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ > > GBeanMBean.java > > > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > Kernel.java > > > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > config/Configuration.java > > > > geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/ > > configuration/LocalConfigStoreTest.java > > Log: > > Moved object name into GBeanData > > > > > > Modified: > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/DeploymentContext.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/DeploymentContext.java (original) > > +++ > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/DeploymentContext.java Mon Nov 1 19:45:48 2004 > > @@ -155,9 +155,9 @@ > > gbeans.put(name, gbean); > > } > > > > - public void addGBean(ObjectName name, GBeanData gbean, > > ClassLoader classLoader) { > > + public void addGBean(GBeanData gbean, ClassLoader classLoader) { > > GBeanMBean gbeanMBean =3D new GBeanMBean(gbean, = classLoader); > > - gbeans.put(name, gbeanMBean); > > + gbeans.put(gbean.getName(), gbeanMBean); > > } > > > > public void addDependency(URI uri) { > > > > Modified: > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanBuilder.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanBuilder.java (original) > > +++ > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanBuilder.java Mon Nov 1 19:45:48 2004 > > @@ -35,13 +35,13 @@ > > * @version $Rev$ $Date$ > > */ > > public class GBeanBuilder { > > - private final ObjectName name; > > private final GBeanData gbean; > > private final ClassLoader classLoader; > > > > public GBeanBuilder(String name, ClassLoader classLoader, String > > className) throws DeploymentException { > > + ObjectName objectName; > > try { > > - this.name =3D new ObjectName(name); > > + objectName =3D new ObjectName(name); > > } catch (MalformedObjectNameException e) { > > throw new DeploymentException("Invalid ObjectName: " + > > name, e); > > } > > @@ -49,7 +49,7 @@ > > this.classLoader =3D classLoader; > > > > try { > > - gbean =3D new = GBeanData(GBeanInfo.getGBeanInfo(className, > > classLoader)); > > + gbean =3D new GBeanData(objectName, > > GBeanInfo.getGBeanInfo(className, classLoader)); > > } catch (Exception e) { > > throw new DeploymentException("Unable to create GBean > > from class " + className, e); > > } > > @@ -95,9 +95,5 @@ > > > > public GBeanData getGBeanData() { > > return gbean; > > - } > > - > > - public ObjectName getName() { > > - return name; > > } > > } > > > > Modified: > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanHelper.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanHelper.java (original) > > +++ > > geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/ > > deployment/service/GBeanHelper.java Mon Nov 1 19:45:48 2004 > > @@ -45,6 +45,6 @@ > > builder.setReference(gbean.getReferencesName(j), > > gbean.getReferencesPatternArray(j)); > > } > > > > - context.addGBean(builder.getName(), builder.getGBeanData(), > > cl); > > + context.addGBean(builder.getGBeanData(), cl); > > } > > } > > > > Modified: > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/ > > GBeanData.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/ > > GBeanData.java (original) > > +++ > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/ > > GBeanData.java Mon Nov 1 19:45:48 2004 > > @@ -32,6 +32,7 @@ > > * @version $Rev$ $Date$ > > */ > > public class GBeanData implements Externalizable { > > + private ObjectName name; > > private GBeanInfo gbeanInfo; > > private final Map attributes; > > private final Map references; > > @@ -41,18 +42,28 @@ > > references =3D new HashMap(); > > } > > > > - public GBeanData(GBeanInfo gbeanInfo) { > > + public GBeanData(ObjectName name, GBeanInfo gbeanInfo) { > > + this.name =3D name; > > this.gbeanInfo =3D gbeanInfo; > > attributes =3D new HashMap(); > > references =3D new HashMap(); > > } > > > > public GBeanData(GBeanData gbeanData) { > > + name =3D gbeanData.name; > > gbeanInfo =3D gbeanData.gbeanInfo; > > attributes =3D new HashMap(gbeanData.attributes); > > references =3D new HashMap(gbeanData.references); > > } > > > > + public ObjectName getName() { > > + return name; > > + } > > + > > + public void setName(ObjectName name) { > > + this.name =3D name; > > + } > > + > > public GBeanInfo getGBeanInfo() { > > return gbeanInfo; > > } > > @@ -101,6 +112,9 @@ > > // write the gbean info > > out.writeObject(gbeanInfo); > > > > + // write the object name > > + out.writeObject(name); > > + > > // write the attributes > > out.writeInt(attributes.size()); > > for (Iterator iterator =3D = attributes.entrySet().iterator(); > > iterator.hasNext();) { > > @@ -135,16 +149,29 @@ > > // read the gbean info > > gbeanInfo =3D (GBeanInfo) in.readObject(); > > > > - // read the attributes > > - int attributeCount =3D in.readInt(); > > - for (int i =3D 0; i < attributeCount; i++) { > > - setAttribute((String) in.readObject(), in.readObject()); > > + // read the object name > > + try { > > + name =3D (ObjectName) in.readObject(); > > + } catch (IOException e) { > > + throw (IOException) new IOException("Unable to > > deserialize ObjectName for GBeanData of type " + > > gbeanInfo.getClassName()).initCause(e); > > } > > > > - // read the references > > - int endpointCount =3D in.readInt(); > > - for (int i =3D 0; i < endpointCount; i++) { > > - setReferencePatterns((String) in.readObject(), (Set) > > in.readObject()); > > + try { > > + // read the attributes > > + int attributeCount =3D in.readInt(); > > + for (int i =3D 0; i < attributeCount; i++) { > > + setAttribute((String) in.readObject(), > > in.readObject()); > > + } > > + > > + // read the references > > + int endpointCount =3D in.readInt(); > > + for (int i =3D 0; i < endpointCount; i++) { > > + setReferencePatterns((String) in.readObject(), (Set) > > in.readObject()); > > + } > > + } catch (IOException e) { > > + throw (IOException) new IOException("Unable to > > deserialize GBeanData " + name).initCause(e); > > + } catch (ClassNotFoundException e) { > > + throw new ClassNotFoundException("Unable to find class > > used in GBeanData " + name, e); > > } > > } > > } > > > > Modified: > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ > > GBeanMBean.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ > > GBeanMBean.java (original) > > +++ > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ > > GBeanMBean.java Mon Nov 1 19:45:48 2004 > > @@ -684,10 +684,7 @@ > > * @return the gbean data > > */ > > public GBeanData getGBeanData() { > > - GBeanData gbeanData =3D new GBeanData(); > > - > > - // add the gbean info > > - gbeanData.setGBeanInfo(gbeanInfo); > > + GBeanData gbeanData =3D new GBeanData(objectName, = gbeanInfo); > > > > // add the attributes > > for (int i =3D 0; i < attributes.length; i++) { > > > > Modified: > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > Kernel.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > Kernel.java (original) > > +++ > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > Kernel.java Mon Nov 1 19:45:48 2004 > > @@ -282,14 +282,14 @@ > > } > > } > > > > - public void loadGBean(ObjectName name, GBeanData gbeanData, > > ClassLoader classLoader) throws InstanceAlreadyExistsException, > > InvalidConfigException { > > + public void loadGBean(GBeanData gbeanData, ClassLoader > > classLoader) throws InstanceAlreadyExistsException, > > InvalidConfigException { > > try { > > GBeanMBean gbean =3D new GBeanMBean(gbeanData, classLoader); > > - mbServer.registerMBean(gbean, name); > > + mbServer.registerMBean(gbean, gbeanData.getName()); > > } catch (MBeanRegistrationException e) { > > - throw new InvalidConfigException("Invalid GBean > > configuration for " + name, e); > > + throw new InvalidConfigException("Invalid GBean > > configuration for " + gbeanData.getName(), e); > > } catch (NotCompliantMBeanException e) { > > - throw new InvalidConfigException("Invalid GBean > > configuration for " + name, e); > > + throw new InvalidConfigException("Invalid GBean > > configuration for " + gbeanData.getName(), e); > > } > > } > > > > > > Modified: > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > config/Configuration.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > config/Configuration.java (original) > > +++ > > geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > > config/Configuration.java Mon Nov 1 19:45:48 2004 > > @@ -349,18 +349,15 @@ > > */ > > private static Map loadGBeans(byte[] gbeanState, ClassLoader cl) > > throws InvalidConfigException { > > Map gbeans =3D new HashMap(); > > - ObjectName objectName =3D null; > > try { > > ObjectInputStream ois =3D new ConfigInputStream(new > > ByteArrayInputStream(gbeanState), cl); > > try { > > while (true) { > > - objectName =3D (ObjectName) ois.readObject(); > > - > > GBeanData gbeanData =3D new GBeanData(); > > gbeanData.readExternal(ois); > > GBeanMBean gbean =3D new GBeanMBean(gbeanData, cl); > > > > - gbeans.put(objectName, gbean); > > + gbeans.put(gbeanData.getName(), gbean); > > } > > } catch (EOFException e) { > > // ok > > @@ -369,8 +366,7 @@ > > } > > return gbeans; > > } catch (Exception e) { > > - throw new InvalidConfigException("Unable to deserialize > > GBeanState" + > > - (objectName =3D=3D null ? "" : " " + = objectName), e); > > + throw new InvalidConfigException("Unable to deserialize > > GBeanState", e); > > } > > } > > > > @@ -401,8 +397,11 @@ > > ObjectName objectName =3D (ObjectName) entry.getKey(); > > GBeanMBean gbean =3D (GBeanMBean) entry.getValue(); > > try { > > - oos.writeObject(objectName); > > - gbean.getGBeanData().writeExternal(oos); > > + GBeanData gbeanData =3D gbean.getGBeanData(); > > + // todo we must explicitly set the bean name here > > from the gbean key because the gbean mbean may > > + // not have been brought online, so the object namve > > in the gbean mbean will be null > > + gbeanData.setName(objectName); > > + gbeanData.writeExternal(oos); > > } catch (Exception e) { > > throw new InvalidConfigException("Unable to serialize > > GBeanState for " + objectName, e); > > } > > > > Added: > > geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/ > > configuration/MockGBean.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- (empty file) > > +++ > > geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/ > > configuration/MockGBean.java Mon Nov 1 19:45:48 2004 > > @@ -0,0 +1,49 @@ > > +/** > > + * > > + * Copyright 2003-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.system.configuration; > > + > > +import org.apache.geronimo.gbean.GBeanInfo; > > +import org.apache.geronimo.gbean.GBeanInfoBuilder; > > + > > +/** > > + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 > > Sep 2004) $ > > + */ > > +public class MockGBean { > > + private static final GBeanInfo GBEAN_INFO; > > + > > + private String value; > > + > > + public String getValue() { > > + return value; > > + } > > + > > + public void setValue(String value) { > > + this.value =3D value; > > + } > > + > > + public static GBeanInfo getGBeanInfo() { > > + return GBEAN_INFO; > > + } > > + > > + static { > > + GBeanInfoBuilder infoBuilder =3D new > > GBeanInfoBuilder("MockGBean", MockGBean.class); > > + infoBuilder.addAttribute("value", String.class, true); > > + > > + GBEAN_INFO =3D infoBuilder.getBeanInfo(); > > + } > > +} > > > > Modified: > > geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/ > > configuration/LocalConfigStoreTest.java > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D > > --- > > geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/ > > configuration/LocalConfigStoreTest.java (original) > > +++ > > geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/ > > configuration/LocalConfigStoreTest.java Mon Nov 1 19:45:48 2004 > > @@ -130,10 +130,10 @@ > > root.mkdir(); > > > > storeName =3D new > > ObjectName("geronimo.test: > > role=3DConfigurationStore,name=3DLocalConfigStore"); > > - GBeanData store =3D new > > GBeanData(LocalConfigStore.getGBeanInfo()); > > + GBeanData store =3D new GBeanData(storeName, > > LocalConfigStore.getGBeanInfo()); > > store.setAttribute("root", root.toURI()); > > > > - kernel.loadGBean(storeName, store, > > getClass().getClassLoader()); > > + kernel.loadGBean(store, getClass().getClassLoader()); > > kernel.startGBean(storeName); > > > > GBeanMBean gbean =3D new > > GBeanMBean(Configuration.GBEAN_INFO); > > >=20