Author: doogie
Date: Thu Apr 30 01:21:11 2009 New Revision: 770028 URL: http://svn.apache.org/viewvc?rev=770028&view=rev Log: Oops, this class got modified to use the removed AbstractHandler before I removed AbstractResolver. Rewrote it to use ServiceRegistry instead, which, as before, simplifies the code. Added: ofbiz/trunk/applications/securityext/src/META-INF/ ofbiz/trunk/applications/securityext/src/META-INF/services/ ofbiz/trunk/applications/securityext/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler ofbiz/trunk/framework/security/src/META-INF/ ofbiz/trunk/framework/security/src/META-INF/services/ ofbiz/trunk/framework/security/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler Modified: ofbiz/trunk/framework/security/src/org/ofbiz/security/authz/da/DynamicAccessFactory.java Added: ofbiz/trunk/applications/securityext/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/securityext/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler?rev=770028&view=auto ============================================================================== --- ofbiz/trunk/applications/securityext/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler (added) +++ ofbiz/trunk/applications/securityext/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler Thu Apr 30 01:21:11 2009 @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +org.ofbiz.securityext.da.ServiceDaHandler Added: ofbiz/trunk/framework/security/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/security/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler?rev=770028&view=auto ============================================================================== --- ofbiz/trunk/framework/security/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler (added) +++ ofbiz/trunk/framework/security/src/META-INF/services/org.ofbiz.security.authz.da.DynamicAccessHandler Thu Apr 30 01:21:11 2009 @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +org.ofbiz.security.authz.da.GroovyDaHandler +org.ofbiz.security.authz.da.ObjectDaHandler Modified: ofbiz/trunk/framework/security/src/org/ofbiz/security/authz/da/DynamicAccessFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/security/src/org/ofbiz/security/authz/da/DynamicAccessFactory.java?rev=770028&r1=770027&r2=770028&view=diff ============================================================================== --- ofbiz/trunk/framework/security/src/org/ofbiz/security/authz/da/DynamicAccessFactory.java (original) +++ ofbiz/trunk/framework/security/src/org/ofbiz/security/authz/da/DynamicAccessFactory.java Thu Apr 30 01:21:11 2009 @@ -1,13 +1,11 @@ package org.ofbiz.security.authz.da; -import java.util.List; import java.util.Set; +import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.imageio.spi.ServiceRegistry; -import javolution.util.FastList; - -import org.ofbiz.base.util.AbstractResolver; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.cache.UtilCache; @@ -20,7 +18,6 @@ */ private static UtilCache<String,DynamicAccessHandler> dynamicAccessHandlerCache = new UtilCache<String,DynamicAccessHandler>("security.DynamicAccessHandlerCache"); private static final String module = DynamicAccessFactory.class.getName(); - private static AccessHandlerResolver resolver = new AccessHandlerResolver(); public static DynamicAccessHandler getDynamicAccessHandler(GenericDelegator delegator, String accessString) { if (dynamicAccessHandlerCache.size() == 0) { // should always be at least 1 @@ -44,8 +41,9 @@ } private static void loadAccessHandlers(GenericDelegator delegator) { - List<DynamicAccessHandler> handlers = resolver.getHandlers(); - for (DynamicAccessHandler handler : handlers) { + Iterator<DynamicAccessHandler> it = ServiceRegistry.lookupProviders(DynamicAccessHandler.class, DynamicAccessFactory.class.getClassLoader()); + while (it.hasNext()) { + DynamicAccessHandler handler = it.next(); handler.setDelegator(delegator); dynamicAccessHandlerCache.put(handler.getPattern(), handler); } @@ -80,54 +78,4 @@ return da; } - - static class AccessHandlerResolver extends AbstractResolver { - - protected List<DynamicAccessHandler> handlers; - - protected List<DynamicAccessHandler> getHandlers() { - handlers = FastList.newInstance(); - find("org.ofbiz"); - return handlers; - } - - @SuppressWarnings("unchecked") - @Override - public void resolveClass(Class clazz) { - Class theClass = clazz; - boolean checking = true; - boolean found = false; - - while (checking) { - Class[] ifaces = theClass.getInterfaces(); - for (Class iface : ifaces) { - if (DynamicAccessHandler.class.equals(iface)) { - loadHandler(theClass); - found = true; - } - } - - if (!found) { - theClass = theClass.getSuperclass(); - if (theClass == null) { - checking = false; - } - } else { - checking = false; - } - } - } - - private void loadHandler(Class<DynamicAccessHandler> clazz) { - DynamicAccessHandler handler = null; - try { - handler = clazz.newInstance(); - handlers.add(handler); - } catch (InstantiationException e) { - Debug.logError(e, module); - } catch (IllegalAccessException e) { - Debug.logError(e, module); - } - } - } } |
Free forum by Nabble | Edit this page |