geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r383682 [4/5] - in /geronimo/branches/1.1/modules: connector/src/test/org/apache/geronimo/connector/ connector/src/test/org/apache/geronimo/connector/outbound/ deployment/src/java/org/apache/geronimo/deployment/ j2ee/src/java/org/apache/ger...
Date Mon, 06 Mar 2006 21:44:37 GMT
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java Mon Mar  6 13:44:29 2006
@@ -30,6 +30,7 @@
 import java.net.URI;
 import java.net.MalformedURLException;
 import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
 
 import junit.framework.TestCase;
 import org.apache.geronimo.kernel.repository.Environment;
@@ -43,6 +44,8 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.AbstractName;
 
 /**
  * @version $Rev$ $Date$
@@ -61,12 +64,12 @@
         assertTrue(configurationManager.isLoaded(artifact3));
         assertTrue(configurationManager.isLoaded(artifact2));
         assertTrue(configurationManager.isLoaded(artifact1));
-        assertTrue(kernel.isLoaded(Configuration.getConfigurationObjectName(artifact3))) ;
-        assertTrue(kernel.isLoaded(Configuration.getConfigurationObjectName(artifact2))) ;
-        assertTrue(kernel.isLoaded(Configuration.getConfigurationObjectName(artifact1))) ;
-        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(Configuration.getConfigurationObjectName(artifact3))) ;
-        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(Configuration.getConfigurationObjectName(artifact2))) ;
-        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(Configuration.getConfigurationObjectName(artifact1))) ;
+        assertTrue(kernel.isLoaded(Configuration.getConfigurationAbstractName(artifact3))) ;
+        assertTrue(kernel.isLoaded(Configuration.getConfigurationAbstractName(artifact2))) ;
+        assertTrue(kernel.isLoaded(Configuration.getConfigurationAbstractName(artifact1))) ;
+        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(Configuration.getConfigurationAbstractName(artifact3))) ;
+        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(Configuration.getConfigurationAbstractName(artifact2))) ;
+        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(Configuration.getConfigurationAbstractName(artifact1))) ;
     }
 
     protected void setUp() throws Exception {
@@ -75,12 +78,11 @@
         kernel = KernelFactory.newInstance().createKernel("test");
         kernel.boot();
 
-        ObjectName artifactManagerName = new ObjectName(":j2eeType=ArtifactManager");
-        GBeanData artifactManagerData = new GBeanData(artifactManagerName, DefaultArtifactManager.GBEAN_INFO);
+        GBeanData artifactManagerData = buildGBeanData("name", "ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
         kernel.loadGBean(artifactManagerData, getClass().getClassLoader());
-        kernel.startGBean(artifactManagerName);
-        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactManagerName));
-        ArtifactManager artifactManager = (ArtifactManager) kernel.getProxyManager().createProxy(artifactManagerName, ArtifactManager.class);
+        kernel.startGBean(artifactManagerData.getAbstractName());
+        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactManagerData.getAbstractName()));
+        ArtifactManager artifactManager = (ArtifactManager) kernel.getProxyManager().createProxy(artifactManagerData.getAbstractName(), ArtifactManager.class);
 
         artifact1 = new Artifact("test", "1", "1.1", "bar");
         artifact2 = new Artifact("test", "2", "2.2", "bar");
@@ -88,21 +90,21 @@
 
         Environment e1 = new Environment();
         e1.setConfigId(artifact1);
-        GBeanData gbeanData1 = new GBeanData(Configuration.getConfigurationObjectName(artifact1), Configuration.GBEAN_INFO);
+        GBeanData gbeanData1 = new GBeanData(Configuration.getConfigurationAbstractName(artifact1), Configuration.GBEAN_INFO);
         gbeanData1.setAttribute("environment", e1);
         configurations.put(artifact1, gbeanData1);
 
         Environment e2 = new Environment();
         e2.setConfigId(artifact2);
         e2.addImport(new Artifact("test", "1", (Version) null, "bar"));
-        GBeanData gbeanData2 = new GBeanData(Configuration.getConfigurationObjectName(artifact2), Configuration.GBEAN_INFO);
+        GBeanData gbeanData2 = new GBeanData(Configuration.getConfigurationAbstractName(artifact2), Configuration.GBEAN_INFO);
         gbeanData2.setAttribute("environment", e2);
         configurations.put(artifact2, gbeanData2);
 
         Environment e3 = new Environment();
         e3.setConfigId(artifact3);
         e3.addImport(new Artifact("test", "2", (Version) null, "bar"));
-        GBeanData gbeanData3 = new GBeanData(Configuration.getConfigurationObjectName(artifact3), Configuration.GBEAN_INFO);
+        GBeanData gbeanData3 = new GBeanData(Configuration.getConfigurationAbstractName(artifact3), Configuration.GBEAN_INFO);
         gbeanData3.setAttribute("environment", e3);
         configurations.put(artifact3, gbeanData3);
 
@@ -148,6 +150,17 @@
         public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException {
             throw new UnsupportedOperationException();
         }
+    }
+
+    private GBeanData buildGBeanData(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        AbstractName abstractName = buildAbstractName(key, value, info);
+        return new GBeanData(abstractName, info);
+    }
+
+    private AbstractName buildAbstractName(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        Map names = new HashMap();
+        names.put(key, value);
+        return new AbstractName(new Artifact("test", "foo", "1", "car"), names, info.getInterfaces(), new ObjectName("test:" + key + "=" + value));
     }
 
     private class TestRepository implements ListableRepository {

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java Mon Mar  6 13:44:29 2006
@@ -17,26 +17,35 @@
 
 package org.apache.geronimo.security;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Properties;
-import javax.management.ObjectName;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
 import junit.framework.TestCase;
-
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.security.jaas.server.JaasLoginService;
-import org.apache.geronimo.security.jaas.LoginModuleGBean;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
+import org.apache.geronimo.security.jaas.LoginModuleGBean;
+import org.apache.geronimo.security.jaas.GeronimoLoginConfiguration;
+import org.apache.geronimo.security.jaas.ConfigurationEntryFactory;
+import org.apache.geronimo.security.jaas.server.JaasLoginService;
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
+import org.apache.geronimo.security.realm.SecurityRealm;
 import org.apache.geronimo.security.remoting.jmx.JaasLoginServiceRemotingServer;
+import org.apache.geronimo.system.serverinfo.BasicServerInfo;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 
 /**
@@ -44,11 +53,16 @@
  */
 public abstract class AbstractTest extends TestCase {
     protected Kernel kernel;
-    protected ObjectName loginService;
-    protected ObjectName testLoginModule;
-    protected ObjectName testRealm;
-    protected ObjectName serverStub;
+    protected AbstractName serverInfo;
+    protected AbstractName loginService;
+    protected AbstractName testLoginModule;
+    protected AbstractName testRealm;
+    protected AbstractName serverStub;
     private static final String REALM_NAME = "test-realm";
+    protected boolean timeoutTest = false;
+    protected boolean needServerInfo = false;
+    protected AbstractName loginConfiguration;
+    protected boolean needLoginConfiguration;
 
     protected void setUp() throws Exception {
         kernel = KernelFactory.newInstance().createKernel("test.kernel");
@@ -57,44 +71,57 @@
         GBeanData gbean;
 
         // Create all the parts
-
-        loginService = new ObjectName("test:name=TestLoginService");
-        gbean = new GBeanData(loginService, JaasLoginService.getGBeanInfo());
-        gbean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
-//        gbean.setAttribute("reclaimPeriod", new Long(10 * 1000));  // todo check other tests to see if ok
+        if (needServerInfo) {
+            gbean = buildGBeanData("name", "ServerInfo", BasicServerInfo.GBEAN_INFO);
+            serverInfo = gbean.getAbstractName();
+            gbean.setAttribute("baseDirectory", ".");
+            kernel.loadGBean(gbean, ServerInfo.class.getClassLoader());
+            kernel.startGBean(serverInfo);
+        }
+        if (needLoginConfiguration) {
+            gbean = buildGBeanData("new", "LoginConfiguration", GeronimoLoginConfiguration.getGBeanInfo());
+            loginConfiguration = gbean.getAbstractName();
+            gbean.setReferencePattern("Configurations", new AbstractNameQuery(ConfigurationEntryFactory.class.getName()));
+            kernel.loadGBean(gbean, GeronimoLoginConfiguration.class.getClassLoader());
+        }
+
+        gbean = buildGBeanData("name", "TestLoginService", JaasLoginService.getGBeanInfo());
+        loginService = gbean.getAbstractName();
+        gbean.setReferencePattern("Realms", new AbstractNameQuery(SecurityRealm.class.getName()));
+        if (timeoutTest) {
+            gbean.setAttribute("expiredLoginScanIntervalMillis", new Integer(50));
+            gbean.setAttribute("maxLoginDurationMillis", new Integer(5000));
+        }
         gbean.setAttribute("algorithm", "HmacSHA1");
         gbean.setAttribute("password", "secret");
         kernel.loadGBean(gbean, JaasLoginService.class.getClassLoader());
 
-        testLoginModule = new ObjectName("geronimo.security:type=LoginModule,name=TestModule");
-        gbean = new GBeanData(testLoginModule, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "TestLoginModule", LoginModuleGBean.getGBeanInfo());
+        testLoginModule = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.bridge.TestLoginModule");
-        gbean.setAttribute("serverSide", new Boolean(true));
+        gbean.setAttribute("serverSide", Boolean.TRUE);
         gbean.setAttribute("loginDomainName", "TestLoginDomain");
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=TestModule");
-        gbean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "TestLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testLoginModule);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testLoginModule));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        testRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=" + REALM_NAME);
-        gbean = new GBeanData(testRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "SecurityRealm" + REALM_NAME, GenericSecurityRealm.getGBeanInfo());
+        testRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", REALM_NAME);
-        Properties props = new Properties();
-//        props.setProperty("LoginModule.1.REQUIRED","geronimo.security:type=LoginModule,name=TestModule");
-//        gbean.setAttribute("loginModuleConfiguration", props);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName));
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
-        serverStub = new ObjectName("geronimo.remoting:target=JaasLoginServiceRemotingServer");
-        gbean = new GBeanData(serverStub, JaasLoginServiceRemotingServer.getGBeanInfo());
+        gbean = buildGBeanData("name", "JaasLoginServiceRemotingServer", JaasLoginServiceRemotingServer.getGBeanInfo());
+        serverStub = gbean.getAbstractName();
         gbean.setAttribute("protocol", "tcp");
         gbean.setAttribute("host", "0.0.0.0");
         gbean.setAttribute("port", new Integer(4242));
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, JaasLoginServiceRemotingServer.class.getClassLoader());
 
         kernel.startGBean(loginService);
