You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2011/10/24 14:34:56 UTC
svn commit: r1188117 [1/2] - in /directory/shared/branches/shared-osgi: ./
ipojo-manager/ ipojo-manager/src/ ipojo-manager/src/main/
ipojo-manager/src/main/java/ ipojo-manager/src/main/java/org/
ipojo-manager/src/main/java/org/apache/ ipojo-manager/src...
Author: pamarcelot
Date: Mon Oct 24 12:34:54 2011
New Revision: 1188117
URL: http://svn.apache.org/viewvc?rev=1188117&view=rev
Log:
Part of a fix for DIRSERVER-1672 (Making Comparators extendable). Applied patch sent by Göktürk Gezer.
Added:
directory/shared/branches/shared-osgi/ipojo-manager/
directory/shared/branches/shared-osgi/ipojo-manager/pom.xml
directory/shared/branches/shared-osgi/ipojo-manager/src/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/IPojoHelper.java
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelper.java
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelpersActivator.java
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/schema/
directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/schema/SchemaElementsManager.java
directory/shared/branches/shared-osgi/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/OSGISchemaManager.java
Modified:
directory/shared/branches/shared-osgi/ldap/model/pom.xml
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/EntityFactory.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BitStringComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BooleanComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ComparableComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnSidComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/GeneralizedTimeComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/IntegerComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/LongComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NormalizingComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NumericStringComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectClassTypeComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierFirstComponentComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/SerializableComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/StringComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/TelephoneNumberComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UUIDComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UniqueMemberComparator.java
directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/WordComparator.java
directory/shared/branches/shared-osgi/ldap/schema/data/pom.xml
directory/shared/branches/shared-osgi/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
directory/shared/branches/shared-osgi/pom.xml
Added: directory/shared/branches/shared-osgi/ipojo-manager/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ipojo-manager/pom.xml?rev=1188117&view=auto
==============================================================================
--- directory/shared/branches/shared-osgi/ipojo-manager/pom.xml (added)
+++ directory/shared/branches/shared-osgi/ipojo-manager/pom.xml Mon Oct 24 12:34:54 2011
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.directory.shared</groupId>
+ <artifactId>shared-parent</artifactId>
+ <version>1.0.0-M9-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shared-ipojo-manager</artifactId>
+ <name>ApacheDS Shared OSGI/IPOJO Manager</name>
+ <packaging>bundle</packaging>
+
+ <description>Provides main facility for handling IPojo component management</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.annotations</artifactId>
+ <version>1.8.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.handler.whiteboard</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>shared-ldap-model</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <inherited>true</inherited>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Activator>org.apache.directory.shared.ipojo.helpers.OSGIHelpersActivator</Bundle-Activator>
+ <Export-Package>
+ {local-packages};version=${project.version};-noimport:=true
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>1.8.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
Added: directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/IPojoHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/IPojoHelper.java?rev=1188117&view=auto
==============================================================================
--- directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/IPojoHelper.java (added)
+++ directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/IPojoHelper.java Mon Oct 24 12:34:54 2011
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ *
+ */
+package org.apache.directory.shared.ipojo.helpers;
+
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.felix.ipojo.ComponentFactory;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.MissingHandlerException;
+import org.apache.felix.ipojo.UnacceptableConfiguration;
+
+
+public class IPojoHelper
+{
+ public static ComponentFactory getFactory( String factoryName )
+ {
+ try
+ {
+ String filter = "(factory.name=" + factoryName + ")";
+ List<ComponentFactory> factories = ( List<ComponentFactory> ) OSGIHelper.getServices( Factory.class.getName(), filter );
+ if ( factories == null )
+ {
+ return null;
+ }
+ return factories.get( 0 );
+ }
+ catch ( ClassCastException e )
+ {
+ return null;
+ }
+ }
+
+
+ public static Object createIPojoComponent( String factoryName, String instanceName, Dictionary<String,String> props )
+ {
+ ComponentFactory factory = IPojoHelper.getFactory( factoryName );
+ if ( factory == null )
+ {
+ return null;
+ }
+
+ if ( instanceName != null )
+ {
+ if ( props == null )
+ {
+ props = new Hashtable<String, String>();
+ }
+ props.put( "instance.name", instanceName );
+ }
+
+ try
+ {
+ ComponentInstance comp = factory.createComponentInstance( props );
+ Object instance = ( ( InstanceManager ) comp ).getPojoObject();
+
+ return instance;
+ }
+ catch ( UnacceptableConfiguration e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ catch ( MissingHandlerException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ catch ( ConfigurationException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+
+ }
+}
Added: directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelper.java?rev=1188117&view=auto
==============================================================================
--- directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelper.java (added)
+++ directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelper.java Mon Oct 24 12:34:54 2011
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ *
+ */
+package org.apache.directory.shared.ipojo.helpers;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+
+public class OSGIHelper
+{
+ /** BundleContext reference which will be assigned through BundleActivator */
+ public static BundleContext bundleCtx;
+
+
+ private static boolean checkOSGIContext()
+ {
+ if ( bundleCtx == null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ public static List<?> getServices( String serviceClassName, String filter )
+ {
+ if ( !checkOSGIContext() )
+ {
+ return null;
+ }
+
+ try
+ {
+ ServiceReference[] serviceReferences = bundleCtx.getServiceReferences( serviceClassName, filter );
+ List<Object> services = new ArrayList<Object>();
+ for ( ServiceReference ref : serviceReferences )
+ {
+ services.add( bundleCtx.getService( ref ) );
+ }
+
+ return services;
+ }
+ catch ( InvalidSyntaxException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ catch ( IllegalStateException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+
+ public static Object getService( String serviceClassName )
+ {
+ if ( !checkOSGIContext() )
+ {
+ return null;
+ }
+
+ ServiceReference ref = bundleCtx.getServiceReference( serviceClassName );
+ if ( ref == null )
+ {
+ return null;
+ }
+
+ try
+ {
+ return bundleCtx.getService( ref );
+ }
+ catch ( IllegalStateException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static Object getServiceObject(ServiceReference ref)
+ {
+ try
+ {
+ return bundleCtx.getService( ref );
+ }
+ catch ( IllegalStateException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
Added: directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelpersActivator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelpersActivator.java?rev=1188117&view=auto
==============================================================================
--- directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelpersActivator.java (added)
+++ directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/helpers/OSGIHelpersActivator.java Mon Oct 24 12:34:54 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ */
+package org.apache.directory.shared.ipojo.helpers;
+
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * BundleActivator to keep and release BundleContext reference for further uses by helper classes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OSGIHelpersActivator implements BundleActivator
+{
+
+ public void start( BundleContext context ) throws Exception
+ {
+ //Save the BundleContext reference
+ OSGIHelper.bundleCtx = context;
+ }
+
+
+ public void stop( BundleContext context ) throws Exception
+ {
+ //Null the BundleContext reference
+ OSGIHelper.bundleCtx = null;
+ }
+}
Added: directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/schema/SchemaElementsManager.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/schema/SchemaElementsManager.java?rev=1188117&view=auto
==============================================================================
--- directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/schema/SchemaElementsManager.java (added)
+++ directory/shared/branches/shared-osgi/ipojo-manager/src/main/java/org/apache/directory/shared/ipojo/schema/SchemaElementsManager.java Mon Oct 24 12:34:54 2011
@@ -0,0 +1,54 @@
+package org.apache.directory.shared.ipojo.schema;
+
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.directory.shared.ipojo.helpers.IPojoHelper;
+import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.directory.shared.ldap.model.schema.Normalizer;
+import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
+
+
+public class SchemaElementsManager
+{
+ public LdapComparator<?> getLdapComparator( String factoryName, String oid ) throws Exception
+ {
+ Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put( "ads.comp.comparator.oid", oid );
+
+ LdapComparator<?> comparator = ( LdapComparator<?> ) IPojoHelper
+ .createIPojoComponent( factoryName, null, props );
+
+ if ( comparator == null )
+ {
+ throw new Exception( "Required Comparator is not registered" );
+ }
+
+ return comparator;
+ }
+
+ /*
+ public Normalizer getNormalizer( String factoryName ) throws Exception
+ {
+ Normalizer comparator = activeNormalizers.get( factoryName );
+ if ( comparator == null )
+ {
+ throw new Exception( "Required Normalizer is not registered" );
+ }
+
+ return comparator;
+ }
+
+
+ public SyntaxChecker getSyntaxChecker( String factoryName ) throws Exception
+ {
+ SyntaxChecker comparator = activeSyntaxCheckers.get( factoryName );
+ if ( comparator == null )
+ {
+ throw new Exception( "Required SyntaxChecker is not registered" );
+ }
+
+ return comparator;
+ }*/
+}
Modified: directory/shared/branches/shared-osgi/ldap/model/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/pom.xml?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/pom.xml (original)
+++ directory/shared/branches/shared-osgi/ldap/model/pom.xml Mon Oct 24 12:34:54 2011
@@ -76,6 +76,12 @@
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.annotations</artifactId>
+ <version>1.8.0</version>
+ </dependency>
</dependencies>
<build>
@@ -144,6 +150,19 @@
</instructions>
</configuration>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>1.8.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/EntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/EntityFactory.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/EntityFactory.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/EntityFactory.java Mon Oct 24 12:34:54 2011
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.ldap.model.schema;
+
import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.schema.parsers.LdapComparatorDescription;
@@ -27,6 +28,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.schema.parsers.SyntaxCheckerDescription;
import org.apache.directory.shared.ldap.model.schema.registries.Registries;
+
public interface EntityFactory
{
/**
@@ -37,8 +39,8 @@ public interface EntityFactory
* @throws Exception If the instance can't be created
*/
Schema getSchema( Entry entry ) throws Exception;
-
-
+
+
/**
* Construct an AttributeType from an entry representing an AttributeType.
*
@@ -49,9 +51,10 @@ public interface EntityFactory
* @return An AttributeType SchemaObject
* @throws LdapException If the AttributeType is invalid
*/
- AttributeType getAttributeType( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) throws LdapException;
+ AttributeType getAttributeType( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
+ String schemaName ) throws LdapException;
+
-
/**
* Construct a LdapComparator from a description of a comparator.
*
@@ -62,11 +65,11 @@ public interface EntityFactory
* @return A new instance of a LdapComparator
* @throws Exception If the creation has failed
*/
- LdapComparator<?> getLdapComparator( SchemaManager schemaManager,
+ LdapComparator<?> getLdapComparator( SchemaManager schemaManager,
LdapComparatorDescription comparatorDescription,
Registries targetRegistries, String schemaName ) throws Exception;
-
-
+
+
/**
* Retrieve and load a Comparator class from the DIT.
*
@@ -77,9 +80,23 @@ public interface EntityFactory
* @return the loaded Comparator
* @throws LdapException if anything fails during loading
*/
- LdapComparator<?> getLdapComparator( SchemaManager schemaManager, Entry entry,
+ LdapComparator<?> getLdapComparator( SchemaManager schemaManager, Entry entry,
Registries targetRegistries, String schemaName ) throws LdapException;
-
+
+
+ /**
+ * Retrieve and load a Comparator class through OSGI from the DIT.
+ *
+ * @param schemaManager The Schema Manager
+ * @param entry The entry containing all the informations to build a LdapComparator
+ * @param targetRegistries The registries containing all the enabled SchemaObjects
+ * @param schemaName The schema this SchemaObject will be part of
+ * @return the loaded Comparator
+ * @throws LdapException if anything fails during loading
+ */
+ LdapComparator<?> getLdapComparatorOSGI( SchemaManager schemaManager, Entry entry,
+ Registries targetRegistries, String schemaName ) throws LdapException;
+
/**
* Construct an MatchingRule from an entry get from the Dit
@@ -91,7 +108,8 @@ public interface EntityFactory
* @return A MatchingRule SchemaObject
* @throws LdapException If the MatchingRule is invalid
*/
- MatchingRule getMatchingRule( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) throws LdapException;
+ MatchingRule getMatchingRule( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
+ String schemaName ) throws LdapException;
/**
@@ -106,8 +124,8 @@ public interface EntityFactory
*/
Normalizer getNormalizer( SchemaManager schemaManager, NormalizerDescription normalizerDescription,
Registries targetRegistries, String schemaName ) throws Exception;
-
-
+
+
/**
* Retrieve and load a Normalizer class from the DIT.
*
@@ -120,8 +138,8 @@ public interface EntityFactory
*/
Normalizer getNormalizer( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName )
throws LdapException;
-
-
+
+
/**
*
* @param schemaManager The Schema Manager
@@ -131,9 +149,10 @@ public interface EntityFactory
* @return
* @throws Exception
*/
- ObjectClass getObjectClass( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) throws LdapException;
-
-
+ ObjectClass getObjectClass( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName )
+ throws LdapException;
+
+
/**
*
* @param schemaManager The Schema Manager
@@ -143,9 +162,10 @@ public interface EntityFactory
* @return
* @throws LdapException
*/
- LdapSyntax getSyntax( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) throws LdapException;
-
-
+ LdapSyntax getSyntax( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName )
+ throws LdapException;
+
+
/**
* Retrieve and load a syntaxChecker class from the DIT.
*
@@ -156,8 +176,9 @@ public interface EntityFactory
* @return the loaded SyntaxChecker
* @throws LdapException if anything fails during loading
*/
- SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) throws LdapException;
-
+ SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
+ String schemaName ) throws LdapException;
+
/**
* Create a new instance of a SyntaxChecker
@@ -169,6 +190,6 @@ public interface EntityFactory
* @return A new instance of a syntaxChecker
* @throws Exception If the creation has failed
*/
- SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, SyntaxCheckerDescription syntaxCheckerDescription,
+ SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, SyntaxCheckerDescription syntaxCheckerDescription,
Registries targetRegistries, String schemaName ) throws Exception;
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BitStringComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BitStringComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BitStringComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BitStringComparator.java Mon Oct 24 12:34:54 2011
@@ -21,6 +21,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,19 +33,29 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class BitStringComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( BitStringComparator.class );
+
/**
* The BitStringComparator constructor. Its OID is the IntegerOrderingMatch matching
* rule OID.
*/
- public BitStringComparator( String oid )
+ public BitStringComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -52,7 +65,7 @@ public class BitStringComparator extends
* Implementation of the Compare method
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ES_COMPARING_PARAMETER_STRING_WITH_EQ",
- justification ="false positive")
+ justification = "false positive")
public int compare( String bs1, String bs2 )
{
LOG.debug( "comparing BitString objects '{}' with '{}'", bs1, bs2 );
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BooleanComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BooleanComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BooleanComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/BooleanComparator.java Mon Oct 24 12:34:54 2011
@@ -21,6 +21,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,19 +33,29 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class BooleanComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( BooleanComparator.class );
+
/**
* The BooleanComparator constructor. Its OID is the BooleanMatch matching
* rule OID.
*/
- public BooleanComparator( String oid )
+ public BooleanComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparator.java Mon Oct 24 12:34:54 2011
@@ -22,6 +22,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.util.Strings;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,30 +34,41 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class ByteArrayComparator extends LdapComparator<byte[]>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( ByteArrayComparator.class );
+
/**
* The ByteArrayComparator constructor. Its OID is the OctetStringMatch matching
* rule OID.
*/
- public ByteArrayComparator( String oid )
+ public ByteArrayComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
+
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare( byte[] b1, byte[] b2 )
{
- LOG.debug( "comparing OctetString objects '{}' with '{}'",
- Strings.dumpBytes(b1), Strings.dumpBytes(b2) );
+ LOG.debug( "comparing OctetString objects '{}' with '{}'",
+ Strings.dumpBytes( b1 ), Strings.dumpBytes( b2 ) );
// -------------------------------------------------------------------
// Handle some basis cases
@@ -64,12 +78,12 @@ public class ByteArrayComparator extends
{
return ( b2 == null ) ? 0 : -1;
}
-
+
if ( b2 == null )
{
return 1;
}
-
+
if ( b1.length == b2.length )
{
for ( int i = 0; i < b1.length; i++ )
@@ -83,12 +97,12 @@ public class ByteArrayComparator extends
return -1;
}
}
-
+
return 0;
}
-
+
int minLength = Math.min( b1.length, b2.length );
-
+
for ( int i = 0; i < minLength; i++ )
{
if ( b1[i] > b2[i] )
@@ -100,19 +114,19 @@ public class ByteArrayComparator extends
return -1;
}
}
-
+
// b2 is longer w/ b1 as prefix
if ( b1.length == minLength )
{
return -1;
}
-
+
// b1 is longer w/ b2 as prefix
if ( b2.length == minLength )
{
return 1;
}
-
+
return 0;
}
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ComparableComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ComparableComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ComparableComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ComparableComparator.java Mon Oct 24 12:34:54 2011
@@ -22,6 +22,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,20 +35,30 @@ import org.slf4j.LoggerFactory;
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @param <T> the type, must extend {@link Comparable}
*/
+@Component
+@Provides
public class ComparableComparator<T> extends LdapComparator<Comparable<T>>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( ComparableComparator.class );
+
/**
* The ComparableComparator constructor.
*
* @param oid the comparator OID
*/
- public ComparableComparator( String oid )
+ public ComparableComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnComparator.java Mon Oct 24 12:34:54 2011
@@ -22,6 +22,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.entry.StringValue;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,19 +40,29 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class CsnComparator extends LdapComparator<Object>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( CsnComparator.class );
+
/**
* The CsnComparator constructor. Its OID is the CsnMatch matching
* rule OID.
*/
- public CsnComparator( String oid )
+ public CsnComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -61,7 +74,7 @@ public class CsnComparator extends LdapC
public int compare( Object csnObj1, Object csnObj2 )
{
LOG.debug( "comparing CSN objects '{}' with '{}'", csnObj1, csnObj2 );
-
+
if ( csnObj1 == csnObj2 )
{
return 0;
@@ -74,15 +87,15 @@ public class CsnComparator extends LdapC
{
return ( csnObj2 == null ) ? 0 : -1;
}
-
+
if ( csnObj2 == null )
{
return 1;
}
-
+
String csnStr1 = null;
String csnStr2 = null;
-
+
if ( csnObj1 instanceof StringValue )
{
csnStr1 = ( ( StringValue ) csnObj1 ).getValue();
@@ -94,13 +107,13 @@ public class CsnComparator extends LdapC
if ( csnObj2 instanceof StringValue )
{
- csnStr2 = ( (StringValue) csnObj2 ).getValue();
+ csnStr2 = ( ( StringValue ) csnObj2 ).getValue();
}
else
{
csnStr2 = csnObj2.toString();
}
-
+
return csnStr1.compareTo( csnStr2 );
}
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnSidComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnSidComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnSidComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/CsnSidComparator.java Mon Oct 24 12:34:54 2011
@@ -21,6 +21,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,24 +35,34 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class CsnSidComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( CsnSidComparator.class );
+
/**
* The CsnSidComparator constructor. Its OID is the CsnSidMatch matching
* rule OID.
*/
- public CsnSidComparator( String oid )
+ public CsnSidComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
-
-
+
+
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@@ -64,15 +77,15 @@ public class CsnSidComparator extends Ld
{
return ( sidStr2 == null ) ? 0 : -1;
}
-
+
if ( sidStr2 == null )
{
return 1;
}
-
+
int sid1 = 0;
int sid2 = 0;
-
+
try
{
sid1 = Integer.parseInt( sidStr1, 16 );
@@ -81,7 +94,7 @@ public class CsnSidComparator extends Ld
{
return -1;
}
-
+
try
{
sid2 = Integer.parseInt( sidStr2, 16 );
@@ -90,7 +103,7 @@ public class CsnSidComparator extends Ld
{
return 1;
}
-
+
if ( sid1 > sid2 )
{
return 1;
@@ -99,7 +112,7 @@ public class CsnSidComparator extends Ld
{
return -1;
}
-
+
return 0;
}
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java Mon Oct 24 12:34:54 2011
@@ -22,6 +22,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.normalizers.CachingNormalizer;
import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimNormalizer;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
/**
@@ -29,13 +32,24 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class DeepTrimCachingNormalizingComparator extends NormalizingComparator
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public DeepTrimCachingNormalizingComparator( String oid )
+
+ @SuppressWarnings(
+ { "rawtypes", "unchecked" })
+ public DeepTrimCachingNormalizingComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid, new CachingNormalizer( new DeepTrimNormalizer( oid ), 10 ),
new ComparableComparator( oid ) );
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java Mon Oct 24 12:34:54 2011
@@ -22,6 +22,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.normalizers.CachingNormalizer;
import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
/**
@@ -29,13 +32,24 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class DeepTrimToLowerCachingNormalizingComparator extends NormalizingComparator
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public DeepTrimToLowerCachingNormalizingComparator( String oid )
+
+ @SuppressWarnings(
+ { "rawtypes", "unchecked" })
+ public DeepTrimToLowerCachingNormalizingComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid, new CachingNormalizer( new DeepTrimToLowerNormalizer( oid ), 10 ),
new ComparableComparator( oid ) );
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java Mon Oct 24 12:34:54 2011
@@ -26,6 +26,9 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.name.Dn;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
/**
@@ -33,29 +36,39 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class DnComparator extends LdapComparator<Object>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
- /** A reference to the schema manager */
+ /** A reference to the schema manager */
private SchemaManager schemaManager;
-
- public DnComparator( String oid )
+
+
+ public DnComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
-
-
+
+
/**
* {@inheritDoc}
*/
- public int compare( Object obj0, Object obj1 )
+ public int compare( Object obj0, Object obj1 )
{
Dn dn0 = null;
Dn dn1 = null;
-
- try
+
+ try
{
dn0 = getDn( obj0 );
dn1 = getDn( obj1 );
@@ -65,7 +78,7 @@ public class DnComparator extends LdapCo
// -- what do we do here ?
return -1;
}
-
+
if ( dn0.equals( dn1 ) )
{
return 0;
@@ -80,11 +93,11 @@ public class DnComparator extends LdapCo
private Dn getDn( Object obj ) throws LdapInvalidDnException
{
Dn dn = null;
-
- if ( obj instanceof Dn)
+
+ if ( obj instanceof Dn )
{
- dn = (Dn)obj;
-
+ dn = ( Dn ) obj;
+
dn = ( dn.isSchemaAware() ? dn : dn.apply( schemaManager ) );
}
else if ( obj instanceof String )
@@ -93,9 +106,9 @@ public class DnComparator extends LdapCo
}
else
{
- throw new IllegalStateException( I18n.err( I18n.ERR_04218, (obj == null ? null : obj.getClass() ) ) );
+ throw new IllegalStateException( I18n.err( I18n.ERR_04218, ( obj == null ? null : obj.getClass() ) ) );
}
-
+
return dn;
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/GeneralizedTimeComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/GeneralizedTimeComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/GeneralizedTimeComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/GeneralizedTimeComparator.java Mon Oct 24 12:34:54 2011
@@ -27,6 +27,9 @@ import org.apache.directory.shared.i18n.
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.ldap.model.schema.PrepareString;
import org.apache.directory.shared.util.GeneralizedTime;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,19 +39,29 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class GeneralizedTimeComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( GeneralizedTimeComparator.class );
+
/**
* The GeneralizedTimeComparator constructor. Its OID is the
* generalizedTimeOrderingMatch matching rule OID.
*/
- public GeneralizedTimeComparator( String oid )
+ public GeneralizedTimeComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -58,7 +71,7 @@ public class GeneralizedTimeComparator e
* Implementation of the Compare method
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ES_COMPARING_PARAMETER_STRING_WITH_EQ",
- justification ="false positive")
+ justification = "false positive")
public int compare( String backendValue, String assertValue )
{
LOG.debug( "comparing generalizedTimeOrdering objects '{}' with '{}'", backendValue, assertValue );
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/IntegerComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/IntegerComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/IntegerComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/IntegerComparator.java Mon Oct 24 12:34:54 2011
@@ -27,6 +27,9 @@ import java.math.BigInteger;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.ldap.model.schema.PrepareString;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,19 +39,29 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class IntegerComparator extends LdapComparator<Object> implements Serializable
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( IntegerComparator.class );
+
/**
* The IntegerComparator constructor. Its OID is the IntegerOrderingMatch matching
* rule OID.
*/
- public IntegerComparator( String oid )
+ public IntegerComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -74,7 +87,7 @@ public class IntegerComparator extends L
* Implementation of the Compare method
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "RC_REF_COMPARISON",
- justification ="false positive")
+ justification = "false positive")
private int compare( Long backendValue, Long assertValue )
{
LOG.debug( "comparing Integer objects '{}' with '{}'", backendValue, assertValue );
@@ -103,7 +116,7 @@ public class IntegerComparator extends L
* Implementation of the Compare method
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ES_COMPARING_PARAMETER_STRING_WITH_EQ",
- justification ="false positive")
+ justification = "false positive")
private int compare( String backendValue, String assertValue )
{
LOG.debug( "comparing Integer objects '{}' with '{}'", backendValue, assertValue );
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/LongComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/LongComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/LongComparator.java Mon Oct 24 12:34:54 2011
@@ -24,6 +24,9 @@ import java.io.Serializable;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
/**
@@ -31,16 +34,26 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class LongComparator extends LdapComparator<Long> implements Serializable
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
+
/**
* The LongComparator constructor. Its OID is the IntegerOrderingMatch matching
* rule OID.
*/
- public LongComparator( String oid )
+ public LongComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -54,7 +67,7 @@ public class LongComparator extends Ldap
* @return 1 if obj1 > obj2, 0 if obj1 == obj2, -1 if obj1 < obj2
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "RC_REF_COMPARISON",
- justification ="false positive")
+ justification = "false positive")
public int compare( Long obj1, Long obj2 )
{
if ( obj1 == obj2 )
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NormalizingComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NormalizingComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NormalizingComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NormalizingComparator.java Mon Oct 24 12:34:54 2011
@@ -42,10 +42,10 @@ import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger( NormalizingComparator.class );
/** the Normalizer to normalize values with before comparing */
- private Normalizer normalizer;
+ protected Normalizer normalizer;
/** the underlying comparator to use for comparisons */
- private LdapComparator<String> comparator;
+ protected LdapComparator<String> comparator;
/**
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NumericStringComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NumericStringComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NumericStringComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/NumericStringComparator.java Mon Oct 24 12:34:54 2011
@@ -25,6 +25,9 @@ import java.io.IOException;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.ldap.model.schema.PrepareString;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,19 +37,29 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class NumericStringComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( NumericStringComparator.class );
+
/**
* The IntegerComparator constructor. Its OID is the numericStringOrderingMatch matching
* rule OID.
*/
- public NumericStringComparator( String oid )
+ public NumericStringComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -56,7 +69,7 @@ public class NumericStringComparator ext
* Implementation of the Compare method
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ES_COMPARING_PARAMETER_STRING_WITH_EQ",
- justification ="false positive")
+ justification = "false positive")
public int compare( String backendValue, String assertValue )
{
LOG.debug( "comparing numericStringOrdering objects '{}' with '{}'", backendValue, assertValue );
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectClassTypeComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectClassTypeComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectClassTypeComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectClassTypeComparator.java Mon Oct 24 12:34:54 2011
@@ -22,6 +22,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.util.Strings;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
/**
@@ -30,40 +33,51 @@ import org.apache.directory.shared.util.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ObjectClassTypeComparator<T> extends LdapComparator<T>
+@Component
+@Provides
+public class ObjectClassTypeComparator<T> extends LdapComparator<T>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
- public ObjectClassTypeComparator( String oid )
+
+ public ObjectClassTypeComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
-
+
+
public int compare( T o1, T o2 )
{
String s1 = getString( o1 );
String s2 = getString( o2 );
-
+
if ( s1 == null && s2 == null )
{
return 0;
}
-
+
if ( s1 == null )
{
return -1;
}
-
+
if ( s2 == null )
{
return 1;
}
-
+
return s1.compareTo( s2 );
}
-
-
+
+
String getString( T obj )
{
String strValue;
@@ -72,14 +86,14 @@ public class ObjectClassTypeComparator<T
{
return null;
}
-
+
if ( obj instanceof String )
{
strValue = ( String ) obj;
}
else if ( obj instanceof byte[] )
{
- strValue = Strings.utf8ToString((byte[]) obj);
+ strValue = Strings.utf8ToString( ( byte[] ) obj );
}
else
{
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierComparator.java Mon Oct 24 12:34:54 2011
@@ -21,6 +21,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,19 +33,29 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class ObjectIdentifierComparator extends LdapComparator<Object>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( ObjectIdentifierComparator.class );
+
/**
* The ObjectIdentifierComparator constructor. Its OID is the ObjectIdentifierMatch matching
* rule OID.
*/
- public ObjectIdentifierComparator( String oid )
+ public ObjectIdentifierComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -84,6 +97,6 @@ public class ObjectIdentifierComparator
}
// Here, we should leverage the SchemaManager to compare the String and teh OID
- return ((String)o1).compareToIgnoreCase( (String)o2 );
+ return ( ( String ) o1 ).compareToIgnoreCase( ( String ) o2 );
}
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierFirstComponentComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierFirstComponentComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierFirstComponentComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/ObjectIdentifierFirstComponentComparator.java Mon Oct 24 12:34:54 2011
@@ -24,6 +24,9 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.util.Chars;
import org.apache.directory.shared.util.Strings;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,24 +36,34 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class ObjectIdentifierFirstComponentComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( ObjectIdentifierFirstComponentComparator.class );
+
/**
* The ObjectIdentifierFirstComponentComparator constructor. Its OID is the
* ObjectIdentifierFirstComponentMatch matching rule OID.
*/
- public ObjectIdentifierFirstComponentComparator( String oid )
+ public ObjectIdentifierFirstComponentComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
-
+
/**
* Get the OID from the SchemaObject description
*/
@@ -58,27 +71,27 @@ public class ObjectIdentifierFirstCompon
{
// Get the OID from the strings now
int pos = 0;
-
+
if ( !Strings.isCharASCII( s, pos++, '(' ) )
{
return null;
}
-
+
while ( Strings.isCharASCII( s, pos, ' ' ) )
{
pos++;
}
-
+
int start = pos;
-
- while ( Chars.isDigit(s, pos) || Strings.isCharASCII( s, pos, '.' ) )
+
+ while ( Chars.isDigit( s, pos ) || Strings.isCharASCII( s, pos, '.' ) )
{
pos++;
}
-
+
String numericOid = s.substring( start, pos );
-
- if ( Oid.isOid(numericOid) )
+
+ if ( Oid.isOid( numericOid ) )
{
return numericOid;
}
@@ -87,7 +100,8 @@ public class ObjectIdentifierFirstCompon
return null;
}
}
-
+
+
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@@ -102,7 +116,7 @@ public class ObjectIdentifierFirstCompon
{
return ( s2 == null ) ? 0 : -1;
}
-
+
if ( s2 == null )
{
return -1;
@@ -113,22 +127,22 @@ public class ObjectIdentifierFirstCompon
{
return 0;
}
-
+
// Get the OID from the strings now
String oid1 = getNumericOid( s1 );
-
+
if ( oid1 == null )
{
return -1;
}
-
+
String oid2 = getNumericOid( s2 );
if ( oid2 == null )
{
return -1;
}
-
+
if ( oid1.equals( oid2 ) )
{
return 0;
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/SerializableComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/SerializableComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/SerializableComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/SerializableComparator.java Mon Oct 24 12:34:54 2011
@@ -27,6 +27,10 @@ import org.apache.directory.shared.i18n.
import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.annotations.Validate;
/**
@@ -43,13 +47,14 @@ public class SerializableComparator<E> e
/** the OID of the matchingRule for this comparator */
private String matchingRuleOid;
-
+
/** the transient wrapped comparator */
private transient Comparator<E> wrapped;
- /** A reference to the schema manager */
+ /** A reference to the schema manager */
private transient SchemaManager schemaManager;
-
+
+
// ------------------------------------------------------------------------
// C O N T R U C T O R S
// ------------------------------------------------------------------------
@@ -74,7 +79,7 @@ public class SerializableComparator<E> e
{
try
{
- wrapped = (Comparator<E>)schemaManager.lookupComparatorRegistry( matchingRuleOid );
+ wrapped = ( Comparator<E> ) schemaManager.lookupComparatorRegistry( matchingRuleOid );
}
catch ( LdapException e )
{
@@ -96,18 +101,18 @@ public class SerializableComparator<E> e
{
try
{
- wrapped = ( Comparator<E> )
+ wrapped = ( Comparator<E> )
schemaManager.lookupComparatorRegistry( matchingRuleOid );
}
catch ( LdapException ne )
{
// Not found : get the default comparator
- wrapped = ( Comparator<E> )
+ wrapped = ( Comparator<E> )
new ComparableComparator<Comparable<E>>( matchingRuleOid );
}
}
- ((LdapComparator<E>)wrapped).setSchemaManager( schemaManager );
+ ( ( LdapComparator<E> ) wrapped ).setSchemaManager( schemaManager );
super.setSchemaManager( schemaManager );
}
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/StringComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/StringComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/StringComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/StringComparator.java Mon Oct 24 12:34:54 2011
@@ -23,6 +23,9 @@ package org.apache.directory.shared.ldap
import java.io.Serializable;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,12 +35,20 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class StringComparator extends LdapComparator<String> implements Serializable
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
-
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( StringComparator.class );
@@ -46,7 +57,7 @@ public class StringComparator extends Ld
* The StringComparator constructor. Its OID is the StringMatch matching
* rule OID.
*/
- public StringComparator( String oid )
+ public StringComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
@@ -56,7 +67,7 @@ public class StringComparator extends Ld
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ES_COMPARING_PARAMETER_STRING_WITH_EQ",
- justification ="false positive")
+ justification = "false positive")
public int compare( String s1, String s2 )
{
LOG.debug( "comparing String objects '{}' with '{}'", s1, s2 );
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/TelephoneNumberComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/TelephoneNumberComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/TelephoneNumberComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/TelephoneNumberComparator.java Mon Oct 24 12:34:54 2011
@@ -21,6 +21,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,24 +36,34 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class TelephoneNumberComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( TelephoneNumberComparator.class );
+
/**
* The TelephoneNumberComparator constructor. Its OID is the TelephoneNumberMatch matching
* rule OID.
*/
- public TelephoneNumberComparator( String oid )
+ public TelephoneNumberComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
-
+
/**
* Remove all spaces and '-' from the telephone number
*/
@@ -58,21 +71,21 @@ public class TelephoneNumberComparator e
{
char[] telephoneNumberArray = telephoneNumber.toCharArray();
int pos = 0;
-
- for ( char c:telephoneNumberArray )
+
+ for ( char c : telephoneNumberArray )
{
if ( ( c == ' ' ) || ( c == '-' ) )
- {
+ {
continue;
}
-
+
telephoneNumberArray[pos++] = c;
}
-
+
return new String( telephoneNumberArray, 0, pos );
}
-
+
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@@ -87,18 +100,18 @@ public class TelephoneNumberComparator e
{
return ( telephoneNumber2 == null ) ? 0 : -1;
}
-
+
if ( telephoneNumber2 == null )
{
return 1;
}
-
+
// -------------------------------------------------------------------
// Remove all spaces and '-'
// -------------------------------------------------------------------
String strippedTelephoneNumber1 = strip( telephoneNumber1 );
String strippedTelephoneNumber2 = strip( telephoneNumber2 );
-
+
return ( strippedTelephoneNumber1.compareToIgnoreCase( strippedTelephoneNumber2 ) );
}
}
Modified: directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UUIDComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UUIDComparator.java?rev=1188117&r1=1188116&r2=1188117&view=diff
==============================================================================
--- directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UUIDComparator.java (original)
+++ directory/shared/branches/shared-osgi/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UUIDComparator.java Mon Oct 24 12:34:54 2011
@@ -21,6 +21,9 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,24 +33,34 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
+@Component
+@Provides
public class UUIDComparator extends LdapComparator<String>
{
+ /**
+ * Property to specify factory type.
+ * TODO:This is temporary. Will be vanished after introducing custom annotations
+ */
+ @Property(name = "ads.comp.type", value = "comparator")
+ public String compType;
+
/** The serial version UID */
private static final long serialVersionUID = 2L;
/** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( UUIDComparator.class );
+
/**
* The UUIDComparator constructor. Its OID is the UUIDMatch matching
* rule OID.
*/
- public UUIDComparator( String oid )
+ public UUIDComparator( @Property(name = "ads.comp.comparator.oid") String oid )
{
super( oid );
}
-
+
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@@ -62,12 +75,12 @@ public class UUIDComparator extends Ldap
{
return ( uuid2 == null ) ? 0 : -1;
}
-
+
if ( uuid2 == null )
{
return 1;
}
-
+
return uuid1.compareTo( uuid2 );
}
}