directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@apache.org>
Subject Re: svn commit: r1203217 - in /directory/apacheds/trunk: ./ component-hub/ component-hub/src/ component-hub/src/main/ component-hub/src/main/java/ component-hub/src/main/java/org/ component-hub/src/main/java/org/apache/ component-hub/src/main/java/or
Date Fri, 18 Nov 2011 11:03:03 GMT
I confirm, but i forgot to discuss that on the ml. My bad.
Le 18 nov. 2011 10:55, "Göktürk Gezer" <gokturk.gezer@gmail.com> a écrit :

> Hi Pierre,
>
> On Nov 18, 2011 11:50 AM, "Pierre-Arnaud Marcelot" <pa@marcelot.net>
> wrote:
> >
> > Hi Göktürk,
> >
> > As I was merging modifications from trunk to the OSGI branch, I noticed
> this commit was done on trunk instead of the OSGI branch.
> > Was this on purpose?
> This is what Emmanuel wanted. He did not want to deal with merging.
> Actually my things are all seperated from the main code for now. It can be
> merged back easilly.
> >
> > Regards,
> > Pierre-Arnaud
> >
> > On 17 nov. 2011, at 16:21, gokturk@apache.org wrote:
> >
> > > Author: gokturk
> > > Date: Thu Nov 17 15:21:39 2011
> > > New Revision: 1203217
> > >
> > > URL: http://svn.apache.org/viewvc?rev=1203217&view=rev
> > > Log:
> > > First work on ApacheDS ComponentHub ( the IPojo based main plug-in
> layer).
> > >
> > > TODO:
> > > * Implement ComponentManager for ComponentHub's clients to manage
> component instances,schema and configuration
> > > * Implement entry cache to preserve component instance configuration
> across server sessions.
> > > * Add test cases for "customuser" typed components.
> > > ......
> > > * Create InterceptorHubClient to manage interceptors using plug-in
> layer.
> > >
> > >
> > > Added:
> > >    directory/apacheds/trunk/component-hub/
> > >    directory/apacheds/trunk/component-hub/pom.xml
> > >    directory/apacheds/trunk/component-hub/src/
> > >    directory/apacheds/trunk/component-hub/src/main/
> > >    directory/apacheds/trunk/component-hub/src/main/java/
> > >    directory/apacheds/trunk/component-hub/src/main/java/org/
> > >    directory/apacheds/trunk/component-hub/src/main/java/org/apache/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponent.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponentHandler.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentSchemaGenerator.java
> > >
>  directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java
> > > Modified:
> > >    directory/apacheds/trunk/pom.xml
> > >
> > > Added: directory/apacheds/trunk/component-hub/pom.xml
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/pom.xml?rev=1203217&view=auto
> > >
> ==============================================================================
> > > --- directory/apacheds/trunk/component-hub/pom.xml (added)
> > > +++ directory/apacheds/trunk/component-hub/pom.xml Thu Nov 17 15:21:39
> 2011
> > > @@ -0,0 +1,97 @@
> > > +<?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.server</groupId>
> > > +    <artifactId>apacheds-parent</artifactId>
> > > +    <version>2.0.0-M4-SNAPSHOT</version>
> > > +  </parent>
> > > +
> > > +  <artifactId>apacheds-component-hub</artifactId>
> > > +  <name>ApacheDS Component Hub</name>
> > > +  <packaging>bundle</packaging>
> > > +  <description>Provides main plugin-layer for ApacheDS</description>
> > > +
> > > +  <dependencies>
> > > +
> > > +    <dependency>
> > > +      <groupId>org.apache.directory.server</groupId>
> > > +      <artifactId>apacheds-core-api</artifactId>
> > > +    </dependency>
> > > +
> > > +    <dependency>
> > > +      <groupId>org.apache.directory.shared</groupId>
> > > +      <artifactId>shared-ldap-model</artifactId>
> > > +    </dependency>
> > > +
> > > +    <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>org.osgi</groupId>
> > > +      <artifactId>org.osgi.core</artifactId>
> > > +      <version>4.3.0</version>
> > > +    </dependency>
> > > +
> > > +  </dependencies>
> > > +
> > > +  <build>
> > > +    <plugins>
> > > +      <plugin>
> > > +        <groupId>org.apache.felix</groupId>
> > > +        <artifactId>maven-bundle-plugin</artifactId>
> > > +        <inherited>true</inherited>
> > > +        <extensions>true</extensions>
> > > +        <configuration>
> > > +          <manifestLocation>META-INF</manifestLocation>
> > > +          <instructions>
> > > +
>  <Bundle-SymbolicName>${project.groupId}.component.hub</Bundle-SymbolicName>
> > > +          </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/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,49 @@
> > > +/*
> > > + *  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.server.component;
> > > +
> > > +import java.util.List;
> > > +
> > > +import org.apache.directory.shared.ldap.model.ldif.LdifReader;
> > > +import org.apache.felix.ipojo.ComponentFactory;
> > > +
> > > +/**
> > > + * Class that represents a component for ApacheDS use.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public class ADSComponent
> > > +{
> > > +    private ComponentFactory factory;
> > > +
> > > +    private String componentType = "user";
> > > +
> > > +    private String componentSchemaDn;
> > > +
> > > +    private List<ADSComponentInstance> instances;
> > > +
> > > +    private LdifReader cacheHandle;
> > > +
> > > +    public ComponentFactory getFactory()
> > > +    {
> > > +        return factory;
> > > +    }
> > > +
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,39 @@
> > > +/*
> > > + *  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.server.component;
> > > +
> > > +import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
> > > +
> > > +/**
> > > + * Class that represents an individual instance of an ADSComponent
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public class ADSComponentInstance
> > > +{
> > > +    private LdifEntry instanceEntry;
> > > +
> > > +    private String configHookDn;
> > > +
> > > +    private Object instance;
> > > +
> > > +    private ADSComponent parentComponent;
> > > +
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,136 @@
> > > +/*
> > > + *  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.server.component;
> > > +
> > > +
> > > +import java.util.Dictionary;
> > > +import java.util.Hashtable;
> > > +
> > > +
> > > +/**
> > > + * Class to hold constants for ApacheDS component management.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public class ADSConstants
> > > +{
> > > +
> > > +    /*
> > > +     * base directory path for component cache
> > > +     */
> > > +    public static final String ADS_CACHE_BASE_DIR = "adscache";
> > > +
> > > +    /*
> > > +     * default file name for caching schemas inside for components
> > > +     */
> > > +    public static final String ADS_CACHE_SCHEMA_FILE = "schema.ldif";
> > > +
> > > +    /*
> > > +     * default file name for caching instance entries inside for
> components
> > > +     */
> > > +    public static final String ADS_CACHE_INSTANCES_FILE =
> "instances.ldif";
> > > +
> > > +    /*
> > > +     * default file name for caching version information for
> components
> > > +     */
> > > +    public static final String ADS_CACHE_VERSION_FILE = "version";
> > > +
> > > +    /*
> > > +     * IPojo Handler name for ADSComponent annotation.
> > > +     */
> > > +    public static final String ADS_COMPONENT_HANDLER_NS =
> "org.apache.directory.server.component.handler";
> > > +
> > > +    /*
> > > +     * IPojo Handler name for ADSComponent annotation.
> > > +     */
> > > +    public static final String ADS_COMPONENT_HANDLER_NAME =
> "ADSComponentHandler";
> > > +
> > > +    /*
> > > +     * IPojo Handler name for ADSComponent annotation.
> > > +     */
> > > +    public static final String ADS_COMPONENT_HANDLER_FULLNAME =
> "org.apache.directory.server.component.handler:ADSComponentHandler";
> > > +
> > > +    /*
> > > +     * iPOJO Component Type and Instance declaration header.
> > > +     */
> > > +    public static final String IPOJO_HEADER = "iPOJO-Components";
> > > +
> > > +    /*
> > > +     * Base OID value for ApacheDS component schemas.
> > > +     */
> > > +    public static final String ADS_COMPONENT_BASE_OID =
> "1.3.6.1.4.1.18060.0.4.4";
> > > +
> > > +    /*
> > > +     * Component type name of user defined components.
> > > +     */
> > > +    public static final String ADS_COMPONENT_TYPE_USER = "user";
> > > +
> > > +    /*
> > > +     * Base DN for @ADSComponent(componentType="user") component
> schema elements.
> > > +     */
> > > +    public static final String ADS_USER_COMPONENTS_SCHEMA_DN =
> "cn=usercomponents,ou=schema";
> > > +
> > > +    /*
> > > +     * Hash table for mapping property type name to its syntax in
> ApacheDS
> > > +     */
> > > +    public static Dictionary<String, String> syntaxMappings;
> > > +
> > > +    /*
> > > +     * Hash table for mapping property type name to its equality
> matching rule in ApacheDS
> > > +     */
> > > +    public static Dictionary<String, String> equalityMappings;
> > > +
> > > +    /*
> > > +     * Hash table for mapping property type name to its ordering rule
> in ApacheDS
> > > +     */
> > > +    public static Dictionary<String, String> orderingMappings;
> > > +
> > > +    /*
> > > +     * Hash table for mapping property type name to its substring
> matching in ApacheDS
> > > +     */
> > > +    public static Dictionary<String, String> substringMappings;
> > > +
> > > +    /**
> > > +     * Static constructor that initializes the values of the type
> mapping Hash tables.
> > > +     */
> > > +    static
> > > +    {
> > > +        syntaxMappings = new Hashtable<String, String>();
> > > +        syntaxMappings.put( "int", "1.3.6.1.4.1.1466.115.121.1.27" );
> > > +        syntaxMappings.put( "java.lang.String",
> "1.3.6.1.4.1.1466.115.121.1.15" );
> > > +        syntaxMappings.put( "boolean", "1.3.6.1.4.1.1466.115.121.1.7"
> );
> > > +
> > > +        equalityMappings = new Hashtable<String, String>();
> > > +        equalityMappings.put( "int", "integerMatch" );
> > > +        equalityMappings.put( "java.lang.String", "caseExactMatch" );
> > > +        equalityMappings.put( "boolean", "booleanMatch" );
> > > +
> > > +        orderingMappings = new Hashtable<String, String>();
> > > +        orderingMappings.put( "int", "integerOrderingMatch" );
> > > +        orderingMappings.put( "java.lang.String",
> "caseExactOrderingMatch" );
> > > +        orderingMappings.put( "boolean", "caseIgnoreOrderingMatch" );
> > > +
> > > +        substringMappings = new Hashtable<String, String>();
> > > +        substringMappings.put( "int", "numericStringSubstringsMatch"
> );
> > > +        substringMappings.put( "java.lang.String",
> "caseExactSubstringsMatch" );
> > > +        substringMappings.put( "boolean", "caseIgnoreSubstringsMatch"
> );
> > > +    }
> > > +
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponent.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponent.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponent.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponent.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,31 @@
> > > +/*
> > > + *  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.server.component.handler;
> > > +
> > > +
> > > +/**
> > > + * Used to annotate ApacheDS components with their component type.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public @interface ADSComponent
> > > +{
> > > +    String componentType() default "user";
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponentHandler.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponentHandler.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponentHandler.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/handler/ADSComponentHandler.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,65 @@
> > > +/*
> > > + *  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.server.component.handler;
> > > +
> > > +
> > > +import java.util.Dictionary;
> > > +
> > > +import org.apache.felix.ipojo.ConfigurationException;
> > > +import org.apache.felix.ipojo.PrimitiveHandler;
> > > +import org.apache.felix.ipojo.annotations.Handler;
> > > +import org.apache.felix.ipojo.metadata.Element;
> > > +
> > > +
> > > +/**
> > > + * IPojo handler for ADSComponent annotation.
> > > + * It does not supposed to do anything. It is just to validate the
> custom-annotated component.
> > > + *
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +@Handler(namespace = "org.apache.directory.server.component.handler",
> name = "ADSComponent")
> > > +public class ADSComponentHandler extends PrimitiveHandler
> > > +{
> > > +
> > > +    @Override
> > > +    public void configure( Element metadata, Dictionary configuration
> ) throws ConfigurationException
> > > +    {
> > > +        // TODO Auto-generated method stub
> > > +
> > > +    }
> > > +
> > > +
> > > +    @Override
> > > +    public void stop()
> > > +    {
> > > +        // TODO Auto-generated method stub
> > > +
> > > +    }
> > > +
> > > +
> > > +    @Override
> > > +    public void start()
> > > +    {
> > > +        // TODO Auto-generated method stub
> > > +
> > > +    }
> > > +
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,418 @@
> > > +/*
> > > + *  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.server.component.hub;
> > > +
> > > +
> > > +import java.util.ArrayList;
> > > +import java.util.Dictionary;
> > > +import java.util.Enumeration;
> > > +import java.util.Hashtable;
> > > +import java.util.List;
> > > +
> > > +import org.apache.directory.server.component.ADSComponent;
> > > +import org.apache.directory.server.component.ADSConstants;
> > > +import org.apache.directory.server.component.hub.listener.HubListener;
> > > +import
> org.apache.directory.server.component.schema.ComponentSchemaGenerator;
> > > +import
> org.apache.directory.server.component.schema.UserComponentSchemaGenerator;
> > > +import org.apache.felix.ipojo.Factory;
> > > +import org.apache.felix.ipojo.annotations.Component;
> > > +import org.apache.felix.ipojo.annotations.Invalidate;
> > > +import org.apache.felix.ipojo.annotations.Requires;
> > > +import org.apache.felix.ipojo.annotations.Validate;
> > > +import org.apache.felix.ipojo.metadata.Element;
> > > +import org.apache.felix.ipojo.parser.ManifestMetadataParser;
> > > +import org.apache.felix.ipojo.parser.ParseException;
> > > +import org.apache.felix.ipojo.whiteboard.Wbp;
> > > +import org.apache.felix.ipojo.whiteboard.Whiteboards;
> > > +import org.osgi.framework.ServiceReference;
> > > +import org.osgi.service.log.LogService;
> > > +
> > > +
> > > +/**
> > > + * An IPojo component that listens for incoming factories and
> instances.
> > > + * Creating or destroying corresponding ADSComponent from them.
> > > + *
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +@Component
> > > +@Whiteboards(whiteboards =
> > > +    {
> > > +        @Wbp(onArrival = "onFactoryArrival",
> > > +            onDeparture = "onFactoryDeparture",
> > > +            filter = "(objectClass=org.apache.felix.ipojo.Factory)"),
> > > +        @Wbp(onArrival = "onInstanceArrival",
> > > +            onDeparture = "onInstanceDeparture",
> > > +            filter =
> "(objectClass=org.apache.felix.ipojo.architecture.Architecture)")
> > > +})
> > > +public class ComponentHub
> > > +{
> > > +    /*
> > > +     * boolean value to check for deferred writes to schema partition
> > > +     */
> > > +    private boolean schemaReady = false;
> > > +
> > > +    /*
> > > +     * boolean value to check for deferred writes to config partition
> > > +     */
> > > +    private boolean configReady = false;
> > > +
> > > +    /*
> > > +     * Map to keep "component type" -> "components" mapping.
> > > +     */
> > > +    private Dictionary<String, List<ADSComponent>> componentMap;
> > > +
> > > +    /*
> > > +     * List to keep all active ApacheDS components.
> > > +     */
> > > +    private List<ADSComponent> components;
> > > +
> > > +    /*
> > > +     * Map to keep "component type" -> "schema generator" mapping.
> > > +     */
> > > +    private Dictionary<String, ComponentSchemaGenerator>
> schemaGenerators;
> > > +
> > > +    /*
> > > +     * Map to keep "component type" -> "listeners" mapping
> > > +     */
> > > +    private Dictionary<String, List<HubListener>> listenersMap;
> > > +
> > > +    /*
> > > +     * OSGI Logger
> > > +     */
> > > +    @Requires
> > > +    private LogService logger;
> > > +
> > > +
> > > +    public ComponentHub()
> > > +    {
> > > +        componentMap = new Hashtable<String, List<ADSComponent>>();
> > > +        components = new ArrayList<ADSComponent>();
> > > +
> > > +        schemaGenerators = new Hashtable<String,
> ComponentSchemaGenerator>();
> > > +        schemaGenerators.put( ADSConstants.ADS_COMPONENT_TYPE_USER,
> new UserComponentSchemaGenerator() );
> > > +
> > > +        listenersMap = new Hashtable<String, List<HubListener>>();
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Called when ADSComponentHub instance is validated by IPojo
> > > +     *
> > > +     */
> > > +    @Validate
> > > +    public void hubValidated()
> > > +    {
> > > +        logger.log( LogService.LOG_INFO, "ADSComponentHub validated."
> );
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Called when ADSComponentHub instance is invalidated by IPojo
> > > +     *
> > > +     */
> > > +    @Invalidate
> > > +    public void hubInvalidated()
> > > +    {
> > > +        logger.log( LogService.LOG_INFO, "ADSComponentHub validated."
> );
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Factory arrival callback, registered by whiteboard handler.
> > > +     *
> > > +     * @param ref Reference to IPojo Factory
> > > +     */
> > > +    public void onFactoryArrival( ServiceReference ref )
> > > +    {
> > > +        Factory arrivingFactory = ( Factory )
> ref.getBundle().getBundleContext().getService( ref );
> > > +        if ( !checkIfADSComponent( arrivingFactory ) )
> > > +        {
> > > +            return;
> > > +        }
> > > +
> > > +        try
> > > +        {
> > > +            String componentType = parseComponentType(
> arrivingFactory );
> > > +
> > > +            List<HubListener> listenersByType = listenersMap.get(
> componentType );
> > > +
> > > +            // Fire the 'factory arrived' event on listeners.
> > > +            if ( listenersByType != null )
> > > +            {
> > > +                for ( HubListener listener : listenersByType )
> > > +                {
> > > +                    listener.onFactoryArrival( arrivingFactory );
> > > +                }
> > > +            }
> > > +
> > > +            //Actual ADSComponent creation
> > > +            ADSComponent component = generateADSComponent(
> componentType, arrivingFactory );
> > > +
> > > +            // Iterate over listeners for 'component created' event.
> Apply the changes applied by them.
> > > +            if ( listenersByType != null )
> > > +            {
> > > +                for ( HubListener listener : listenersByType )
> > > +                {
> > > +                    ADSComponent _comp =
> listener.onComponentCreation( component );
> > > +                    if ( _comp != null )
> > > +                    {
> > > +                        component = _comp;
> > > +                    }
> > > +                }
> > > +            }
> > > +
> > > +            //Keep the newly created ADSComponent reference.
> > > +            components.add( component );
> > > +
> > > +            List<ADSComponent> componentsByType = componentMap.get(
> componentType );
> > > +            if ( componentsByType == null )
> > > +            {
> > > +                List<ADSComponent> newCompList = new
> ArrayList<ADSComponent>();
> > > +                newCompList.add( component );
> > > +                componentMap.put( componentType, newCompList );
> > > +            }
> > > +            else
> > > +            {
> > > +                componentsByType.add( component );
> > > +            }
> > > +
> > > +        }
> > > +        catch ( ParseException e )
> > > +        {
> > > +            e.printStackTrace();
> > > +        }
> > > +
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Factory departure callback, registered by whiteboard handler.
> > > +     *
> > > +     * @param ref Reference to IPojo Factory
> > > +     */
> > > +    public void onFactoryDeparture( ServiceReference ref )
> > > +    {
> > > +        Factory leavingFactory = ( Factory )
> ref.getBundle().getBundleContext().getService( ref );
> > > +        if ( !checkIfADSComponent( leavingFactory ) )
> > > +        {
> > > +            return;
> > > +        }
> > > +
> > > +        try
> > > +        {
> > > +            String componentType = parseComponentType( leavingFactory
> );
> > > +
> > > +            List<HubListener> listenersByType = listenersMap.get(
> componentType );
> > > +
> > > +            // Fire the 'factory leaving' event on listeners.
> > > +            if ( listenersByType != null )
> > > +            {
> > > +                for ( HubListener listener : listenersByType )
> > > +                {
> > > +                    listener.onFactoryDeparture( leavingFactory );
> > > +                }
> > > +            }
> > > +
> > > +            ADSComponent associatedComp = null;
> > > +            for ( ADSComponent _comp : components )
> > > +            {
> > > +                if ( _comp.getFactory().getName().equals(
> leavingFactory.getName() ) )
> > > +                {
> > > +                    associatedComp = _comp;
> > > +                    break;
> > > +                }
> > > +            }
> > > +
> > > +            if ( associatedComp == null )
> > > +            {
> > > +                logger.log( LogService.LOG_INFO, "Couldn't found an
> associated ADSComponent for factory:"
> > > +                    + leavingFactory.getName() );
> > > +                return;
> > > +            }
> > > +
> > > +            // Iterate over listeners for 'component deleting' event.
> > > +            if ( listenersByType != null )
> > > +            {
> > > +                for ( HubListener listener : listenersByType )
> > > +                {
> > > +                    listener.onComponentDeletion( associatedComp );
> > > +                }
> > > +            }
> > > +
> > > +            // All clients are notified now cache and delete the
> ADSComponent existence on ApacheDS
> > > +            cacheAndReleaseADSComponent( associatedComp );
> > > +
> > > +        }
> > > +        catch ( ParseException e )
> > > +        {
> > > +            e.printStackTrace();
> > > +        }
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * IPojo instance arrival callback, registered by whiteboard
> handler.
> > > +     *
> > > +     * @param ref Reference to IPojo instance
> > > +     */
> > > +    public void onInstanceArrival( ServiceReference ref )
> > > +    {
> > > +
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * IPojo instance departure callback, registered by whiteboard
> handler.
> > > +     *
> > > +     * @param ref Reference to IPojo instance
> > > +     */
> > > +    public void onInstanceDeparture( ServiceReference ref )
> > > +    {
> > > +
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Check whether the argument is ADSComponent annotated.
> > > +     *
> > > +     * @param factory
> > > +     * @return
> > > +     */
> > > +    private boolean checkIfADSComponent( Factory factory )
> > > +    {
> > > +        List<String> handlers = factory.getRequiredHandlers();
> > > +        for ( String handlerName : handlers )
> > > +        {
> > > +            if ( handlerName.equals(
> ADSConstants.ADS_COMPONENT_HANDLER_FULLNAME ) )
> > > +            {
> > > +                return true;
> > > +            }
> > > +        }
> > > +
> > > +        return false;
> > > +    }
> > > +
> > > +
> > > +    private String parseComponentType( Factory factory ) throws
> ParseException
> > > +    {
> > > +        Dictionary bundleHeaders =
> factory.getBundleContext().getBundle().getHeaders();
> > > +        String ipojoHeader = ( String ) bundleHeaders.get(
> ADSConstants.IPOJO_HEADER );
> > > +
> > > +        if ( ipojoHeader == null )
> > > +        {
> > > +            throw new ParseException( "Null ipojo header returned for
> factory: " + factory.getName() );
> > > +        }
> > > +
> > > +        ManifestMetadataParser parser = new ManifestMetadataParser();
> > > +        parser.parseHeader( ipojoHeader );
> > > +
> > > +        Element[] componentMetas = parser.getComponentsMetadata();
> > > +
> > > +        for ( Element componentMeta : componentMetas )
> > > +        {
> > > +            String compName = componentMeta.getAttribute( "name" );
> > > +            if ( compName.equals( factory.getName() ) )
> > > +            {
> > > +                Element[] adsElements = componentMeta.getElements(
> > > +                    ADSConstants.ADS_COMPONENT_HANDLER_NAME,
> > > +                    ADSConstants.ADS_COMPONENT_HANDLER_NS );
> > > +
> > > +                if ( adsElements == null || adsElements.length == 0 )
> > > +                {
> > > +                    throw new ParseException( "ADSComponent element
> couldn't be found for factory: "
> > > +                        + factory.getName() );
> > > +                }
> > > +
> > > +                return adsElements[0].getAttribute( "componentType" );
> > > +            }
> > > +        }
> > > +
> > > +        return null;
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Generates a new ADSComponent with its schema and cache handle.
> > > +     *
> > > +     * @param componentType Type of a component being created
> > > +     * @param factory a factory reference to create a ADSComponent
> for.
> > > +     * @return
> > > +     */
> > > +    private ADSComponent generateADSComponent( String componentType,
> Factory factory )
> > > +    {
> > > +        return null;
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Cache the ADSComponent existence on ApacheDS with all of its
> DIT entries. And then release it from hub.
> > > +     *
> > > +     * @param leavingComp ADSComponent reference to cache and release.
> > > +     */
> > > +    private void cacheAndReleaseADSComponent( ADSComponent
> leavingComp )
> > > +    {
> > > +
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Registers a HubListener for specified component type.
> > > +     *
> > > +     * @param componentType component type to get notifications for.
> > > +     * @param listener HubListener implementation
> > > +     */
> > > +    public void registerListener( String componentType, HubListener
> listener )
> > > +    {
> > > +        List<HubListener> listenersForComp = listenersMap.get(
> componentType );
> > > +        if ( listenersForComp == null )
> > > +        {
> > > +            ArrayList<HubListener> list = new
> ArrayList<HubListener>();
> > > +            list.add( listener );
> > > +            listenersMap.put( componentType, list );
> > > +        }
> > > +        else
> > > +        {
> > > +            if ( !listenersForComp.contains( listener ) )
> > > +            {
> > > +                listenersForComp.add( listener );
> > > +            }
> > > +        }
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Removes the specified listener from the notification chain.
> > > +     *
> > > +     * @param listener HubListener implementation
> > > +     */
> > > +    public void removeListener( HubListener listener )
> > > +    {
> > > +        Enumeration<List<HubListener>> it = listenersMap.elements();
> > > +        while ( it.hasMoreElements() )
> > > +        {
> > > +            List<HubListener> list = it.nextElement();
> > > +            if ( list.contains( listener ) )
> > > +            {
> > > +                list.remove( listener );
> > > +            }
> > > +        }
> > > +    }
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,76 @@
> > > +/*
> > > + *  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.server.component.hub.listener;
> > > +
> > > +
> > > +import org.apache.directory.server.component.ADSComponent;
> > > +import org.apache.felix.ipojo.Factory;
> > > +
> > > +
> > > +/**
> > > + * Abstract HubListener implementation. Override the intended methods
> to receive notifications.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public abstract class AbstractHubListener implements HubListener
> > > +{
> > > +
> > > +    /*
> > > +     * (non-Javadoc)
> > > +     * @see
> org.apache.directory.server.component.hub.listener.HubListener#onFactoryArrival(org.apache.felix.ipojo.Factory)
> > > +     */
> > > +    @Override
> > > +    public void onFactoryArrival( Factory factory )
> > > +    {
> > > +    }
> > > +
> > > +
> > > +    /*
> > > +     * (non-Javadoc)
> > > +     * @see
> org.apache.directory.server.component.hub.listener.HubListener#onFactoryDeparture(org.apache.felix.ipojo.Factory)
> > > +     */
> > > +    @Override
> > > +    public void onFactoryDeparture( Factory factory )
> > > +    {
> > > +
> > > +    }
> > > +
> > > +
> > > +    /*
> > > +     * (non-Javadoc)
> > > +     * @see
> org.apache.directory.server.component.hub.listener.HubListener#onComponentCreation(org.apache.directory.server.component.ADSComponent)
> > > +     */
> > > +    @Override
> > > +    public ADSComponent onComponentCreation( ADSComponent component )
> > > +    {
> > > +        return null;
> > > +    }
> > > +
> > > +
> > > +    /*
> > > +     * (non-Javadoc)
> > > +     * @see
> org.apache.directory.server.component.hub.listener.HubListener#onComponentDeletion(org.apache.directory.server.component.ADSComponent)
> > > +     */
> > > +    @Override
> > > +    public void onComponentDeletion( ADSComponent component )
> > > +    {
> > > +    }
> > > +
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,73 @@
> > > +/*
> > > + *  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.server.component.hub.listener;
> > > +
> > > +
> > > +import org.apache.directory.server.component.ADSComponent;
> > > +import org.apache.felix.ipojo.Factory;
> > > +import org.apache.felix.ipojo.architecture.Architecture;
> > > +
> > > +
> > > +/**
> > > + * Interface for the classes those want to be notified of
> ComponentHub.
> > > + * Listeners can bind themselves using
> ComponentHub.registerListener() method,
> > > + * and can remove themselves using ComponentHub.removeListener()
> method.
> > > + * TODO HubListener.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public interface HubListener
> > > +{
> > > +    /**
> > > +     * Notified when a new factory is sniffed by Hub.
> > > +     *
> > > +     * @param factory arriving factory
> > > +     */
> > > +    public void onFactoryArrival( Factory factory );
> > > +
> > > +
> > > +    /**
> > > +     * Notified when a factory leaving the container.
> > > +     *
> > > +     * @param factory departuring factory
> > > +     */
> > > +    public void onFactoryDeparture( Factory factory );
> > > +
> > > +
> > > +    /**
> > > +     * Notified when a new ADSComponent is created.
> > > +     * Listener can change the newly created ADSComponent by
> returning changed ADSComponent.(Be cautious)
> > > +     *
> > > +     * @param component newly created ADSComponent
> > > +     * @return the overrided version of the ADSComponent or null if
> no change is intended.
> > > +     */
> > > +    public ADSComponent onComponentCreation( ADSComponent component );
> > > +
> > > +
> > > +    /**
> > > +     * Notified when a new ADSComponent is about to be disposed.
> > > +     * Called before component disposal begins.
> > > +     *
> > > +     * @param component disposing created ADSComponent
> > > +     * @return the overrided version of the ADSComponent or null if
> no change is intended.
> > > +     */
> > > +    public void onComponentDeletion( ADSComponent component );
> > > +
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,103 @@
> > > +/*
> > > + *  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.server.component.schema;
> > > +
> > > +
> > > +import java.util.ArrayList;
> > > +import java.util.List;
> > > +
> > > +import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
> > > +
> > > +
> > > +/**
> > > + * Class that represents an ADSComponent's schema definition.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public class ADSComponentSchema
> > > +{
> > > +    /*
> > > +     * Schema elements (attribs,ocs) for component.
> > > +     */
> > > +    private List<LdifEntry> schemaElements = null;
> > > +
> > > +    /*
> > > +     * True if the @schemaElements contains complete schema
> definition with schema entry.
> > > +     */
> > > +    private boolean completeSchema = false;
> > > +
> > > +    /*
> > > +     * Schema name which @schemaElements will go under.
> > > +     */
> > > +    private String parentSchemaDn = null;
> > > +
> > > +
> > > +    public ADSComponentSchema( String name, List<LdifEntry> elements )
> > > +    {
> > > +        this( name, elements, false );
> > > +    }
> > > +
> > > +
> > > +    public ADSComponentSchema( String parentSchema, List<LdifEntry>
> elements, boolean complete )
> > > +    {
> > > +        parentSchemaDn = parentSchema;
> > > +        schemaElements = elements;
> > > +        completeSchema = complete;
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Getter for completeSchema
> > > +     *
> > > +     * @return true if schema is complete with schema entry.
> > > +     */
> > > +    public boolean ifCompleteSchema()
> > > +    {
> > > +        return completeSchema;
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Returns name of the schema
> > > +     *
> > > +     * @return name of the schema
> > > +     */
> > > +    public String getParentSchemaName()
> > > +    {
> > > +        return parentSchemaDn;
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Gets the clone of the schema elements.
> > > +     *
> > > +     * @return clone of the schema elements.
> > > +     */
> > > +    public List<LdifEntry> getSchemaElements()
> > > +    {
> > > +        if ( schemaElements == null )
> > > +        {
> > > +            return null;
> > > +        }
> > > +
> > > +        return new ArrayList<LdifEntry>( schemaElements );
> > > +    }
> > > +
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,88 @@
> > > +/*
> > > + *  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.server.component.schema;
> > > +
> > > +
> > > +import org.apache.directory.server.component.ADSConstants;
> > > +
> > > +
> > > +/**
> > > + * This is a simple incremental generator for OID assignments of
> custom generated schemas.
> > > + * Ensuring consistency among different servers on the cluster will
> be replication layer's duty.
> > > + * TODO ADSComponentOIDGenerator.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public class ComponentOIDGenerator
> > > +{
> > > +    /*
> > > +     * Base OID to generate sequential OIDs against.
> > > +     */
> > > +    private static String baseOID = null;
> > > +
> > > +    /*
> > > +     * Counters to keep track.
> > > +     */
> > > +    private static int componentCounter;
> > > +    private static int ocCounter;
> > > +    private static int attribCounter;
> > > +
> > > +    static
> > > +    {
> > > +        baseOID = ADSConstants.ADS_COMPONENT_BASE_OID;
> > > +
> > > +        componentCounter = 0;
> > > +        ocCounter = 0;
> > > +        attribCounter = 0;
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Returns OID for component
> > > +     *
> > > +     * @return oid for component
> > > +     */
> > > +    public static synchronized String generateComponentOID()
> > > +    {
> > > +        return baseOID + "." + ( ++componentCounter );
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Returns OID for object class under specified component base
> OID.
> > > +     *
> > > +     * @return oid for object class
> > > +     */
> > > +    public static synchronized String generateOCOID( String
> componentBase )
> > > +    {
> > > +        return componentBase + ".1." + ( ++ocCounter );
> > > +    }
> > > +
> > > +
> > > +    /**
> > > +     * Returns OID for attribute under specified component base OID.
> > > +     *
> > > +     * @return oid for attribute
> > > +     */
> > > +    public static synchronized String generateAttribOID( String
> componentBase )
> > > +    {
> > > +        return componentBase + ".2." + ( ++attribCounter );
> > > +    }
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentSchemaGenerator.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentSchemaGenerator.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentSchemaGenerator.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentSchemaGenerator.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,44 @@
> > > +/*
> > > + *  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.server.component.schema;
> > > +
> > > +
> > > +import org.apache.felix.ipojo.Factory;
> > > +
> > > +
> > > +/**
> > > + * Interface for classes generating schemas for component types.
> > > + *
> > > + * @author <a href="mailto:dev@directory.apache.org">Apache
> Directory Project</a>
> > > + */
> > > +public interface ComponentSchemaGenerator
> > > +{
> > > +    /**
> > > +     * Generates a schema for representing all of factory's
> configurables.
> > > +     * Returned schema is in right order to add it to LDAP without
> any sorting.
> > > +     *
> > > +     * If factory does not need a custom schema, it does not generate
> a schema for
> > > +     * it, just returns the name of stock schema instead.
> > > +     *
> > > +     * @param factory Factory reference to generate schema for.
> > > +     * @return Schema in the form of LdifEntry list.
> > > +     */
> > > +    public ADSComponentSchema generateOrGetSchemaElements( Factory
> factory );
> > > +}
> > >
> > > Added:
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java?rev=1203217&view=auto
> > >
> ==============================================================================
> > > ---
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java
> (added)
> > > +++
> directory/apacheds/trunk/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java
> Thu Nov 17 15:21:39 2011
> > > @@ -0,0 +1,157 @@
> > > +/*
> > > + *  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.server.component.schema;
> > > +
> > > +
> > > +import java.util.ArrayList;
> > > +import java.util.List;
> > > +
> > > +import org.apache.directory.server.component.ADSConstants;
> > > +import
> org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
> > > +import
> org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
> > > +import org.apache.directory.shared.ldap.model.ldif.LdapLdifException;
> > > +import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
> > > +import org.apache.felix.ipojo.Factory;
> > > +import org.apache.felix.ipojo.architecture.PropertyDescription;
> > > +import org.slf4j.Logger;
> > > +import org.slf4j.LoggerFactory;
> > > +
> > > +
> > > +public class UserComponentSchemaGenerator implements
> ComponentSchemaGenerator
> > > +{
> > > +
> > > +    private static final Logger LOG = LoggerFactory.getLogger(
> UserComponentSchemaGenerator.class );
> > > +
> > > +
> > > +    @Override
> > > +    public ADSComponentSchema generateOrGetSchemaElements( Factory
> componentFactory )
> > > +    {
> > > +        List<LdifEntry> schemaElements = new ArrayList<LdifEntry>();
> > > +
> > > +        String componentName = componentFactory.getName();
> > > +        if ( componentName.contains( "." ) )
> > > +        {
> > > +            componentName = componentName.substring(
> componentName.lastIndexOf( '.' ) + 1 );
> > > +        }
> > > +
> > > +        String schemaDn = ADSConstants.ADS_USER_COMPONENTS_SCHEMA_DN;
> > > +
> > > +        String attribsDn = "ou=attributeTypes," + schemaDn;
> > > +        String ocsDn = "ou=objectClasses," + schemaDn;
> > > +
> > > +        //Will hold the m-must attributes while iterating over
> properties of the component
> > > +        List<String> ocAttribs = new ArrayList<String>();
> > > +
> > > +        // Creating schema elements with proper order and pushing
> them into the list
> > > +        try
> > > +        {
> > > +
> > > +            String componentBaseOID =
> ComponentOIDGenerator.generateComponentOID();
> > > +
> > > +            for ( PropertyDescription prop :
> componentFactory.getComponentDescription().getProperties() )
> > > +            {
> > > +
> > > +                //Must be lower case, alphanumeric only
> > > +                String propname = prop.getName();
> > > +
> > > +                String proptype = prop.getType();
> > > +                String propoid =
> ComponentOIDGenerator.generateAttribOID( componentBaseOID );
> > > +                String propdn = "m-oid=" + propoid + "," + attribsDn;
> > > +
> > > +                if ( !( proptype.equals( "int" ) || proptype.equals(
> "java.lang.String" ) || proptype
> > > +                    .equals( "boolean" ) ) )
> > > +                {
> > > +                    LOG.info( "Property found with an incompatible
> type:  "
> > > +                        + propname + ":" + proptype );
> > > +                    continue;
> > > +                }
> > > +
> > > +                String syntax = ADSConstants.syntaxMappings.get(
> proptype );
> > > +                String equality = ADSConstants.equalityMappings.get(
> proptype );
> > > +                String ordering = ADSConstants.orderingMappings.get(
> proptype );
> > > +                String substr = ADSConstants.substringMappings.get(
> proptype );
> > > +
> > > +                schemaElements.add( new LdifEntry( propdn,
> > > +                    "objectclass:metaAttributeType",
> > > +                    "objectclass:metaTop",
> > > +                    "objectclass:top",
> > > +                    "m-oid:" + propoid,
> > > +                    "m-name:" + propname,
> > > +                    "m-description:Property of component type " +
> componentName,
> > > +                    "m-equality:" + equality,
> > > +                    "m-ordering:" + ordering,
> > > +                    "m-substr:" + substr,
> > > +                    "m-syntax:" + syntax,
> > > +                    "m-length:0",
> > > +                    "m-singleValue:TRUE" ) );
> > > +
> > > +                if ( prop.isMandatory() )
> > > +                {
> > > +                    ocAttribs.add( "m-must:" + propname );
> > > +                }
> > > +                else
> > > +                {
> > > +                    ocAttribs.add( "m-may:" + propname );
> > > +                }
> > > +
> > > +            }
> > > +
> > > +            schemaElements.add( new LdifEntry( ocsDn,
> > > +                "objectclass:organizationalUnit",
> > > +                "objectClass:top",
> > > +                "ou:objectClasses" ) );
> > > +
> > > +            String ocoid = ComponentOIDGenerator.generateOCOID(
> componentBaseOID );
> > > +            String ocDn = "m-oid=" + ocoid + "," + ocsDn;
> > > +
> > > +            ocAttribs.add( 0, "m-may:cached" );
> > > +            ocAttribs.add( 0, "m-must:ins" );
> > > +            ocAttribs.add( 0, "m-must:active" );
> > > +            ocAttribs.add( 0, "m-supObjectClass: top" );
> > > +            ocAttribs.add( 0, "m-description:Object Class for
> generating instances of:" + componentName );
> > > +            ocAttribs.add( 0, "m-name:" + componentName );
> > > +            ocAttribs.add( 0, "m-oid:" + ocoid );
> > > +            ocAttribs.add( 0, "objectclass: top" );
> > > +            ocAttribs.add( 0, "objectclass: metaTop" );
> > > +            ocAttribs.add( 0, "objectclass: metaObjectClass" );
> > > +
> > > +            schemaElements.add( new LdifEntry( ocDn,
> ocAttribs.toArray() ) );
> > > +
> > > +        }
> > > +        catch ( LdapInvalidAttributeValueException e )
> > > +        {
> > > +            LOG.info( "ADSSchemaManager#generateSchema:
>  Error(LdapInvalidAttributeValueException) while creating LdifEntry for:  "
> > > +                + componentFactory );
> > > +        }
> > > +        catch ( LdapInvalidDnException e )
> > > +        {
> > > +            LOG.info( "ADSSchemaManager#generateSchema:
>  Error(LdapInvalidDnException) while creating LdifEntry for:  "
> > > +                + componentFactory );
> > > +        }
> > > +        catch ( LdapLdifException e )
> > > +        {
> > > +            LOG.info( "ADSSchemaManager#generateSchema:
>  Error(LdapLdifException) while creating LdifEntry for:  "
> > > +                + componentFactory );
> > > +        }
> > > +
> > > +        return new ADSComponentSchema(
> ADSConstants.ADS_USER_COMPONENTS_SCHEMA_DN, schemaElements );
> > > +    }
> > > +
> > > +}
> > >
> > > Modified: directory/apacheds/trunk/pom.xml
> > > URL:
> http://svn.apache.org/viewvc/directory/apacheds/trunk/pom.xml?rev=1203217&r1=1203216&r2=1203217&view=diff
> > >
> ==============================================================================
> > > --- directory/apacheds/trunk/pom.xml (original)
> > > +++ directory/apacheds/trunk/pom.xml Thu Nov 17 15:21:39 2011
> > > @@ -151,6 +151,7 @@
> > >     <module>apache-felix</module>
> > >     <module>dependencies</module>
> > >     <module>service-osgi</module>
> > > +    <module>component-hub</module>
> > >   </modules>
> > >
> > >   <build>
> > >
> > >
> >
>

Mime
View raw message