@@ -115,6 +142,18 @@
         kernel.unloadGBean(serverStub);
 
         kernel.shutdown();
+    }
+
+
+    protected GBeanData buildGBeanData(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        AbstractName abstractName = buildAbstractName(key, value, info);
+        return new GBeanData(abstractName, info);
+    }
+
+    private AbstractName buildAbstractName(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        Map names = new HashMap();
+        names.put(key, value);
+        return new AbstractName(new Artifact("test", "foo", "1", "car"), names, info.getInterfaces(), new ObjectName("test:" + key + "=" + value));
     }
 
     public static class UsernamePasswordCallback implements CallbackHandler {

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java Mon Mar  6 13:44:29 2006
@@ -18,11 +18,12 @@
 package org.apache.geronimo.security.jaas;
 
 import java.io.File;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Properties;
 import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
 import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 
@@ -33,14 +34,19 @@
 import org.apache.log4j.PatternLayout;
 
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
 import org.apache.geronimo.security.jaas.server.JaasLoginService;
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
+import org.apache.geronimo.security.realm.SecurityRealm;
 import org.apache.geronimo.security.remoting.jmx.JaasLoginServiceRemotingServer;
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -52,15 +58,15 @@
 public class ConfigurationEntryTest extends TestCase {
 
     protected Kernel kernel;
-    protected ObjectName serverInfo;
-    protected ObjectName loginConfiguration;
-    protected ObjectName loginService;
-    protected ObjectName clientCE;
-    protected ObjectName testUPCred;
-    protected ObjectName testCE;         //audit lm
-    protected ObjectName testProperties; //properties lm
-    protected ObjectName testRealm;
-    protected ObjectName serverStub;
+    protected AbstractName serverInfo;
+    protected AbstractName loginConfiguration;
+    protected AbstractName loginService;
+    protected AbstractName clientCE;
+    protected AbstractName testUPCred;
+    protected AbstractName testCE;         //audit lm
+    protected AbstractName testProperties; //properties lm
+    protected AbstractName testRealm;
+    protected AbstractName serverStub;
 
     public void test() throws Exception {
         File log = new File("target/login-audit.log");
@@ -135,38 +141,34 @@
 
         // Create all the parts
 
-        serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
-        gbean = new GBeanData(serverInfo, BasicServerInfo.GBEAN_INFO);
+        gbean = buildGBeanData("name", "ServerInfo", BasicServerInfo.GBEAN_INFO);
+        serverInfo = gbean.getAbstractName();
         gbean.setAttribute("baseDirectory", ".");
         kernel.loadGBean(gbean, ServerInfo.class.getClassLoader());
         kernel.startGBean(serverInfo);
 
-        loginConfiguration = new ObjectName("geronimo.security:type=LoginConfiguration");
-        gbean = new GBeanData(loginConfiguration, GeronimoLoginConfiguration.getGBeanInfo());
-        Set configurations = new HashSet();
-        configurations.add(new ObjectName("geronimo.security:type=SecurityRealm,*"));
-        configurations.add(new ObjectName("geronimo.security:type=ConfigurationEntry,*"));
-        gbean.setReferencePatterns("Configurations", configurations);
+        gbean = buildGBeanData("new", "LoginConfiguration", GeronimoLoginConfiguration.getGBeanInfo());
+        loginConfiguration = gbean.getAbstractName();
+        gbean.setReferencePattern("Configurations", new AbstractNameQuery(ConfigurationEntryFactory.class.getName()));
         kernel.loadGBean(gbean, GeronimoLoginConfiguration.class.getClassLoader());
 
-        loginService = new ObjectName("test:name=TestLoginService");
-        gbean = new GBeanData(loginService, JaasLoginService.getGBeanInfo());
-        gbean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
-//        gbean.setAttribute("reclaimPeriod", new Long(100));
+        gbean = buildGBeanData("name", "TestLoginService", JaasLoginService.getGBeanInfo());
+        loginService = gbean.getAbstractName();
+        gbean.setReferencePattern("Realms", new AbstractNameQuery((SecurityRealm.class.getName())));
         gbean.setAttribute("algorithm", "HmacSHA1");
         gbean.setAttribute("password", "secret");
         kernel.loadGBean(gbean, JaasLoginService.class.getClassLoader());
 
         // TODO What is this?
-        clientCE = new ObjectName("geronimo.security:type=ConfigurationEntry,jaasId=properties-client");
-        gbean = new GBeanData(clientCE, ServerRealmConfigurationEntry.getGBeanInfo());
+        gbean = buildGBeanData("name", "client-ConfigurationEntry", ServerRealmConfigurationEntry.getGBeanInfo());
+        clientCE = gbean.getAbstractName();
         gbean.setAttribute("applicationConfigName", "properties-client");
         gbean.setAttribute("realmName", "properties-realm");
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, ServerRealmConfigurationEntry.class.getClassLoader());
 
-        testProperties = new ObjectName("geronimo.security:type=LoginModule,name=properties");
-        gbean = new GBeanData(testProperties, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
+        testProperties = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
         gbean.setAttribute("serverSide", new Boolean(true));
         Properties props = new Properties();
@@ -177,15 +179,15 @@
         gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        testUPCred = new ObjectName("geronimo.security:type=LoginModule,name=UPCred");
-        gbean = new GBeanData(testUPCred, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "UPCredLoginModule", LoginModuleGBean.getGBeanInfo());
+        testUPCred = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.jaas.UPCredentialLoginModule");
         gbean.setAttribute("serverSide", new Boolean(true));
         gbean.setAttribute("options", new Properties());
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        testCE = new ObjectName("geronimo.security:type=LoginModule,name=audit");
-        gbean = new GBeanData(testCE, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData    ("name", "AuditLoginModule", LoginModuleGBean.getGBeanInfo());
+        testCE = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.FileAuditLoginModule");
         gbean.setAttribute("serverSide", new Boolean(true));
         props = new Properties();
@@ -193,45 +195,40 @@
         gbean.setAttribute("options", props);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        ObjectName testUseName3 = new ObjectName("geronimo.security:type=LoginModuleUse,name=UPCred");
-        gbean = new GBeanData(testUseName3, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "UPCredLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName3 = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testUPCred);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testUPCred));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        ObjectName testUseName2 = new ObjectName("geronimo.security:type=LoginModuleUse,name=audit");
-        gbean = new GBeanData(testUseName2, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "AuditLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName2 = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testCE);
-        gbean.setReferencePattern("Next", testUseName3);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testCE));
+        gbean.setReferencePattern("Next", new AbstractNameQuery(testUseName3));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        ObjectName testUseName1 = new ObjectName("geronimo.security:type=LoginModuleUse,name=properties");
-        gbean = new GBeanData(testUseName1, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName1 = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testProperties);
-        gbean.setReferencePattern("Next", testUseName2);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testProperties));
+        gbean.setReferencePattern("Next", new AbstractNameQuery(testUseName2));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        testRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
-        gbean = new GBeanData(testRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesSecurityRealm", GenericSecurityRealm.getGBeanInfo());
+        testRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", "properties-realm");
-//        props = new Properties();
-//        props.setProperty("LoginModule.3.REQUIRED","geronimo.security:type=LoginModule,name=UPCred");
-//        props.setProperty("LoginModule.2.REQUIRED","geronimo.security:type=LoginModule,name=audit");
-//        props.setProperty("LoginModule.1.REQUIRED","geronimo.security:type=LoginModule,name=properties");
-//        gbean.setAttribute("loginModuleConfiguration", props);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName1);
-        gbean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfo));
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName1));
+        gbean.setReferencePattern("ServerInfo", new AbstractNameQuery(serverInfo));
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
-        serverStub = new ObjectName("geronimo.remoting:target=JaasLoginServiceRemotingServer");
-        gbean = new GBeanData(serverStub, JaasLoginServiceRemotingServer.getGBeanInfo());
+        gbean = buildGBeanData("name", "JaasLoginServiceRemotingServer", JaasLoginServiceRemotingServer.getGBeanInfo());
+        serverStub = gbean.getAbstractName();
         gbean.setAttribute("protocol", "tcp");
         gbean.setAttribute("host", "0.0.0.0");
         gbean.setAttribute("port", new Integer(4242));
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, JaasLoginServiceRemotingServer.class.getClassLoader());
 
         kernel.startGBean(loginConfiguration);
