You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2009/01/12 12:54:21 UTC
svn commit: r733703 - in
/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api: ./
src/main/java/org/apache/felix/ipojo/api/
src/main/java/org/apache/felix/ipojo/api/test/
Author: clement
Date: Mon Jan 12 03:54:20 2009
New Revision: 733703
URL: http://svn.apache.org/viewvc?rev=733703&view=rev
Log:
- Add javadoc comments
- Add licence files
- Add the notice file
- Remove built-in tests
Added:
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE.asm
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/NOTICE
Removed:
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/metadata.xml
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/test/
Modified:
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/ (props changed)
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/pom.xml
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ComponentType.java
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Dependency.java
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Property.java
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Service.java
felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ServiceProperty.java
Propchange: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jan 12 03:54:20 2009
@@ -5,3 +5,5 @@
target
.settings
+
+.checkstyle
Added: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE?rev=733703&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE (added)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE Mon Jan 12 03:54:20 2009
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Added: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE.asm
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE.asm?rev=733703&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE.asm (added)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/LICENSE.asm Mon Jan 12 03:54:20 2009
@@ -0,0 +1,28 @@
+
+ ASM: a very small and fast Java bytecode manipulation framework
+ Copyright (c) 2000-2005 INRIA, France Telecom
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
Added: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/NOTICE
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/NOTICE?rev=733703&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/NOTICE (added)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/NOTICE Mon Jan 12 03:54:20 2009
@@ -0,0 +1,27 @@
+Apache Felix iPOJO API
+Copyright 2008 The Apache Software Foundation
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+Copyright (c) 2000-2005 INRIA, France Telecom
+Licensed under BSD License.
+
+II. Used Software
+
+This product uses software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org).
+Copyright (c) OSGi Alliance (2000, 2007).
+Licensed under the Apache License 2.0.
+
+III. License Summary
+- Apache License 2.0
+- BSD Licence
Modified: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/pom.xml?rev=733703&r1=733702&r2=733703&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/pom.xml (original)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/pom.xml Mon Jan 12 03:54:20 2009
@@ -1,51 +1,102 @@
+<!--
+ 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>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.api</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <name>iPOJO API</name>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.2</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Import-Package>! org.apache.felix.ipojo.xml.*, *</Import-Package>
- <Export-Package>org.apache.felix.ipojo.api</Export-Package>
- <Private-Package>org.apache.felix.ipojo.api.test, org.apache.felix.ipojo.manipulation, org.apache.felix.ipojo.manipulation.annotations, org.objectweb.asm.commons, org.objectweb.asm, org.objectweb.asm.tree</Private-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.api
+ </artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <name>iPOJO API</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.2</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${pom.artifactId}
+ </Bundle-SymbolicName>
+
+ <Export-Package>org.apache.felix.ipojo.api
+ </Export-Package>
+ <Private-Package>org.apache.felix.ipojo.manipulation,
+ org.apache.felix.ipojo.manipulation.annotations,
+ org.objectweb.asm.commons, org.objectweb.asm</Private-Package>
+ <Include-Resource> META-INF/LICENCE=LICENSE,
+ META-INF/NOTICE=NOTICE, META-INF/LICENCE.asm=LICENSE.asm
+ </Include-Resource>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rat-maven-plugin</artifactId>
+ <configuration>
+ <excludeSubProjects>false</excludeSubProjects>
+ <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes>
+ <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
+ <excludes>
+ <param>doc/**/*</param>
+ <param>maven-eclipse.xml</param>
+ <param>.checkstyle</param>
+ <param>.externalToolBuilders/*</param>
+ <param>LICENSE.asm</param>
+ <param>.fbprefs</param>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <enableRulesSummary>false</enableRulesSummary>
+ <violationSeverity>warning</violationSeverity>
+ <configLocation>http://felix.apache.org/ipojo/dev/checkstyle_ipojo.xml</configLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.manipulator
+ </artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm-tree</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
</project>
Modified: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ComponentType.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ComponentType.java?rev=733703&r1=733702&r2=733703&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ComponentType.java (original)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ComponentType.java Mon Jan 12 03:54:20 2009
@@ -1,3 +1,21 @@
+/*
+ * 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.felix.ipojo.api;
import java.util.ArrayList;
@@ -11,39 +29,99 @@
import org.apache.felix.ipojo.MissingHandlerException;
import org.apache.felix.ipojo.UnacceptableConfiguration;
+
+/**
+ * The component type class allows specifying a new component type
+ * and its attached factory. It also allows creating instances form
+ * the specified component type.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
public abstract class ComponentType {
+ /**
+ * The list of instances created from the
+ * current component type.
+ */
private List m_instances = new ArrayList();
+ /**
+ * Gets the factory attached to the current
+ * component type.
+ * @return the factory
+ */
public abstract Factory getFactory();
+ /**
+ * Starts the factory attached to this
+ * component type. Once started a factory
+ * and its attached component type
+ * cannot be modified.
+ */
public abstract void start();
+
+ /**
+ * Stops the factory attached to this
+ * component type.
+ */
public abstract void stop();
+ /**
+ * Creates a component instance from the current type
+ * with an empty configuration.
+ * @return the component instance object.
+ * @throws UnacceptableConfiguration the configuration is not acceptable
+ * @throws MissingHandlerException the factory in invalid
+ * @throws ConfigurationException the instance configuration failed
+ */
public ComponentInstance createInstance() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- ComponentInstance ci = _getFactory().createComponentInstance(null);
+ ComponentInstance ci = ensureAndGetFactory().createComponentInstance(null);
m_instances.add(ci);
return ci;
}
+ /**
+ * Creates a component instance from the current type
+ * with the given name.
+ * @param name the instance name
+ * @return the component instance object.
+ * @throws UnacceptableConfiguration the configuration is not acceptable
+ * @throws MissingHandlerException the factory in invalid
+ * @throws ConfigurationException the instance configuration failed
+ */
public ComponentInstance createInstance(String name) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
Dictionary dict = null;
if (name != null) {
dict = new Properties();
dict.put("instance.name", name);
}
- ComponentInstance ci = _getFactory().createComponentInstance(dict);
+ ComponentInstance ci = ensureAndGetFactory().createComponentInstance(dict);
m_instances.add(ci);
return ci;
}
+ /**
+ * Creates a component instance from the current type
+ * with the given configuration.
+ * @param conf the configuration
+ * @return the component instance object.
+ * @throws UnacceptableConfiguration the configuration is not acceptable
+ * @throws MissingHandlerException the factory in invalid
+ * @throws ConfigurationException the instance configuration failed
+ */
public ComponentInstance createInstance(Dictionary conf) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- ComponentInstance ci = _getFactory().createComponentInstance(conf);
+ ComponentInstance ci = ensureAndGetFactory().createComponentInstance(conf);
m_instances.add(ci);
return ci;
}
+ /**
+ * Disposes the given name. The instance must be created from this
+ * component type.
+ * @param ci the component instance to delete
+ * @return <code>true</code> if the instance was
+ * successfully disposed.
+ */
public boolean disposeInstance(ComponentInstance ci) {
if (m_instances.remove(ci)) {
ci.dispose();
@@ -54,6 +132,14 @@
}
}
+ /**
+ * Gets the component instance created from this component type.
+ * with the given name.
+ * @param name the instance name.
+ * @return the component instance with the given name and created
+ * from the current component type factory. <code>null</code> if
+ * the instance cannot be found.
+ */
public ComponentInstance getInstanceByName(String name) {
for (int i = 0; i < m_instances.size(); i++) {
ComponentInstance ci = (ComponentInstance) m_instances.get(i);
@@ -64,6 +150,12 @@
return null;
}
+ /**
+ * Disposes the instance created with this component type which
+ * has the given name.
+ * @param name the name of the instance to delete.
+ * @return <code>true</code> is the instance is successfully disposed.
+ */
public boolean disposeInstance(String name) {
ComponentInstance ci = getInstanceByName(name);
if (ci == null) {
@@ -74,7 +166,13 @@
}
}
- private Factory _getFactory() {
+ /**
+ * Returns the attached factory.
+ * Before returning the factory, the consistency of the
+ * factory is checked.
+ * @return the attached factory to the current component type
+ */
+ private Factory ensureAndGetFactory() {
ensureFactory();
return getFactory();
}
Modified: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Dependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Dependency.java?rev=733703&r1=733702&r2=733703&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Dependency.java (original)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Dependency.java Mon Jan 12 03:54:20 2009
@@ -1,28 +1,122 @@
+/*
+ * 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.felix.ipojo.api;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.handlers.dependency.DependencyDescription;
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
+/**
+ * Allows configuring a service dependencies.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
public class Dependency {
+ /**
+ * The dynamic binding policy.
+ */
public static final int DYNAMIC = org.apache.felix.ipojo.handlers.dependency.Dependency.DYNAMIC_BINDING_POLICY;
+
+ /**
+ * The static binding policy.
+ */
public static final int STATIC = org.apache.felix.ipojo.handlers.dependency.Dependency.STATIC_BINDING_POLICY;
+
+ /**
+ * The dynamic-priority binding policy.
+ */
public static final int DYNAMIC_PRIORITY = org.apache.felix.ipojo.handlers.dependency.Dependency.DYNAMIC_PRIORITY_BINDING_POLICY;
+ /**
+ * The required specification.
+ */
private String m_specification;
+
+ /**
+ * The LDAP filter of the dependency.
+ */
private String m_filter;
+
+ /**
+ * The field of the implementation class attached to
+ * this dependency.
+ */
private String m_field;
+
+ /**
+ * Is the dependency optional?
+ */
private boolean m_optional;
+
+ /**
+ * Is the dependency aggregate?
+ */
private boolean m_aggregate;
+
+ /**
+ * Bind method attached to the dependency.
+ */
private String m_bind;
+
+ /**
+ * Unbind method attached to the dependency.
+ */
private String m_unbind;
+
+ /**
+ * The dependency binding policy.
+ */
private int m_policy;
+
+ /**
+ * The dependency comparator.
+ * (used to compare service providers)
+ */
private String m_comparator;
+
+ /**
+ * The dependency default-implementation.
+ */
private String m_di;
+
+ /**
+ * The dependency specific provider.
+ */
private String m_from;
+
+ /**
+ * The dependency id.
+ */
private String m_id;
- private boolean m_nullable;
+
+ /**
+ * Does the dependency supports nullable?
+ */
+ private boolean m_nullable = true;
+ /**
+ * Gets the dependency metadata.
+ * @return the 'requires' element describing
+ * the current dependency.
+ */
public Element getElement() {
ensureValidity();
@@ -82,66 +176,134 @@
return dep;
}
+ /**
+ * Sets the required service specification.
+ * @param spec the specification
+ * @return the current dependency object.
+ */
public Dependency setSpecification(String spec) {
m_specification = spec;
return this;
}
+ /**
+ * Sets the dependency filter.
+ * @param filter the LDAP filter
+ * @return the current dependency object
+ */
public Dependency setFilter(String filter) {
m_filter = filter;
return this;
}
+ /**
+ * Sets the field attached to the dependency.
+ * @param field the implementation class field name.
+ * @return the current dependency object
+ */
public Dependency setField(String field) {
m_field = field;
return this;
}
+ /**
+ * Sets the dependency optionality.
+ * @param opt <code>true</code> to set the
+ * dependency to optional.
+ * @return the current dependency object.
+ */
public Dependency setOptional(boolean opt) {
m_optional = opt;
return this;
}
+ /**
+ * Sets the dependency cardinality.
+ * @param agg <code>true</code> to set the
+ * dependency to aggregate.
+ * @return the current dependency object.
+ */
public Dependency setAggregate(boolean agg) {
m_aggregate = agg;
return this;
}
+ /**
+ * Sets if the dependency supports nullable objects.
+ * @param nullable <code>false</code> if the dependency does not
+ * support the nullable object injection
+ * @return the current dependency object.
+ */
public Dependency setNullable(boolean nullable) {
m_nullable = nullable;
return this;
}
+ /**
+ * Sets the dependency bind method.
+ * @param bind the bind method name
+ * @return the current dependency object.
+ */
public Dependency setBindMethod(String bind) {
m_bind = bind;
return this;
}
+ /**
+ * Sets the dependency unbind method.
+ * @param unbind the unbind method
+ * @return the current dependency object.
+ */
public Dependency setUnbindMethod(String unbind) {
m_unbind = unbind;
return this;
}
+ /**
+ * Sets the dependency binding policy.
+ * @param policy the binding policy
+ * @return the current dependency object
+ */
public Dependency setBindingPolicy(int policy) {
m_policy = policy;
return this;
}
+ /**
+ * Sets the dependency comparator.
+ * @param cmp the comparator class name
+ * @return the current dependency object
+ */
public Dependency setComparator(String cmp) {
m_comparator = cmp;
return this;
}
+ /**
+ * Sets the dependency default-implementation.
+ * @param di the default-implementation class name
+ * @return the current dependency object
+ */
public Dependency setDefaultImplementation(String di) {
m_di = di;
return this;
}
+ /**
+ * Sets the dependency 'from' attribute.
+ * @param from the name of the service provider.
+ * @return the current dependency object
+ */
public Dependency setFrom(String from) {
m_from = from;
return this;
}
+ /**
+ * Sets the dependency id.
+ * @param id the dependency id.
+ * @return the current dependency object.
+ */
public Dependency setId(String id) {
m_id = id;
return this;
@@ -163,5 +325,28 @@
}
}
+ /**
+ * Gets the dependency description object attached to
+ * this dependency.
+ * @param instance the instance on which searching the dependency
+ * @return the dependency description attached to this dependency or
+ * <code>null</code> if the dependency cannot be found.
+ */
+ public DependencyDescription getDependencyDescription(ComponentInstance instance) {
+ PrimitiveInstanceDescription desc = (PrimitiveInstanceDescription) instance.getInstanceDescription();
+ if (m_id != null) {
+ return desc.getDependency(m_id);
+ }
+ if (m_specification != null) {
+ return desc.getDependency(m_specification);
+ }
+ DependencyDescription[] deps = desc.getDependencies();
+ if (deps.length == 1) {
+ return deps[0];
+ }
+ // Cannot determine the dependency.
+ return null;
+ }
+
}
Modified: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java?rev=733703&r1=733702&r2=733703&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java (original)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java Mon Jan 12 03:54:20 2009
@@ -1,3 +1,21 @@
+/*
+ * 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.felix.ipojo.api;
import java.io.IOException;
@@ -14,118 +32,268 @@
import org.apache.felix.ipojo.metadata.Element;
import org.osgi.framework.BundleContext;
+/**
+ * Allows defining primitive component types.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
public class PrimitiveComponentType extends ComponentType {
+ /**
+ * The bundle context.
+ */
private BundleContext m_context;
+
+ /**
+ * The implementation class name.
+ */
private String m_classname;
+
+ /**
+ * The component type name.
+ */
private String m_name;
+
+ /**
+ * Is the component type immediate.
+ */
private boolean m_immediate;
+
+ /**
+ * Manipulation metadata of the component type.
+ */
private Element m_manipulation;
+
+ /**
+ * Component factory attached to the component
+ * type.
+ */
private ComponentFactory m_factory;
+
+ /**
+ * Component type metadata.
+ */
private Element m_metadata;
+
+ /**
+ * List of provided services.
+ */
private List m_services = new ArrayList(1);
+
+ /**
+ * List of service dependencies.
+ */
private List m_dependencies = new ArrayList();
+
+ /**
+ * List of configuration properties.
+ */
private List m_properties = new ArrayList();
+
+ /**
+ * The validate callback.
+ */
private String m_validate;
+
+ /**
+ * The invalidate callback.
+ */
private String m_invalidate;
+
+ /**
+ * Are the properties propagated to provided services?
+ */
private boolean m_propagation;
+
+ /**
+ * The factory method.
+ */
private String m_factoryMethod;
+
+ /**
+ * Is the factory public?
+ */
private boolean m_public = true;
+
+ /**
+ * The Managed Service PID.
+ */
private String m_msPID;
+ /**
+ * Checks that the component type is not already
+ * started.
+ */
private void ensureNotInitialized() {
if (m_factory != null) {
throw new IllegalStateException("The component type was already initialized, cannot modify metadata");
}
}
+ /**
+ * Checks that the component type description is valid.
+ */
private void ensureValidity() {
if (m_classname == null) {
- throw new IllegalStateException("The primitive component type as no implementation class");
+ throw new IllegalStateException("The primitive component type has no implementation class");
+ }
+ if (m_context == null) {
+ throw new IllegalStateException("The primitive component type has no bundle context");
}
}
+ /**
+ * Gets the component factory.
+ * @return the factory attached to this component type.
+ * @see org.apache.felix.ipojo.api.ComponentType#getFactory()
+ */
public Factory getFactory() {
initializeFactory();
return m_factory;
}
+ /**
+ * Starts the component type.
+ * @see org.apache.felix.ipojo.api.ComponentType#start()
+ */
public void start() {
initializeFactory();
m_factory.start();
}
+ /**
+ * Stops the component type.
+ * @see org.apache.felix.ipojo.api.ComponentType#stop()
+ */
public void stop() {
initializeFactory();
m_factory.stop();
}
+ /**
+ * Initializes the factory.
+ */
private void initializeFactory() {
if (m_factory == null) {
createFactory();
}
}
+ /**
+ * Sets the bundle context.
+ * @param bc the bundle context
+ * @return the current component type
+ */
public PrimitiveComponentType setBundleContext(BundleContext bc) {
ensureNotInitialized();
m_context = bc;
return this;
}
+ /**
+ * Sets the implementation class.
+ * @param classname the class name
+ * @return the current component type
+ */
public PrimitiveComponentType setClassName(String classname) {
ensureNotInitialized();
m_classname = classname;
return this;
}
+ /**
+ * Sets the component type name.
+ * @param name the factory name
+ * @return the current component type
+ */
public PrimitiveComponentType setComponentTypeName(String name) {
ensureNotInitialized();
m_name = name;
return this;
}
+ /**
+ * Sets if the component type is immediate or not.
+ * @param immediate <code>true</code> to set the component
+ * type to immediate
+ * @return the current component type
+ */
public PrimitiveComponentType setImmediate(boolean immediate) {
ensureNotInitialized();
m_immediate = immediate;
return this;
}
+ /**
+ * Sets the dependency factory method.
+ * @param method the method used to create pojo object.
+ * @return the current component type
+ */
public PrimitiveComponentType setFactoryMethod(String method) {
ensureNotInitialized();
m_factoryMethod = method;
return this;
}
+ /**
+ * Sets if the component type propagates properties to service properties.
+ * @param propagation <code>true</code> to enable propagation
+ * @return the current component type
+ */
public PrimitiveComponentType setPropagation(boolean propagation) {
ensureNotInitialized();
m_propagation = propagation;
return this;
}
+ /**
+ * Sets the factory public aspect.
+ * @param visible <code>false</code> to create a private factory.
+ * @return the current component type
+ */
public PrimitiveComponentType setPublic(boolean visible) {
ensureNotInitialized();
m_public = visible;
return this;
}
+ /**
+ * Sets the managed service pid.
+ * @param pid the managed service pid
+ * @return the current component type
+ */
public PrimitiveComponentType setManagedServicePID(String pid) {
ensureNotInitialized();
m_msPID = pid;
return this;
}
+ /**
+ * Sets the validate method.
+ * @param method the validate method
+ * @return the current component type
+ */
public PrimitiveComponentType setValidateMethod(String method) {
ensureNotInitialized();
m_validate = method;
return this;
}
+ /**
+ * Sets the invalidate method.
+ * @param method the invalidate method
+ * @return the current component type
+ */
public PrimitiveComponentType setInvalidateMethod(String method) {
ensureNotInitialized();
m_invalidate = method;
return this;
}
+ /**
+ * Generates the component description.
+ * @return the component type description of
+ * the current component type
+ */
private Element generateComponentMetadata() {
Element element = new Element("component", "");
element.addAttribute(new Attribute("classname", m_classname));
@@ -182,6 +350,9 @@
return element;
}
+ /**
+ * Creates the component factory.
+ */
private void createFactory() {
ensureValidity();
byte[] clazz = manipulate();
@@ -196,6 +367,10 @@
}
+ /**
+ * Manipulates the implementation class.
+ * @return the manipulated class
+ */
private byte[] manipulate() {
Manipulator manipulator = new Manipulator();
try {
@@ -208,6 +383,11 @@
}
}
+ /**
+ * Gets a class file as a byte array.
+ * @return the byte array.
+ * @throws IOException the class file cannot be read.
+ */
private byte[] getClassByteArray() throws IOException {
String filename = m_classname.replace('.', '/') + ".class";
URL url = m_context.getBundle().getResource(filename);
@@ -223,18 +403,33 @@
return b;
}
+ /**
+ * Adds a provided service.
+ * @param svc the service to add
+ * @return the current component type
+ */
public PrimitiveComponentType addService(Service svc) {
ensureNotInitialized();
m_services.add(svc);
- return this;
+ return this;
}
+ /**
+ * Adds a service dependency.
+ * @param dep the dependency to add
+ * @return the current component type
+ */
public PrimitiveComponentType addDependency(Dependency dep) {
ensureNotInitialized();
m_dependencies.add(dep);
return this;
}
+ /**
+ * Adds a configuration property.
+ * @param prop the property to add
+ * @return the current component type
+ */
public PrimitiveComponentType addProperty(Property prop) {
ensureNotInitialized();
m_properties.add(prop);
Modified: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Property.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Property.java?rev=733703&r1=733702&r2=733703&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Property.java (original)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Property.java Mon Jan 12 03:54:20 2009
@@ -1,47 +1,129 @@
+/*
+ * 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.felix.ipojo.api;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.architecture.PropertyDescription;
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
+/**
+ * Allows configuring a configuration property.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
public class Property {
+ /**
+ * The property name.
+ */
private String m_name;
+
+ /**
+ * The property field.
+ */
private String m_field;
+
+ /**
+ * The property value.
+ */
private String m_value;
+
+ /**
+ * The property method.
+ */
private String m_method;
+
+ /**
+ * Is the property mandatory.
+ */
private boolean m_mandatory;
+
+ /**
+ * Is the property immutable.
+ */
private boolean m_immutable;
+ /**
+ * Sets the property name.
+ * @param name the property name
+ * @return the current property object
+ */
public Property setName(String name) {
m_name = name;
return this;
}
+ /**
+ * Sets the property field.
+ * @param name the property field
+ * @return the current property object
+ */
public Property setField(String name) {
m_field = name;
return this;
}
+ /**
+ * Sets the property method.
+ * @param name the property method
+ * @return the current property object
+ */
public Property setMethod(String name) {
m_method = name;
return this;
}
+ /**
+ * Sets the property value.
+ * @param name the property value
+ * @return the current property object
+ */
public Property setValue(String name) {
m_value = name;
return this;
}
+ /**
+ * Sets if the property is mandatory.
+ * @param mandatory <code>true</code> if the dependency is mandatory.
+ * @return the current property object
+ */
public Property setMandatory(boolean mandatory) {
m_mandatory = mandatory;
return this;
}
+ /**
+ * Sets if the property is immutable.
+ * @param immutable <code>true</code> if the dependency is immutable.
+ * @return the current property object
+ */
public Property setImmutable(boolean immutable) {
m_immutable = immutable;
return this;
}
+ /**
+ * Gets the property element.
+ * @return the property element.
+ */
public Element getElement() {
ensureValidity();
Element element = new Element("property", "");
@@ -66,6 +148,9 @@
return element;
}
+ /**
+ * Checks the configuration validity.
+ */
private void ensureValidity() {
// Two cases
// Field or Method
@@ -77,6 +162,24 @@
}
}
+ /**
+ * Gets the property description for the current property.
+ * @param instance the component instance on which looking for the property.
+ * @return the property description associated with the current property
+ * or <code>null</code> if not found.
+ */
+ public PropertyDescription getPropertyDescription(ComponentInstance instance) {
+ PrimitiveInstanceDescription desc = (PrimitiveInstanceDescription) instance.getInstanceDescription();
+ PropertyDescription[] props = desc.getProperties();
+
+ for (int i = 0; i < props.length; i++) {
+ if ((m_name != null && m_name.equals(props[i].getName()))
+ || (m_field != null && m_field.equals(props[i].getName()))) {
+ return props[i];
+ }
+ }
+
+ return null;
+ }
-
}
Modified: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Service.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Service.java?rev=733703&r1=733702&r2=733703&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Service.java (original)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/Service.java Mon Jan 12 03:54:20 2009
@@ -1,19 +1,64 @@
+/*
+ * 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.felix.ipojo.api;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
import org.apache.felix.ipojo.handlers.providedservice.ProvidedService;
+import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceDescription;
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
+/**
+ * Allows configuring a provided service.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
public class Service {
+ /**
+ * The provided service specification.
+ */
private List m_specifications; // null be default computed.
+
+ /**
+ * The provided service strategy.
+ */
private int m_strategy = ProvidedService.SINGLETON_STRATEGY;
+
+ /**
+ * The provided service custom strategy.
+ */
private String m_customStrategy;
+
+ /**
+ * The service properties.
+ */
private List m_properties = new ArrayList();
+ /**
+ * Gets the provided service element.
+ * @return the 'provides' element.
+ */
public Element getElement() {
ensureValidity();
Element element = new Element("provides", "");
@@ -26,13 +71,52 @@
}
return element;
}
+
+ /**
+ * Gets the provided service description associated with the current service.
+ * @param instance the instance on which looking for the provided service description
+ * @return the provided service description or <code>null</code> if not found.
+ */
+ public ProvidedServiceDescription getProvidedServiceDescription(ComponentInstance instance) {
+ PrimitiveInstanceDescription desc = (PrimitiveInstanceDescription) instance.getInstanceDescription();
+ ProvidedServiceDescription[] pss = desc.getProvidedServices();
+ if (pss.length == 0) {
+ return null;
+ }
+
+ if (pss.length == 1) {
+ return pss[0];
+ }
+
+ if (m_specifications == null) {
+ return null;
+ } else {
+ for (int j = 0; j < pss.length; j++) {
+ ProvidedServiceDescription psd = pss[j];
+ List specs = Arrays.asList(psd.getServiceSpecifications());
+ if (specs.containsAll(m_specifications)) {
+ return psd;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Checks the validity of the configuration.
+ */
private void ensureValidity() {
// No check required.
}
+ /**
+ * The the service specification array as a String.
+ * @return the string-from of the service specifications.
+ */
private String getSpecificationsArray() {
if (m_specifications.size() == 1) {
return (String) m_specifications.get(0);
@@ -49,50 +133,80 @@
}
}
+ /**
+ * Adds a service property.
+ * @param ps the service property to add
+ * @return the current service object.
+ */
public Service addProperty(ServiceProperty ps) {
- m_properties.add(ps);
- return this;
+ m_properties.add(ps);
+ return this;
}
+ /**
+ * Sets the provided service specification.
+ * @param spec the service specification
+ * @return the current service object.
+ */
public Service setSpecification(String spec) {
m_specifications = new ArrayList(1);
m_specifications.add(spec);
return this;
}
+ /**
+ * Sets the provided service specifications.
+ * @param specs the service specifications
+ * @return the current service object.
+ */
public Service setSpecifications(List specs) {
m_specifications = specs;
return this;
}
+ /**
+ * Sets the creation strategy.
+ * @param strategy the service strategy.
+ * @return the current service object
+ */
public Service setCreationStrategy(int strategy) {
m_strategy = strategy;
return this;
}
+ /**
+ * Sets the creation strategy.
+ * This method allows using a customized
+ * service strategy.
+ * @param strategy the service strategy
+ * @return the current service object
+ */
public Service setCreationStrategy(String strategy) {
m_strategy = -1; // Custom
m_customStrategy = strategy;
return this;
}
- private String getStringStrategy() {
+ /**
+ * Gets the string-form of the creation strategy.
+ * @return the creation strategy string form
+ */
+ private String getStringStrategy() {
switch (m_strategy) {
case -1: // Custom policies
- return m_customStrategy;
+ return m_customStrategy;
case ProvidedService.SINGLETON_STRATEGY:
- return "singleton";
- case ProvidedService.STATIC_STRATEGY:
- return "method";
+ return "singleton";
+ case ProvidedService.STATIC_STRATEGY:
+ return "method";
case ProvidedService.SERVICE_STRATEGY:
- return "service";
+ return "service";
case ProvidedService.INSTANCE_STRATEGY:
- return "instance";
+ return "instance";
default:
- throw new IllegalStateException("Unknown creation strategy : " + m_strategy);
+ throw new IllegalStateException("Unknown creation strategy : "
+ + m_strategy);
}
}
-
-
}
Modified: felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ServiceProperty.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ServiceProperty.java?rev=733703&r1=733702&r2=733703&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ServiceProperty.java (original)
+++ felix/sandbox/clement/ipojo-utils/org.apache.felix.ipojo.api/src/main/java/org/apache/felix/ipojo/api/ServiceProperty.java Mon Jan 12 03:54:20 2009
@@ -1,47 +1,130 @@
+/*
+ * 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.felix.ipojo.api;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceDescription;
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
+/**
+ * Allows configuring a service property.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
public class ServiceProperty {
+ /**
+ * The property name.
+ */
private String m_name;
+
+ /**
+ * The property field.
+ */
private String m_field;
+
+ /**
+ * The property type.
+ */
private String m_type;
+
+ /**
+ * The property value.
+ */
private String m_value;
+
+ /**
+ * Is the property mandatory.
+ */
private boolean m_mandatory;
+
+ /**
+ * Is the property immutable.
+ */
private boolean m_immutable;
+ /**
+ * Sets the property name.
+ * @param name the property name
+ * @return the current property object
+ */
public ServiceProperty setName(String name) {
m_name = name;
return this;
}
+ /**
+ * Sets the property field.
+ * @param name the property field
+ * @return the current property object
+ */
public ServiceProperty setField(String name) {
m_field = name;
return this;
}
+ /**
+ * Sets the property type.
+ * @param name the property type
+ * @return the current property object
+ */
public ServiceProperty setType(String name) {
m_type = name;
return this;
}
+ /**
+ * Sets the property value.
+ * @param name the property value
+ * @return the current property object
+ */
public ServiceProperty setValue(String name) {
m_value = name;
return this;
}
+ /**
+ * Sets if the property is immutable.
+ * @param immutable <code>true</code> if the dependency is immutable.
+ * @return the current property object
+ */
public ServiceProperty setImmutable(boolean immutable) {
m_immutable = immutable;
return this;
}
+ /**
+ * Sets if the property is mandatory.
+ * @param mandatory <code>true</code> if the dependency is mandatory.
+ * @return the current property object
+ */
public ServiceProperty setMandatory(boolean mandatory) {
m_mandatory = mandatory;
return this;
}
+
+ /**
+ * Gets the 'property' element.
+ * @return the element describing the current property.
+ */
public Element getElement() {
ensureValidity();
Element element = new Element("property", "");
@@ -66,6 +149,9 @@
return element;
}
+ /**
+ * Checks the configuration validity.
+ */
private void ensureValidity() {
// Two cases
// Field or type
@@ -77,6 +163,30 @@
}
}
-
+ /**
+ * Gets the property value of the current property
+ * on the given instance.
+ * @param instance the instance on which looking for
+ * the property value
+ * @return the property value or <code>null</code>
+ * if not found.
+ */
+ public Object getPropertyValue(ComponentInstance instance) {
+ PrimitiveInstanceDescription desc = (PrimitiveInstanceDescription) instance.getInstanceDescription();
+ ProvidedServiceDescription[] pss = desc.getProvidedServices();
+ for (int i = 0; i < pss.length; i++) {
+ // Check with the name
+ if (m_name != null && pss[i].getProperties().containsKey(m_name)) {
+ return pss[i].getProperties().get(m_name);
+ }
+ // Check with the field
+ if (m_field != null && pss[i].getProperties().containsKey(m_field)) {
+ return pss[i].getProperties().get(m_field);
+ }
+ }
+ // Not found.
+ return null;
+ }
+
}