@@ -268,4 +265,16 @@
 
         kernel.shutdown();
     }
+
+    private GBeanData buildGBeanData(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+          AbstractName abstractName = buildAbstractName(key, value, info);
+          return new GBeanData(abstractName, info);
+      }
+
+      private AbstractName buildAbstractName(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+          Map names = new HashMap();
+          names.put(key, value);
+          return new AbstractName(new Artifact("test", "foo", "1", "car"), names, info.getInterfaces(), new ObjectName("test:" + key + "=" + value));
+      }
+
 }

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosNonGeronimoTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosNonGeronimoTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosNonGeronimoTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosNonGeronimoTest.java Mon Mar  6 13:44:29 2006
@@ -17,20 +17,18 @@
 
 package org.apache.geronimo.security.jaas;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import javax.management.ObjectName;
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.RealmPrincipal;
 
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.util.Properties;
+
 
 /**
  * An example of how to setup non-Geronimo login modules when the
@@ -42,9 +40,8 @@
  */
 public class LoginKerberosNonGeronimoTest extends AbstractTest {
 
-    protected ObjectName kerberosCE;
-    protected ObjectName kerberosLM;
-    protected ObjectName loginConfiguration;
+    protected AbstractName kerberosCE;
+    protected AbstractName kerberosLM;
 
     /**
      * Install the <code>GeronimoLoginConfiguration</code> but setup a non-Geronimo
@@ -54,20 +51,13 @@
      * @throws Exception
      */
     public void setUp() throws Exception {
+        needLoginConfiguration = true;
         super.setUp();
 
         GBeanData gbean;
 
-        loginConfiguration = new ObjectName("geronimo.security:type=LoginConfiguration");
-        gbean = new GBeanData(loginConfiguration, GeronimoLoginConfiguration.getGBeanInfo());
-        Set configurations = new HashSet();
-        configurations.add(new ObjectName("geronimo.security:type=SecurityRealm,*"));
-        configurations.add(new ObjectName("geronimo.security:type=ConfigurationEntry,*"));
-        gbean.setReferencePatterns("Configurations", configurations);
-        kernel.loadGBean(gbean, GeronimoLoginConfiguration.class.getClassLoader());
-
-        kerberosLM = new ObjectName("geronimo.security:type=LoginModule,name=TOOLAZYDOGS.COM");
-        gbean = new GBeanData(kerberosLM, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "KerberosLoginModule", LoginModuleGBean.getGBeanInfo());
+        kerberosLM = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "com.sun.security.auth.module.Krb5LoginModule");
         gbean.setAttribute("serverSide", new Boolean(true)); // normally not, but in this case, it's treated as server-side
         Properties props = new Properties();
@@ -77,11 +67,11 @@
         gbean.setAttribute("options", props);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        kerberosCE = new ObjectName("geronimo.security:type=ConfigurationEntry,jaasId=kerberos-foobar");
-        gbean = new GBeanData(kerberosCE, DirectConfigurationEntry.getGBeanInfo());
+        gbean = buildGBeanData("name", "kerberosConfigurationEntry", DirectConfigurationEntry.getGBeanInfo());
+        kerberosCE = gbean.getAbstractName();
         gbean.setAttribute("applicationConfigName", "kerberos-foobar");
         gbean.setAttribute("controlFlag", LoginModuleControlFlag.REQUIRED);
-        gbean.setReferencePatterns("Module", Collections.singleton(kerberosLM));
+        gbean.setReferencePattern("Module", new AbstractNameQuery(kerberosLM));
         kernel.loadGBean(gbean, DirectConfigurationEntry.class.getClassLoader());
 
         kernel.startGBean(loginConfiguration);

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginKerberosTest.java Mon Mar  6 13:44:29 2006
@@ -18,13 +18,14 @@
 package org.apache.geronimo.security.jaas;
 
 import java.util.Properties;
-import javax.management.ObjectName;
 import javax.security.auth.Subject;
 import javax.security.auth.kerberos.KerberosPrincipal;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.IdentificationPrincipal;
@@ -37,14 +38,14 @@
  */
 public class LoginKerberosTest extends AbstractTest {
 
-    protected ObjectName kerberosRealm;
-    protected ObjectName kerberosLM;
+    protected AbstractName kerberosRealm;
+    protected AbstractName kerberosLM;
 
     public void setUp() throws Exception {
         super.setUp();
 
-        kerberosLM = new ObjectName("geronimo.security:type=LoginModule,name=TOOLAZYDOGS.COM");
-        GBeanData gbean = new GBeanData(kerberosLM, LoginModuleGBean.getGBeanInfo());
+        GBeanData gbean = buildGBeanData("name", "KerberosLoginModule", LoginModuleGBean.getGBeanInfo());
+        kerberosLM = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "com.sun.security.auth.module.Krb5LoginModule");
         gbean.setAttribute("serverSide", new Boolean(true)); // normally not, but in this case, it's treated as server-side
         Properties props = new Properties();
@@ -54,19 +55,16 @@
         gbean.setAttribute("options", props);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=TOOLAZYDOGS.COM");
-        gbean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "KerberosLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", kerberosLM);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(kerberosLM));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        kerberosRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=TOOLAZYDOGS.COM");
-        gbean = new GBeanData(kerberosRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "KerberosSecurityRealm", GenericSecurityRealm.getGBeanInfo());
+        kerberosRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", "TOOLAZYDOGS.COM");
-//        props = new Properties();
-//        props.setProperty("LoginModule.1.REQUIRED", "geronimo.security:type=LoginModule,name=TOOLAZYDOGS.COM");
-//        gbean.setAttribute("loginModuleConfiguration", props);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
         kernel.startGBean(kerberosLM);
         kernel.startGBean(testUseName);

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java Mon Mar  6 13:44:29 2006
@@ -17,25 +17,21 @@
 
 package org.apache.geronimo.security.jaas;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import javax.management.ObjectName;
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.security.DomainPrincipal;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
-import org.apache.geronimo.security.DomainPrincipal;
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
-import org.apache.geronimo.system.serverinfo.BasicServerInfo;
-import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.io.File;
+import java.util.Properties;
 
 
 /**
@@ -43,36 +39,22 @@
  */
 public class LoginPropertiesFileTest extends AbstractTest {
 
-    protected ObjectName serverInfo;
-    protected ObjectName loginConfiguration;
-    protected ObjectName clientLM;
-    protected ObjectName clientCE;
-    protected ObjectName testCE;
-    protected ObjectName testRealm;
+    protected AbstractName clientLM;
+    protected AbstractName clientCE;
+    protected AbstractName testCE;
+    protected AbstractName testRealm;
 
     public void setUp() throws Exception {
+        needServerInfo = true;
+        needLoginConfiguration = true;
         super.setUp();
 
         GBeanData gbean;
 
-        serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
-        gbean = new GBeanData(serverInfo, BasicServerInfo.GBEAN_INFO);
-        gbean.setAttribute("baseDirectory", ".");
-        kernel.loadGBean(gbean, ServerInfo.class.getClassLoader());
-        kernel.startGBean(serverInfo);
-
-        loginConfiguration = new ObjectName("geronimo.security:type=LoginConfiguration");
-        gbean = new GBeanData(loginConfiguration, GeronimoLoginConfiguration.getGBeanInfo());
-        Set configurations = new HashSet();
-        configurations.add(new ObjectName("geronimo.security:type=SecurityRealm,*"));
-        configurations.add(new ObjectName("geronimo.security:type=ConfigurationEntry,*"));
-        gbean.setReferencePatterns("Configurations", configurations);
-        kernel.loadGBean(gbean, GeronimoLoginConfiguration.class.getClassLoader());
-
-        clientLM = new ObjectName("geronimo.security:type=LoginModule,name=properties-client");
-        gbean = new GBeanData(clientLM, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "ClientPropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
+        clientLM = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.jaas.client.JaasLoginCoordinator");
-        gbean.setAttribute("serverSide", new Boolean(false));
+        gbean.setAttribute("serverSide", Boolean.FALSE);
         Properties props = new Properties();
         props.put("host", "localhost");
         props.put("port", "4242");
@@ -80,18 +62,18 @@
         gbean.setAttribute("options", props);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        clientCE = new ObjectName("geronimo.security:type=ConfigurationEntry,jaasId=properties-client");
-        gbean = new GBeanData(clientCE, DirectConfigurationEntry.getGBeanInfo());
+        gbean = buildGBeanData("name", "ClientConfigurationEntry", DirectConfigurationEntry.getGBeanInfo());
+        clientCE = gbean.getAbstractName();
         gbean.setAttribute("applicationConfigName", "properties-client");
         gbean.setAttribute("controlFlag", LoginModuleControlFlag.REQUIRED);
         gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
-        gbean.setReferencePatterns("Module", Collections.singleton(clientLM));
+        gbean.setReferencePattern("Module", new AbstractNameQuery(clientLM));
         kernel.loadGBean(gbean, DirectConfigurationEntry.class.getClassLoader());
 
-        testCE = new ObjectName("geronimo.security:type=LoginModule,name=properties");
-        gbean = new GBeanData(testCE, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
+        testCE = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
-        gbean.setAttribute("serverSide", new Boolean(true));
+        gbean.setAttribute("serverSide", Boolean.TRUE);
         props = new Properties();
         props.put("usersURI", new File(new File("."), "src/test-data/data/users.properties").toURI().toString());
         props.put("groupsURI", new File(new File("."), "src/test-data/data/groups.properties").toURI().toString());
@@ -100,19 +82,18 @@
         gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=properties");
-        gbean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testCE);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testCE));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        testRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
-        gbean = new GBeanData(testRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesSecurityRealm", GenericSecurityRealm.getGBeanInfo());
+        testRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", "properties-realm");
-//        gbean.setAttribute("loginModuleConfiguration", props);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
-        gbean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfo));
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName));
+        gbean.setReferencePattern("ServerInfo", new AbstractNameQuery(serverInfo));
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
         kernel.startGBean(loginConfiguration);

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSQLTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSQLTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSQLTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSQLTest.java Mon Mar  6 13:44:29 2006
@@ -21,12 +21,13 @@
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Properties;
-import javax.management.ObjectName;
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.DomainPrincipal;
@@ -41,8 +42,8 @@
 public class LoginSQLTest extends AbstractTest {
 
     private static final String hsqldbURL = "jdbc:hsqldb:target/database/LoginSQLTest";
-    protected ObjectName sqlRealm;
-    protected ObjectName sqlModule;
+    protected AbstractName sqlRealm;
+    protected AbstractName sqlModule;
 
     public void setUp() throws Exception {
         super.setUp();
@@ -81,8 +82,8 @@
 
         conn.close();
 
-        sqlModule = new ObjectName("geronimo.security:type=LoginModule,name=sql");
-        GBeanData gbean = new GBeanData(sqlModule, LoginModuleGBean.getGBeanInfo());
+        GBeanData gbean = buildGBeanData("name", "SQLLoginModule", LoginModuleGBean.getGBeanInfo());
+        sqlModule = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.SQLLoginModule");
         gbean.setAttribute("serverSide", new Boolean(true));
         Properties props = new Properties();
@@ -98,21 +99,18 @@
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
         kernel.startGBean(sqlModule);
 
-        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=sql");
-        gbean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "SQLLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", sqlModule);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(sqlModule));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
         kernel.startGBean(testUseName);
 
-        sqlRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=sql-realm");
-        gbean = new GBeanData(sqlRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "SQLSecurityRealm", GenericSecurityRealm.getGBeanInfo());
+        sqlRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", "sql-realm");
-//        props = new Properties();
-//        props.setProperty("LoginModule.1.REQUIRED","geronimo.security:type=LoginModule,name=sql");
-//        gbean.setAttribute("loginModuleConfiguration", props);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName));
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
         kernel.startGBean(sqlRealm);
 

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java Mon Mar  6 13:44:29 2006
@@ -17,27 +17,21 @@
 
 package org.apache.geronimo.security.jaas;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import javax.management.ObjectName;
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.DomainPrincipal;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
-import org.apache.geronimo.security.jaas.server.JaasLoginService;
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
-import org.apache.geronimo.security.remoting.jmx.JaasLoginServiceRemotingServer;
-import org.apache.geronimo.system.serverinfo.BasicServerInfo;
-import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import java.io.File;
+import java.util.Properties;
+import java.util.Set;
 
 
 /**
@@ -45,60 +39,25 @@
  */
 public class TimeoutTest extends AbstractTest {
 
-    protected ObjectName serverInfo;
-    protected ObjectName loginConfiguration;
-    protected ObjectName testCE;
-    protected ObjectName testRealm;
-    protected ObjectName clientLM;
-    protected ObjectName clientCE;
+    protected AbstractName testCE;
+    protected AbstractName testRealm;
+    protected AbstractName clientLM;
+    protected AbstractName clientCE;
 
     public void setUp() throws Exception {
-        kernel = KernelFactory.newInstance().createKernel("test.kernel");
-        kernel.boot();
+        timeoutTest = true;
+        needServerInfo = true;
+        needLoginConfiguration = true;
+        super.setUp();
 
         GBeanData gbean;
 
         // Create all the parts
 
-        loginService = new ObjectName("geronimo.security:type=JaasLoginService");
-        gbean = new GBeanData(loginService, JaasLoginService.getGBeanInfo());
-        gbean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
-        gbean.setAttribute("expiredLoginScanIntervalMillis", new Integer(50));
-        gbean.setAttribute("maxLoginDurationMillis", new Integer(5000));
-        gbean.setAttribute("algorithm", "HmacSHA1");
-        gbean.setAttribute("password", "secret");
-        kernel.loadGBean(gbean, JaasLoginService.class.getClassLoader());
-
-
-        serverStub = new ObjectName("geronimo.remoting:target=JaasLoginServiceRemotingServer");
-        gbean = new GBeanData(serverStub, JaasLoginServiceRemotingServer.getGBeanInfo());
-        gbean.setAttribute("protocol", "tcp");
-        gbean.setAttribute("host", "0.0.0.0");
-        gbean.setAttribute("port", new Integer(4242));
-        gbean.setReferencePattern("LoginService", loginService);
-        kernel.loadGBean(gbean, JaasLoginServiceRemotingServer.class.getClassLoader());
-
-        kernel.startGBean(loginService);
-        kernel.startGBean(serverStub);
-
-        serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
-        gbean = new GBeanData(serverInfo, BasicServerInfo.GBEAN_INFO);
-        gbean.setAttribute("baseDirectory", ".");
-        kernel.loadGBean(gbean, ServerInfo.class.getClassLoader());
-        kernel.startGBean(serverInfo);
-
-        loginConfiguration = new ObjectName("geronimo.security:type=LoginConfiguration");
-        gbean = new GBeanData(loginConfiguration, GeronimoLoginConfiguration.getGBeanInfo());
-        Set configurations = new HashSet();
-        configurations.add(new ObjectName("geronimo.security:type=SecurityRealm,*"));
-        configurations.add(new ObjectName("geronimo.security:type=ConfigurationEntry,*"));
-        gbean.setReferencePatterns("Configurations", configurations);
-        kernel.loadGBean(gbean, GeronimoLoginConfiguration.class.getClassLoader());
-
-        testCE = new ObjectName("geronimo.security:type=LoginModule,name=properties");
-        gbean = new GBeanData(testCE, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData    ("name", "PropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
+        testCE = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
-        gbean.setAttribute("serverSide", new Boolean(true));
+        gbean.setAttribute("serverSide", Boolean.TRUE);
         Properties props = new Properties();
         props.put("usersURI", new File(new File("."), "src/test-data/data/users.properties").toURI().toString());
         props.put("groupsURI", new File(new File("."), "src/test-data/data/groups.properties").toURI().toString());
@@ -107,27 +66,24 @@
         gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=properties");
-        gbean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testCE);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testCE));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        testRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
-        gbean = new GBeanData(testRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesSecurityRealm", GenericSecurityRealm.getGBeanInfo());
+        testRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", "properties-realm");
-//        props = new Properties();
-//        props.setProperty("LoginModule.1.REQUIRED","geronimo.security:type=LoginModule,name=properties");
-//        gbean.setAttribute("loginModuleConfiguration", props);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
-        gbean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfo));
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName));
+        gbean.setReferencePattern("ServerInfo", new AbstractNameQuery(serverInfo));
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
-        clientLM = new ObjectName("geronimo.security:type=LoginModule,name=properties-client");
-        gbean = new GBeanData(clientLM, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "ClientPropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
+        clientLM = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.jaas.client.JaasLoginCoordinator");
-        gbean.setAttribute("serverSide", new Boolean(false));
+        gbean.setAttribute("serverSide", Boolean.FALSE);
         props = new Properties();
         props.put("host", "localhost");
         props.put("port", "4242");
@@ -135,11 +91,11 @@
         gbean.setAttribute("options", props);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        clientCE = new ObjectName("geronimo.security:type=ConfigurationEntry,jaasId=properties-client");
-        gbean = new GBeanData(clientCE, DirectConfigurationEntry.getGBeanInfo());
+        gbean = buildGBeanData("name", "ClientConfigurationEntry", DirectConfigurationEntry.getGBeanInfo());
+        clientCE = gbean.getAbstractName();
         gbean.setAttribute("applicationConfigName", "properties-client");
         gbean.setAttribute("controlFlag", LoginModuleControlFlag.REQUIRED);
-        gbean.setReferencePatterns("Module", Collections.singleton(clientLM));
+        gbean.setReferencePattern("Module", new AbstractNameQuery(clientLM));
         kernel.loadGBean(gbean, DirectConfigurationEntry.class.getClassLoader());
 
         kernel.startGBean(loginConfiguration);

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java Mon Mar  6 13:44:29 2006
@@ -35,14 +35,13 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
 import org.apache.geronimo.security.jaas.LoginModuleGBean;
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
-import org.apache.geronimo.system.serverinfo.BasicServerInfo;
-import org.apache.geronimo.system.serverinfo.ServerInfo;
 
-import javax.management.ObjectName;
 import javax.security.auth.Subject;
 import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginContext;
@@ -51,7 +50,6 @@
 import java.net.URI;
 import java.security.AccessController;
 import java.security.PrivilegedExceptionAction;
-import java.util.Collections;
 import java.util.Properties;
 
 
@@ -62,9 +60,8 @@
 
     final static private Log log = LogFactory.getLog(SubjectCarryingProtocolTest.class);
 
-    protected ObjectName serverInfo;
-    protected ObjectName testCE;
-    protected ObjectName testRealm;
+    protected AbstractName testCE;
+    protected AbstractName testRealm;
 
     private Subject clientSubject;
     private Subject serverSubject;
@@ -111,18 +108,13 @@
 
 
     public void setUp() throws Exception {
+        needServerInfo = true;
         super.setUp();
 
         GBeanData gbean;
 
-        serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
-        gbean = new GBeanData(serverInfo, BasicServerInfo.GBEAN_INFO);
-        gbean.setAttribute("baseDirectory", ".");
-        kernel.loadGBean(gbean, ServerInfo.class.getClassLoader());
-        kernel.startGBean(serverInfo);
-
-        testCE = new ObjectName("geronimo.security:type=LoginModule,name=properties");
-        gbean = new GBeanData(testCE, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData    ("name", "PropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
+        testCE = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
         gbean.setAttribute("serverSide", new Boolean(true));
         Properties props = new Properties();
@@ -132,20 +124,17 @@
         gbean.setAttribute("loginDomainName", "PropertiesDomain");
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=properties");
-        gbean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testCE);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testCE));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        testRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
-        gbean = new GBeanData(testRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesSecurityRealm", GenericSecurityRealm.getGBeanInfo());
+        testRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", "properties-realm");
-//        props = new Properties();
-//        props.setProperty("LoginModule.1.REQUIRED","geronimo.security:type=LoginModule,name=properties");
-//        gbean.setAttribute("loginModuleConfiguration", props);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
-        gbean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfo));
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName));
+        gbean.setReferencePattern("ServerInfo", new AbstractNameQuery(serverInfo));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
         kernel.startGBean(testCE);

Modified: geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java (original)
+++ geronimo/branches/1.1/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java Mon Mar  6 13:44:29 2006
@@ -20,9 +20,11 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
-import java.util.Collections;
 import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
 import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
 import javax.security.auth.Subject;
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -34,8 +36,12 @@
 import junit.framework.TestCase;
 
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
 import org.apache.geronimo.security.jaas.server.JaasLoginService;
@@ -44,7 +50,9 @@
 import org.apache.geronimo.security.jaas.GeronimoLoginConfiguration;
 import org.apache.geronimo.security.jaas.DirectConfigurationEntry;
 import org.apache.geronimo.security.jaas.LoginModuleControlFlag;
+import org.apache.geronimo.security.jaas.ConfigurationEntryFactory;
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
+import org.apache.geronimo.security.realm.SecurityRealm;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 
@@ -54,15 +62,12 @@
  */
 public class RemoteLoginTest extends TestCase {
     Kernel kernel;
-    ObjectName serverInfo;
-    ObjectName loginService;
-    ObjectName loginConfig;
-    protected ObjectName testCE;
-    protected ObjectName testRealm;
-    ObjectName serverStub;
-//    JaasLoginServiceMBean asyncRemoteProxy;
-//    JaasLoginServiceMBean saslRemoteProxy;
-//    JaasLoginServiceMBean gssapiRemoteProxy;
+    AbstractName serverInfo;
+    AbstractName loginService;
+    AbstractName loginConfig;
+    protected AbstractName testCE;
+    protected AbstractName testRealm;
+    AbstractName serverStub;
 
 
     public void testLogin() throws Exception {
@@ -95,23 +100,23 @@
 
         // Create all the parts
 
-        serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
-        gbean = new GBeanData(serverInfo, BasicServerInfo.GBEAN_INFO);
+        gbean = buildGBeanData("role", "ServerInfo", BasicServerInfo.GBEAN_INFO);
+        serverInfo = gbean.getAbstractName();
         gbean.setAttribute("baseDirectory", ".");
         kernel.loadGBean(gbean, ServerInfo.class.getClassLoader());
         kernel.startGBean(serverInfo);
 
-        loginService = new ObjectName("geronimo.security:type=JaasLoginService");
-        gbean = new GBeanData(loginService, JaasLoginService.getGBeanInfo());
-        gbean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
+        gbean = buildGBeanData("type", "JaasLoginService", JaasLoginService.getGBeanInfo());
+        loginService = gbean.getAbstractName();
+        gbean.setReferencePattern("Realms", new AbstractNameQuery(SecurityRealm.class.getName()));
         gbean.setAttribute("algorithm", "HmacSHA1");
         gbean.setAttribute("password", "secret");
         kernel.loadGBean(gbean, JaasLoginService.class.getClassLoader());
 
-        testCE = new ObjectName("geronimo.security:type=LoginModule,name=properties");
-        gbean = new GBeanData(testCE, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
+        testCE = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
-        gbean.setAttribute("serverSide", new Boolean(true));
+        gbean.setAttribute("serverSide", Boolean.TRUE);
         gbean.setAttribute("loginDomainName", "secret");
         Properties props = new Properties();
         props.put("usersURI", new File(new File("."), "src/test-data/data/users.properties").toURI().toString());
@@ -119,26 +124,26 @@
         gbean.setAttribute("options", props);
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
 
-        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=properties");
-        gbean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
+        AbstractName testUseName = gbean.getAbstractName();
         gbean.setAttribute("controlFlag", "REQUIRED");
-        gbean.setReferencePattern("LoginModule", testCE);
+        gbean.setReferencePattern("LoginModule", new AbstractNameQuery(testCE));
         kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
 
-        testRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
-        gbean = new GBeanData(testRealm, GenericSecurityRealm.getGBeanInfo());
+        gbean = buildGBeanData("name", "PropertiesSecurityRealm", GenericSecurityRealm.getGBeanInfo());
+        testRealm = gbean.getAbstractName();
         gbean.setAttribute("realmName", "properties-realm");
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
-        gbean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfo));
+        gbean.setReferencePattern("LoginModuleConfiguration", new AbstractNameQuery(testUseName));
+        gbean.setReferencePattern("ServerInfo", new AbstractNameQuery(serverInfo));
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
 
-        serverStub = new ObjectName("geronimo.remoting:target=JaasLoginServiceRemotingServer");
-        gbean = new GBeanData(serverStub, JaasLoginServiceRemotingServer.getGBeanInfo());
+        gbean = buildGBeanData("target", "JaasLoginServiceRemotingServer", JaasLoginServiceRemotingServer.getGBeanInfo());
+        serverStub = gbean.getAbstractName();
         gbean.setAttribute("protocol", "tcp");
         gbean.setAttribute("host", "0.0.0.0");
         gbean.setAttribute("port", new Integer(4242));
-        gbean.setReferencePattern("LoginService", loginService);
+        gbean.setReferencePattern("LoginService", new AbstractNameQuery(loginService));
         kernel.loadGBean(gbean, JaasLoginServiceRemotingServer.class.getClassLoader());
 
         kernel.startGBean(loginService);
@@ -153,15 +158,15 @@
         }
 
         //set up "Client side" in the same kernel
-        loginConfig = new ObjectName("geronimo.client:name=GeronimoLoginConfiguration");
-        gbean = new GBeanData(loginConfig, GeronimoLoginConfiguration.getGBeanInfo());
-        gbean.setReferencePattern("Configurations", new ObjectName("geronimo.security:type=ConfigurationEntry,*"));
+        gbean = buildGBeanData("name", "ClientLoginConfiguration", GeronimoLoginConfiguration.getGBeanInfo());
+        loginConfig = gbean.getAbstractName();
+        gbean.setReferencePattern("Configurations", new AbstractNameQuery(ConfigurationEntryFactory.class.getName()));
         kernel.loadGBean(gbean, GeronimoLoginConfiguration.class.getClassLoader());
         kernel.startGBean(loginConfig);
 
         //JaasLoginCoordinator client lm
-        ObjectName jlc = new ObjectName("geronimo.security:type=JaasLoginCoordinatorLM");
-        gbean = new GBeanData(jlc, LoginModuleGBean.getGBeanInfo());
+        gbean = buildGBeanData("name", "JaasLoginCoordinatorLM", LoginModuleGBean.getGBeanInfo());
+        AbstractName jlc = gbean.getAbstractName();
         gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.jaas.client.JaasLoginCoordinator");
         gbean.setAttribute("serverSide", new Boolean(false));
         props = new Properties();
@@ -174,11 +179,11 @@
         kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
         kernel.startGBean(jlc);
 
-        ObjectName dce = new ObjectName("geronimo.security:type=ConfigurationEntry,name=client");
-        gbean = new GBeanData(dce, DirectConfigurationEntry.getGBeanInfo());
+        gbean = buildGBeanData("name", "ClientConfigurationEntry", DirectConfigurationEntry.getGBeanInfo());
+        AbstractName dce = gbean.getAbstractName();
         gbean.setAttribute("applicationConfigName", "FOO");
         gbean.setAttribute("controlFlag", LoginModuleControlFlag.REQUIRED);
-        gbean.setReferencePattern("Module", jlc);
+        gbean.setReferencePattern("Module", new AbstractNameQuery(jlc));
         kernel.loadGBean(gbean, DirectConfigurationEntry.class.getClassLoader());
         kernel.startGBean(dce);
 
@@ -207,6 +212,17 @@
         kernel.unloadGBean(serverInfo);
 
         kernel.shutdown();
+    }
+
+    private GBeanData buildGBeanData(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        AbstractName abstractName = buildAbstractName(key, value, info);
+        return new GBeanData(abstractName, info);
+    }
+
+    private AbstractName buildAbstractName(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        Map names = new HashMap();
+        names.put(key, value);
+        return new AbstractName(new Artifact("test", "foo", "1", "car"), names, info.getInterfaces(), new ObjectName("test:" + key + "=" + value));
     }
 
     class UsernamePasswordCallback implements CallbackHandler {

Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java Mon Mar  6 13:44:29 2006
@@ -17,14 +17,6 @@
 
 package org.apache.geronimo.deployment.service;
 
-import java.beans.PropertyEditor;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.propertyeditor.PropertyEditors;
 import org.apache.geronimo.deployment.DeploymentContext;
@@ -34,14 +26,22 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.xmlbeans.XmlCursor;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.xmlbeans.XmlObject;
 
+import javax.management.ObjectName;
+import java.beans.PropertyEditor;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.List;
+import java.util.Collections;
+
 /**
- *
- *
  * @version $Rev$ $Date$
  */
 public class GBeanBuilder {
@@ -63,7 +63,7 @@
     }
 
     public void setAttribute(String name, String type, String text) throws DeploymentException {
-        if(text != null) {
+        if (text != null) {
             text = text.trim(); // avoid formatting errors due to extra whitespace in XML configuration file
         }
         try {
@@ -120,63 +120,65 @@
     }
 
     public void setReference(String name, ReferenceType pattern, J2eeContext j2eeContext) throws DeploymentException {
-        setReference(name, new PatternType[] { pattern }, j2eeContext);
+        setReference(name, new PatternType[]{pattern}, j2eeContext);
     }
 
     public void setReference(String name, PatternType[] patterns, J2eeContext j2eeContext) throws DeploymentException {
         Set patternNames = new HashSet(patterns.length);
         for (int i = 0; i < patterns.length; i++) {
-            try {
-                patternNames.add(buildObjectName(name, patterns[i], j2eeContext));
-            } catch (MalformedObjectNameException e) {
-                throw new DeploymentException("Invalid pattern for reference " + name + ": " + patterns[i], e);
-            }
+            patternNames.add(buildUnresolvedReferenceInfo(name, patterns[i]));
         }
         gbean.setReferencePatterns(name, patternNames);
     }
 
     public void addDependency(PatternType patternType, J2eeContext j2eeContext) throws DeploymentException {
-        try {
-            ObjectName objectName = buildObjectName(null, patternType, j2eeContext);
-            gbean.getDependencies().add(objectName);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Invalid pattern for dependency: " + patternType, e);
-        }
+        AbstractNameQuery refInfo = buildUnresolvedReferenceInfo(null, patternType);
+        gbean.getDependencies().add(refInfo);
     }
 
-    private ObjectName buildObjectName(String refName, PatternType pattern, J2eeContext j2eeContext) throws MalformedObjectNameException, DeploymentException {
-        if (pattern.isSetGbeanName()) {
-            String gbeanName = pattern.getGbeanName();
-            return ObjectName.getInstance(gbeanName);
-        }
-        String domain = pattern.isSetDomain()? pattern.getDomain().trim(): null;
-        String server = pattern.isSetServer()? pattern.getServer().trim(): null;
-        String application = pattern.isSetApplication()? pattern.getApplication().trim(): null;
-        String moduleType = pattern.isSetModuleType()? pattern.getModuleType().trim(): null;
-        String module = pattern.isSetModule()? pattern.getModule().trim(): null;
-        String type = pattern.isSetType()? pattern.getType().trim(): null;
+    private AbstractNameQuery buildUnresolvedReferenceInfo(String refName, PatternType pattern) throws DeploymentException {
+//        if (refName == null) {
+//            throw new DeploymentException("No type specified in dependency pattern " + pattern + " for gbean " + gbean.getName());
+//        }
+        assert refName != null;
+        GReferenceInfo referenceInfo = null;
+        Set referenceInfos = gbean.getGBeanInfo().getReferences();
+        for (Iterator iterator = referenceInfos.iterator(); iterator.hasNext();) {
+            GReferenceInfo testReferenceInfo = (GReferenceInfo) iterator.next();
+            String testRefName = testReferenceInfo.getName();
+            if (testRefName.equals(refName)) {
+                referenceInfo = testReferenceInfo;
+            }
+        }
+        if (referenceInfo == null) {
+            throw new DeploymentException("No reference named " + refName + " in gbean " + gbean.getName());
+        }
+
+        String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
+        String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
+        String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null;
+        String module = pattern.isSetModule() ? pattern.getModule().trim() : null;
+        String type = pattern.isSetType() ? pattern.getType().trim() : null;
         String name = pattern.getName().trim();
 
+        List artifacts = Collections.EMPTY_LIST;
+        if (artifactid != null) {
+            artifacts = Collections.singletonList(new Artifact(groupId, artifactid, version, "car"));
+        }
         //get the type from the gbean info if not supplied explicitly
         if (type == null) {
-            if (refName == null) {
-                throw new DeploymentException("No type specified in dependency pattern " + pattern + " for gbean " + gbean.getName());
-            }
-            boolean found = false;
-            Set referenceInfos = gbean.getGBeanInfo().getReferences();
-            for (Iterator iterator = referenceInfos.iterator(); iterator.hasNext();) {
-                GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next();
-                String testRefName = referenceInfo.getName();
-                if (testRefName.equals(refName)) {
-                    type = referenceInfo.getNameTypeName();
-                    found = true;
-                }
-            }
-            if (!found) {
-                throw new DeploymentException("No reference named " + refName + " in gbean " + gbean.getName());
-            }
+            type = referenceInfo.getNameTypeName();
+        }
+        Map nameMap = new HashMap();
+        nameMap.put("name", name);
+        if (type != null) {
+            nameMap.put("type", type);
+        }
+        if (module != null) {
+            nameMap.put("module", module);
         }
-        return NameFactory.getComponentNameQuery(domain, server, application, moduleType, module, name, type, j2eeContext);
+        String interfaceType = referenceInfo.getProxyType();
+        return new AbstractNameQuery(artifacts, nameMap, Collections.singleton(interfaceType));
     }
 
     public GBeanData getGBeanData() {

Modified: geronimo/branches/1.1/modules/service-builder/src/test-resources/services/plan1.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/test-resources/services/plan1.xml?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/test-resources/services/plan1.xml (original)
+++ geronimo/branches/1.1/modules/service-builder/src/test-resources/services/plan1.xml Mon Mar  6 13:44:29 2006
@@ -78,7 +78,7 @@
             </ns:javabean>
         </xml-attribute>
         <reference name="MockEndpoint">
-            <gbean-name>geronimo.test:name=MyMockGMBean</gbean-name>
+            <name>MyMockGMBean</name>
         </reference>
     </gbean>
 </configuration>

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java?rev=383682&r1=383681&r2=383682&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java Mon Mar  6 13:44:29 2006
@@ -18,6 +18,9 @@
 
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -41,6 +44,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.HashMap;
 
 /**
  * @version $Rev$ $Date$
@@ -51,6 +55,7 @@
         GeronimoLogging.initialize(GeronimoLogging.WARN);
         LogFactory.getLog(ConfigurationDump.class.getName());
     }
+
     private static ClassLoader classLoader = ConfigurationDump.class.getClassLoader();
 
     public static void main(String[] args) throws Exception {
@@ -63,15 +68,13 @@
 
         PrintWriter out = new PrintWriter(System.out, true);
         try {
-            ObjectName serverInfoName = new ObjectName("configdump:name=ServerInfo");
-            GBeanData serverInfoData = new GBeanData(serverInfoName, BasicServerInfo.GBEAN_INFO);
+            GBeanData serverInfoData = buildGBeanData("name", "ServerInfo", BasicServerInfo.GBEAN_INFO);
             startGBean(kernel, serverInfoData);
 
             // add the repositories
-            ObjectName geronimoRepositoryName = new ObjectName("configdump:name=Repository,type=Geronimo");
-            GBeanData geronimoRepositoryData = new GBeanData(geronimoRepositoryName, Maven2Repository.GBEAN_INFO);
+            GBeanData geronimoRepositoryData = buildGBeanData("name", "Repository", Maven2Repository.GBEAN_INFO);
             geronimoRepositoryData.setAttribute("root", URI.create("repository"));
-            geronimoRepositoryData.setReferencePattern("ServerInfo", serverInfoName);
+            geronimoRepositoryData.setReferencePattern("ServerInfo", new AbstractNameQuery(serverInfoData.getAbstractName()));
             startGBean(kernel, geronimoRepositoryData);
 
             String mavenLocalRepo = System.getProperty("maven.repo.local");
@@ -82,20 +85,20 @@
                 mavenRepositoryDir = new File(System.getProperty("user.home"), ".maven");
                 mavenRepositoryDir = new File(mavenRepositoryDir, "repository");
             }
-            ObjectName mavenRepositoryName = new ObjectName("configdump:name=Repository,type=Maven");
+
+            GBeanData configStoreData = buildGBeanData("name", "ConfigStore", RepositoryConfigurationStore.GBEAN_INFO);
+
             if (mavenRepositoryDir.isDirectory()) {
-                GBeanData mavenRepositoryData = new GBeanData(mavenRepositoryName, Maven2Repository.GBEAN_INFO);
+                GBeanData mavenRepositoryData = buildGBeanData("name", "MavenRepository", Maven2Repository.GBEAN_INFO);
                 mavenRepositoryData.setAttribute("root", mavenRepositoryDir.getAbsoluteFile().toURI());
-                mavenRepositoryData.setReferencePattern("ServerInfo", serverInfoName);
+                mavenRepositoryData.setReferencePattern("ServerInfo", new AbstractNameQuery(serverInfoData.getAbstractName()));
                 startGBean(kernel, mavenRepositoryData);
+                configStoreData.setReferencePattern("Repository", new AbstractNameQuery(mavenRepositoryData.getAbstractName()));
             }
 
-            ObjectName configStoreName = new ObjectName("configdump:name=ConfigStore");
-            GBeanData configStoreData = new GBeanData(configStoreName, RepositoryConfigurationStore.GBEAN_INFO);
-            configStoreData.setReferencePattern("Repository", mavenRepositoryName);
             startGBean(kernel, configStoreData);
 
-            ConfigurationStore configurationStore = (ConfigurationStore) kernel.getProxyManager().createProxy(configStoreName, classLoader);
+            ConfigurationStore configurationStore = (ConfigurationStore) kernel.getProxyManager().createProxy(configStoreData.getAbstractName(), classLoader);
             List configurationInfos = configurationStore.listConfigurations();
             for (Iterator iterator = configurationInfos.iterator(); iterator.hasNext();) {
                 ConfigurationInfo configurationInfo = (ConfigurationInfo) iterator.next();
@@ -111,6 +114,17 @@
         }
     }
 
+    private static GBeanData buildGBeanData(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        AbstractName abstractName = buildAbstractName(key, value, info);
+        return new GBeanData(abstractName, info);
+    }
+
+    private static AbstractName buildAbstractName(String key, String value, GBeanInfo info) throws MalformedObjectNameException {
+        Map names = new HashMap();
+        names.put(key, value);
+        return new AbstractName(new Artifact("geronimo", "configdump", "1", "car"), names, info.getInterfaces(), new ObjectName("geronimo.configdump:" + key + "=" + value));
+    }
+
     private static void startGBean(Kernel kernel, GBeanData gbeanData) throws Exception {
         kernel.loadGBean(gbeanData, classLoader);
         kernel.startGBean(gbeanData.getName());
@@ -126,7 +140,7 @@
         out.println("==================================================");
 
         loadRecursive(kernel, configurationStore, id);
-        ObjectName name = null;
+        ObjectName name;
         name = Configuration.getConfigurationObjectName(id);
         out.println("objectName: " + name);
 
@@ -191,7 +205,7 @@
         String[] nonOverridableClasses = (String[]) config.getAttribute("nonOverridableClasses");
         if (nonOverridableClasses != null && nonOverridableClasses.length > 0) {
             out.println("nonOverridableClasses: ");
-            for (int i = 0; i < hiddenClasses.length; i++) {
+            for (int i = 0; i < nonOverridableClasses.length; i++) {
                 String nonOverridableClass = nonOverridableClasses[i];
                 out.println("  " + nonOverridableClass);
             }
@@ -227,7 +241,7 @@
                 out.println("attributes: none");
             }
             Map references = gbeanData.getReferences();
-            if (references != null && !attributes.isEmpty()) {
+            if (references != null && !references.isEmpty()) {
                 out.println("references: ");
                 for (Iterator referenceIterator = references.entrySet().iterator(); referenceIterator.hasNext();) {
                     Map.Entry entry = (Map.Entry) referenceIterator.next();
@@ -250,6 +264,7 @@
     }
 
     private static final ObjectName CONFIGURATION_NAME_QUERY;
+
     static {
         try {
             CONFIGURATION_NAME_QUERY = new ObjectName("geronimo.config:*");



Mime
View raw message