Return-Path: Delivered-To: apmail-aries-commits-archive@www.apache.org Received: (qmail 87942 invoked from network); 27 Feb 2011 21:21:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Feb 2011 21:21:51 -0000 Received: (qmail 29628 invoked by uid 500); 27 Feb 2011 21:21:51 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 29528 invoked by uid 500); 27 Feb 2011 21:21:50 -0000 Mailing-List: contact commits-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list commits@aries.apache.org Received: (qmail 29519 invoked by uid 99); 27 Feb 2011 21:21:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Feb 2011 21:21:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Feb 2011 21:21:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EB9F823889E9; Sun, 27 Feb 2011 21:21:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1075149 [2/23] - in /aries/tags/blueprint-0.3.1: ./ blueprint-annotation-api/ blueprint-annotation-api/src/ blueprint-annotation-api/src/main/ blueprint-annotation-api/src/main/java/ blueprint-annotation-api/src/main/java/org/ blueprint-an... Date: Sun, 27 Feb 2011 21:21:22 -0000 To: commits@aries.apache.org From: zoe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110227212126.EB9F823889E9@eris.apache.org> Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Inject.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Inject.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Inject.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Inject.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,32 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Inject { + String value() default ""; + String name() default ""; + String description() default ""; + String ref() default ""; + String[] values() default {}; +} \ No newline at end of file Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,36 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * used to annotate list value in property + * I am not convinced that we want to support this via annotation + * + */ +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface List { + + // the element of the list + public Element[] value(); + +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Reference.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Reference.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Reference.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Reference.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,69 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Reference +{ + /** + * the description property of the service reference + */ + String description() default ""; + + /** + * the interface type that a matching service must support. + */ + Class serviceInterface() default Object.class; + + /** + * the filter expression that a matching service must match. + */ + String filter() default ""; + + /** + * the component-name attribute of the service reference. + */ + String componentName() default ""; + + /** + * whether or not a matching service is required at all times. either optional or mandatory. + */ + String availability() default ""; + + /** + * the reference listeners for the service reference, to receive bind and unbind events. + */ + ReferenceListener[] referenceListeners() default {}; + + /** + * the timeout property. If the timeout is not specified, + * the default-timeout value is inherited from the encapsulating + * definition. + */ + int timeout() default 0; + + /** + * the id for the reference + */ + String id() default ""; +} \ No newline at end of file Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceList.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceList.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceList.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceList.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,67 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ReferenceList +{ + /** + * the description property of the service reference + */ + String description() default ""; + + /** + * the interface type that a matching service must support. + */ + Class serviceInterface() default Object.class; + + /** + * the filter expression that a matching service must match. + */ + String filter() default ""; + + /** + * the component-name attribute of the service reference. + */ + String componentName() default ""; + + /** + * whether or not a matching service is required at all times. either optional or mandatory. + */ + String availability() default ""; + + /** + * the reference listeners for the service reference, to receive bind and unbind events. + */ + ReferenceListener[] referenceListeners() default {}; + + /** + * the value of the memberType property. + */ + String memberType() default "service-object"; + + /** + * the id for the referencelist + */ + String id() default ""; +} \ No newline at end of file Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceListener.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceListener.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceListener.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ReferenceListener.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,28 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ReferenceListener { + String ref() default ""; +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Register.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Register.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Register.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Register.java Sun Feb 27 21:21:05 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * used to annotation register-method in blueprint registration listeners + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Register { +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/RegistrationListener.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/RegistrationListener.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/RegistrationListener.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/RegistrationListener.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,29 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface RegistrationListener { + + String ref() default ""; +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Service.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Service.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Service.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Service.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,56 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface Service { + + /** + * the registration listeners to be notified when the service is + * registered and unregistered with the framework. + */ + RegistrationListener[] registerationListeners() default {}; + + /** + * the ranking value to use when advertising the service. If the + * ranking value is zero, the service must be registered without a + * service.ranking service property. + */ + int ranking() default 0; + + /** + * the auto-export mode for the service. + * possible values are disabled, interfaces, class_hierarchy, all_classes + */ + String autoExport() default ""; + + /** + * the interfaces that the service should be advertised as supporting. + */ + Class[] interfaces() default {}; + + /** + * the user declared properties to be advertised with the service. + */ + ServiceProperty[] serviceProperties() default {}; +} \ No newline at end of file Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ServiceProperty.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ServiceProperty.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ServiceProperty.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ServiceProperty.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,36 @@ +/** + * 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ServiceProperty { + /** + * the key of the property + */ + String key() default ""; + + /** + * the value of the property + */ + String value() default ""; +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unbind.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unbind.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unbind.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unbind.java Sun Feb 27 21:21:05 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * used to annotation unbind-method in blueprint reference listeners + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Unbind { +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unregister.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unregister.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unregister.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Unregister.java Sun Feb 27 21:21:05 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.aries.blueprint.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * used to annotation unregister-method in blueprint registration listeners + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Unregister { +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/service/BlueprintAnnotationScanner.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/service/BlueprintAnnotationScanner.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/service/BlueprintAnnotationScanner.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/service/BlueprintAnnotationScanner.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,27 @@ +/** + * 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.aries.blueprint.annotation.service; + +import java.net.URL; + +import org.osgi.framework.Bundle; + +public interface BlueprintAnnotationScanner { + + public URL createBlueprintModel(Bundle bundle); + +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-impl/pom.xml URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-impl/pom.xml?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-impl/pom.xml (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-impl/pom.xml Sun Feb 27 21:21:05 2011 @@ -0,0 +1,94 @@ + + + 4.0.0 + + org.apache.aries.blueprint + blueprint + 0.3.1 + + + org.apache.aries.blueprint.annotation.impl + bundle + Apache Aries Blueprint Annotation Impl + + This bundle contains the core implementation of Blueprint + along with the "ext" namespace handler. + + + + + org.apache.aries.blueprint.annotation.impl.Activator + + + org.apache.aries.blueprint.jaxb.*, + org.apache.aries.blueprint.annotation.impl + + + !org.apache.aries.blueprint.jaxb.*, + !org.apache.aries.blueprint.annotation.impl, + org.apache.aries.blueprint.annotation, + * + + + org.apache.aries.blueprint.annotation.AnnotationScannerService + + + + + + org.apache.aries.blueprint + org.apache.aries.blueprint.annotation.api + + + org.osgi + org.osgi.core + provided + + + org.osgi + org.osgi.compendium + provided + + + org.eclipse + osgi + provided + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + test + + + asm + asm-all + true + + + org.apache.xbean + xbean-finder + + + + Added: aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/Activator.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/Activator.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/Activator.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/Activator.java Sun Feb 27 21:21:05 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.aries.blueprint.annotation.impl; + +import java.util.Dictionary; +import java.util.Hashtable; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceRegistration; +import org.apache.aries.blueprint.annotation.service.BlueprintAnnotationScanner; + +public class Activator implements BundleActivator { + + ServiceRegistration sr; + + public void start(BundleContext context) { + Dictionary dict = new Hashtable(); + dict.put(Constants.SERVICE_RANKING, 0); + sr = context.registerService(BlueprintAnnotationScanner.class.getName(), new BlueprintAnnotationScannerImpl(context), dict); + } + + public void stop(BundleContext context) { + if (sr != null) { + sr.unregister(); + } + } + +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationException.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationException.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationException.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationException.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,35 @@ +/** + * 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.aries.blueprint.annotation.impl; + +public class BlueprintAnnotationException extends RuntimeException { + public BlueprintAnnotationException() { + } + + public BlueprintAnnotationException(String message) { + super(message); + } + + public BlueprintAnnotationException(String message, Throwable cause) { + super(message, cause); + } + + public BlueprintAnnotationException(Throwable cause) { + super(cause); + } + +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,705 @@ +/** + * 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.aries.blueprint.annotation.impl; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.aries.blueprint.annotation.Arg; +import org.apache.aries.blueprint.annotation.Bean; +import org.apache.aries.blueprint.annotation.Bind; +import org.apache.aries.blueprint.annotation.Blueprint; +import org.apache.aries.blueprint.annotation.Destroy; +import org.apache.aries.blueprint.annotation.Init; +import org.apache.aries.blueprint.annotation.Inject; +import org.apache.aries.blueprint.annotation.Reference; +import org.apache.aries.blueprint.annotation.ReferenceList; +import org.apache.aries.blueprint.annotation.ReferenceListener; +import org.apache.aries.blueprint.annotation.Register; +import org.apache.aries.blueprint.annotation.RegistrationListener; +import org.apache.aries.blueprint.annotation.Service; +import org.apache.aries.blueprint.annotation.ServiceProperty; +import org.apache.aries.blueprint.annotation.Unbind; +import org.apache.aries.blueprint.annotation.Unregister; +import org.apache.aries.blueprint.annotation.service.BlueprintAnnotationScanner; +import org.apache.aries.blueprint.jaxb.Targument; +import org.apache.aries.blueprint.jaxb.Tbean; +import org.apache.aries.blueprint.jaxb.Tblueprint; +import org.apache.aries.blueprint.jaxb.Tdescription; +import org.apache.aries.blueprint.jaxb.Tinterfaces; +import org.apache.aries.blueprint.jaxb.Tproperty; +import org.apache.aries.blueprint.jaxb.Treference; +import org.apache.aries.blueprint.jaxb.TreferenceList; +import org.apache.aries.blueprint.jaxb.TreferenceListener; +import org.apache.aries.blueprint.jaxb.TregistrationListener; +import org.apache.aries.blueprint.jaxb.Tservice; +import org.apache.aries.blueprint.jaxb.TserviceProperties; +import org.apache.aries.blueprint.jaxb.TservicePropertyEntry; +import org.apache.aries.blueprint.jaxb.TtypeConverters; +import org.apache.aries.blueprint.jaxb.Tvalue; +import org.apache.xbean.finder.BundleAnnotationFinder; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.blueprint.container.Converter; +import org.osgi.service.packageadmin.PackageAdmin; + +public class BlueprintAnnotationScannerImpl implements + BlueprintAnnotationScanner { + private BundleContext context; + + public BlueprintAnnotationScannerImpl(BundleContext bc) { + this.context = bc; + } + + private BundleContext getBlueprintExtenderContext() { + Bundle[] bundles = this.context.getBundles(); + for (Bundle b : bundles) { + if (b.getSymbolicName().equals("org.apache.aries.blueprint.core")) { + return b.getBundleContext(); + } + } + + return null; + } + + private BundleAnnotationFinder createBundleAnnotationFinder(Bundle bundle) { + ServiceReference sr = this.context.getServiceReference(PackageAdmin.class.getName()); + PackageAdmin pa = (PackageAdmin) this.context.getService(sr); + BundleAnnotationFinder baf = null; + try { + baf = new BundleAnnotationFinder(pa, bundle); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + this.context.ungetService(sr); + + return baf; + } + + public URL createBlueprintModel(Bundle bundle) { + + Tblueprint tblueprint = generateBlueprintModel(bundle); + + if (tblueprint != null) { + // create the generated blueprint xml file in bundle storage + // area + BundleContext ctx = getBlueprintExtenderContext(); + + if (ctx == null) { + // blueprint extender doesn't exist, let' still generate the + // bundle, using the bundle's bundle context + ctx = bundle.getBundleContext(); + } + + File dir = ctx.getDataFile(bundle.getSymbolicName() + "/" + + bundle.getVersion() + "/"); + if (!dir.exists()) { + dir.mkdirs(); + } + String blueprintPath = cachePath(bundle, + "annotation-generated-blueprint.xml"); + File file = ctx.getDataFile(blueprintPath); + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + try { + marshallOBRModel(tblueprint, file); + } catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + return file.toURL(); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return null; + + } + + private void marshallOBRModel(Tblueprint tblueprint, File blueprintFile) + throws JAXBException { + JAXBContext context = JAXBContext.newInstance(Tblueprint.class); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.marshal(tblueprint, blueprintFile); + + } + + private Tblueprint generateBlueprintModel(Bundle bundle) { + BundleAnnotationFinder baf = createBundleAnnotationFinder(bundle); + + List blueprintClasses = baf.findAnnotatedClasses(Blueprint.class); + List beanClasses = baf.findAnnotatedClasses(Bean.class); + List refListenerClasses = baf.findAnnotatedClasses(ReferenceListener.class); + List regListenerClasses = baf.findAnnotatedClasses(RegistrationListener.class); + Map reflMap = new HashMap(); + Map reglMap = new HashMap(); + + Tblueprint tblueprint = new Tblueprint(); + + + if (!blueprintClasses.isEmpty()) { + // use the first annotated blueprint annotation + Blueprint blueprint = (Blueprint)blueprintClasses.get(0).getAnnotation(Blueprint.class); + tblueprint.setDefaultActivation(blueprint.defaultActivation()); + tblueprint.setDefaultAvailability(blueprint.defaultAvailability()); + tblueprint.setDefaultTimeout(convertToBigInteger(blueprint.defaultTimeout())); + } + + List components = tblueprint.getServiceOrReferenceListOrBean(); + + // try to process classes that have @ReferenceListener or @RegistrationLister first + // as we want the refl and regl maps populated before processing @Bean annotation. + for (Class refListener : refListenerClasses) { + Bean bean = (Bean) refListener.getAnnotation(Bean.class); + + // register the treference with its id + TreferenceListener tref = generateTrefListener(refListener); + + if (bean.id().length() > 0) { + reflMap.put(bean.id(), tref); + } else { + throw new BlueprintAnnotationException("Unable to find the id for the @ReferenceListener annotated class " + refListener.getName()); + } + } + + + for (Class regListener : regListenerClasses) { + Bean bean = (Bean) regListener.getAnnotation(Bean.class); + + // register the tregistrationListener with its id + TregistrationListener tref = generateTregListener(regListener); + + if (bean.id().length() > 0) { + reglMap.put(bean.id(), tref); + } else { + throw new BlueprintAnnotationException("Unable to find the id for the @RegistrationListener annotated class " + regListener.getName()); + } + } + + for (Class clazz : beanClasses) { + // @Bean annotation detected + Bean bean = (Bean)clazz.getAnnotation(Bean.class); + Tbean tbean = new Tbean(); + + // process depends-on property + String[] dependsOn = bean.dependsOn(); + if (!containsValid(dependsOn)) { + tbean.setDependsOn(null); + } else { + List dons = Arrays.asList(dependsOn); + tbean.setDependsOn(dons); + } + + // process id property + String id = bean.id(); + if (id.length() > 0) { + tbean.setId(id); + } else { + // should we auto generate an id, based on the class name? + tbean.setId(clazz.getSimpleName()); + } + + // process the clazz property + tbean.setClazz(clazz.getName()); + + // process activation + String activation = bean.activation(); + if (activation.length() > 0) { + if (activation.equalsIgnoreCase("eager") || activation.equalsIgnoreCase("lazy")) { + tbean.setActivation(bean.activation()); + } else { + throw new BlueprintAnnotationException("Invalid bean activation value " + activation + " for " + clazz.getName()); + } + } + + // process description + if (bean.description().length() > 0) { + Tdescription desp = new Tdescription(); + desp.getContent().add(bean.description()); + tbean.setDescription(desp); + } + + // process scope + String scope = bean.scope(); + if (scope.length() > 0) { + if (scope.equalsIgnoreCase("singleton") || scope.equalsIgnoreCase("prototype")) { + tbean.setScope(scope); + } else { + throw new BlueprintAnnotationException("Invalid bean scope value " + scope + " for " + clazz.getName()); + } + } + + // process factory ref + String factoryRef = bean.factoryRef(); + if (factoryRef.length() > 0) { + tbean.setFactoryRef(factoryRef); + } + + // process factory method + String factoryMethod = bean.factoryMethod(); + if (factoryMethod.length() > 0) { + tbean.setFactoryMethod(factoryMethod); + } + + + List props = tbean.getArgumentOrPropertyOrAny(); + + // process args + Arg[] args = bean.args(); + + if (args.length > 0) { + for (int i = 0; i < args.length; i++) { + Targument targ = createTargument(args[i]); + if (targ != null) { + props.add(targ); + } + } + } + + Field[] fields = clazz.getDeclaredFields(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].isAnnotationPresent(Inject.class)) { + if (fields[i].isAnnotationPresent(Reference.class)) { + // the field is also annotated with @Reference + Reference ref = (Reference)fields[i].getAnnotation(Reference.class); + Treference tref = generateTref(ref, reflMap); + components.add(tref); + } else if (fields[i].isAnnotationPresent(ReferenceList.class)) { + // the field is also annotated with @ReferenceList + ReferenceList ref = (ReferenceList)fields[i].getAnnotation(ReferenceList.class); + TreferenceList tref = generateTrefList(ref, reflMap); + components.add(tref); + + } else { + Tproperty tp = createTproperty(fields[i].getName(), fields[i].getAnnotation(Inject.class)); + props.add(tp); + } + } + } + + // check if the bean also declares init, destroy or inject annotation on methods + Method[] methods = clazz.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].isAnnotationPresent(Init.class)) { + tbean.setInitMethod(methods[i].getName()); + } else if (methods[i].isAnnotationPresent(Destroy.class)) { + tbean.setDestroyMethod(methods[i].getName()); + } else if (methods[i].isAnnotationPresent(Inject.class)) { + String propertyName = convertFromMethodName(methods[i].getName()); + Tproperty tp = createTproperty(propertyName, methods[i].getAnnotation(Inject.class)); + props.add(tp); + } else if (methods[i].isAnnotationPresent(Arg.class)) { + Targument targ = createTargument(methods[i].getAnnotation(Arg.class)); + props.add(targ); + } + } + + // check if the bean also declares service + if (clazz.getAnnotation(Service.class) != null) { + Tservice tservice = generateTservice(clazz, id, reglMap); + components.add(tservice); + } + + // check if the clazz implement Converter, if so, it is Converter + boolean isConverter = isConverter(clazz); + if (isConverter) { + TtypeConverters converters = tblueprint.getTypeConverters(); + List objects = converters.getBeanOrReferenceOrRef(); + objects.add(tbean); + } else { + components.add(tbean); + } + } + + return tblueprint; + } + + private TreferenceListener generateTrefListener(Class refListener) { + ReferenceListener rl = (ReferenceListener) refListener.getAnnotation(ReferenceListener.class); + + String ref = rl.ref(); + String bind = null; + String unbind = null; + + // also check bind/unbind method + Method[] methods = refListener.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].isAnnotationPresent(Bind.class)) { + if (bind == null) { + bind = methods[i].getName(); + } else if (!bind.equals(methods[i].getName())) { + throw new BlueprintAnnotationException("@Bind annottaed method for reference listener " + refListener.getName() + " are not consistent"); + } + continue; + } + if (methods[i].isAnnotationPresent(Unbind.class)) { + if (unbind == null) { + unbind = methods[i].getName(); + } else if (!unbind.equals(methods[i].getName())) { + throw new BlueprintAnnotationException("@Unbind annotated method for reference listener " + refListener.getName() + " are not consistent"); + } + continue; + } + } + + TreferenceListener trl = new TreferenceListener(); + if (bind != null) { + trl.setBindMethod(bind); + } + if (unbind != null) { + trl.setUnbindMethod(unbind); + } + + if (ref != null) { + trl.setRefAttribute(ref); + } + + return trl; + } + + private TregistrationListener generateTregListener(Class regListener) { + RegistrationListener rl = (RegistrationListener) regListener.getAnnotation(RegistrationListener.class); + + String register = null; + String unregister = null; + + // also check bind/unbind method + Method[] methods = regListener.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].isAnnotationPresent(Register.class)) { + if (register == null) { + register = methods[i].getName(); + } else if (!register.equals(methods[i].getName())) { + throw new BlueprintAnnotationException("@Register annottaed method for registration listener " + regListener.getName() + " are not consistent"); + } + continue; + } + if (methods[i].isAnnotationPresent(Unregister.class)) { + if (unregister == null) { + unregister = methods[i].getName(); + } else if (!unregister.equals(methods[i].getName())) { + throw new BlueprintAnnotationException("@Unregister annotated method for registration listener " + regListener.getName() + " are not consistent"); + } + continue; + } + } + + TregistrationListener trl = new TregistrationListener(); + if (register != null) { + trl.setRegistrationMethod(register); + } + if (unregister != null) { + trl.setUnregistrationMethod(unregister); + } + + return trl; + } + + private Targument createTargument(Arg arg) { + String value = arg.value(); + String ref = arg.ref(); + Targument targ = null; + if (value.length() > 0) { + targ = new Targument(); + targ.setValueAttribute(value); + } + + if (ref.length() > 0) { + if (targ == null) { + targ = new Targument(); + } + + targ.setRefAttribute(ref); + } + + // TODO process description, index of Arg annotation + return targ; + } + + private String convertFromMethodName(String name) { + if (name.length() > 3) { + name = name.substring(3); + } else { + throw new BlueprintAnnotationException("The annotated method name " + name + " is invalid"); + } + String firstChar = name.substring(0, 1).toLowerCase(); + + if (name.length() == 1) { + return firstChar; + } else { + return firstChar + name.substring(1); + } + } + + /** + * @param nm method or field name + * @param inj inject annotation + * @return + */ + private Tproperty createTproperty(String nm, Inject inj) { + String value = inj.value(); + String ref = inj.ref(); + String name = inj.name(); + String desp = inj.description(); + + Tproperty tp = new Tproperty(); + if (value.length() > 0) { + Tvalue tvalue = new Tvalue(); + tvalue.setContent(value); + tp.setValue(tvalue); + } + + if (ref.length() > 0) { + tp.setRefAttribute(ref); + } + + if (name.length() > 0) { + tp.setName(name); + } else { + tp.setName(nm); + } + + if (desp.length() > 0) { + Tdescription tdesp = new Tdescription(); + tdesp.getContent().add(desp); + tp.setDescription(tdesp); + + } + + return tp; + } + + private boolean isConverter(Class clazz) { + Class[] classes = clazz.getInterfaces(); + for (int i = 0; i < classes.length; i++) { + if (classes[i].getName().equals(Converter.class.getName())) { + return true; + } + + } + return false; + + } + + private BigInteger convertToBigInteger(int timeout) { + return BigInteger.valueOf(timeout * 1000); + } + + private boolean containsValid(String[] dependsOn) { + for (int i = 0; i < dependsOn.length; i++) { + if (dependsOn[i].length() != 0) { + return true; + } + } + return false; + } + + // copy from blueprint extender + private String cachePath(Bundle bundle, String filePath) { + return bundle.getSymbolicName() + "/" + bundle.getVersion() + "/" + + filePath; + } + + private Treference generateTref(Reference ref, Map reflMap) { + + String id = ref.id(); + String availability = ref.availability(); + String compName = ref.componentName(); + String desp = ref.description(); + String filter = ref.filter(); + Class serviceInterface = ref.serviceInterface(); + ReferenceListener[] refListeners = ref.referenceListeners(); + int timeout = ref.timeout(); + Treference tref = new Treference(); + + // can not think of configuring depends on for reference + tref.setDependsOn(null); + + if (id.length() > 0) { + tref.setId(id); + } + + if (availability.length() > 0) { + tref.setAvailability(availability); + } + if (compName.length() > 0) { + tref.setComponentName(compName); + } + if (desp.length() > 0) { + Tdescription value = new Tdescription(); + value.getContent().add(desp); + tref.setDescription(value); + } + if (filter.length() > 0) { + tref.setFilter(filter); + } + if (serviceInterface != Object.class) { + tref.setInterface(serviceInterface.getName()); + } + + if (timeout > 0) { + tref.setTimeout(convertToBigInteger(timeout)); + } + for (ReferenceListener rl : refListeners) { + String rf = rl.ref(); + TreferenceListener trl = reflMap.get(rf); + if (trl != null) { + trl.setRefAttribute(rf); + tref.getReferenceListener().add(trl); + } else { + throw new BlueprintAnnotationException("Unable to find the ReferenceListener ref " + rf); + } + } + + return tref; + } + + private TreferenceList generateTrefList(ReferenceList ref, Map reflMap) { + String id = ref.id(); + String availability = ref.availability(); + String compName = ref.componentName(); + String desp = ref.description(); + String filter = ref.filter(); + Class serviceInterface = ref.serviceInterface(); + ReferenceListener[] refListeners = ref.referenceListeners(); + TreferenceList tref = new TreferenceList(); + + // can not think of configuring depends on for referencelist + tref.setDependsOn(null); + + if (id.length() > 0) { + tref.setId(id); + } + + if (availability.length() > 0) { + tref.setAvailability(availability); + } + if (compName.length() > 0) { + tref.setComponentName(compName); + } + if (desp.length() > 0) { + Tdescription value = new Tdescription(); + value.getContent().add(desp); + tref.setDescription(value); + } + if (filter.length() > 0) { + tref.setFilter(filter); + } + if (serviceInterface != Object.class) { + tref.setInterface(serviceInterface.getName()); + } + + for (ReferenceListener rl : refListeners) { + String rf = rl.ref(); + TreferenceListener trl = reflMap.get(rf); + if (trl != null) { + trl.setRefAttribute(rf); + tref.getReferenceListener().add(trl); + } else { + throw new BlueprintAnnotationException("Unable to find the ReferenceListener ref " + rf); + } + } + + return tref; + } + + private Tservice generateTservice(Class clazz, String id, Map reglMap) { + Service service = (Service) clazz.getAnnotation(Service.class); + Class[] interfaces = service.interfaces(); + int ranking = service.ranking(); + String autoExport = service.autoExport(); + ServiceProperty[] serviceProperties = service.serviceProperties(); + RegistrationListener[] regListeners = service.registerationListeners(); + + Tservice tservice = new Tservice(); + + // can not think of configuring depends on for service + tservice.setDependsOn(null); + + // use the bean id as the ref value since we are exposing service for the bean + tservice.setRefAttribute(id); + + if (autoExport.length() > 0) { + tservice.setAutoExport(autoExport); + } + if (ranking > 0) { + tservice.setRanking(ranking); + } + for (Class interf : interfaces) { + Tinterfaces tInterfaces = new Tinterfaces(); + if (interf != null) { + tInterfaces.getValue().add(interf.getName()); + } + tservice.setInterfaces(tInterfaces); + } + + // process service property. only key value as string are supported for now + for (ServiceProperty sp : serviceProperties) { + if (sp != null) { + String key = sp.key(); + String value = sp.value(); + if (key.length() > 0 && value.length() > 0) { + TservicePropertyEntry tsp = new TservicePropertyEntry(); + tsp.setKey(key); + tsp.setValueAttribute(value); + tservice.getServiceProperties().getEntry().add(tsp); + } + + } + } + + for (RegistrationListener regListener : regListeners) { + String ref = regListener.ref(); + if (ref.length() > 0) { + TregistrationListener tregListener = reglMap.get(ref); + tregListener.setRefAttribute(ref); + tservice.getRegistrationListener().add(tregListener); + + } else { + throw new BlueprintAnnotationException("No ref id for service registration listener " + " for " + clazz.getName()); + } + } + + return tservice; + } +} Added: aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/jaxb/ObjectFactory.java URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/jaxb/ObjectFactory.java?rev=1075149&view=auto ============================================================================== --- aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/jaxb/ObjectFactory.java (added) +++ aries/tags/blueprint-0.3.1/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/jaxb/ObjectFactory.java Sun Feb 27 21:21:05 2011 @@ -0,0 +1,497 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 1.6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2010.04.23 at 12:57:08 PM EDT +// + + +package org.apache.aries.blueprint.jaxb; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.apache.aries.blueprint.jaxb package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _Blueprint_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "blueprint"); + private final static QName _TbeanArgument_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "argument"); + private final static QName _TbeanProperty_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "property"); + private final static QName _TtypeConvertersReference_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "reference"); + private final static QName _TtypeConvertersBean_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "bean"); + private final static QName _TtypeConvertersRef_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "ref"); + private final static QName _TblueprintReferenceList_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "reference-list"); + private final static QName _TblueprintService_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "service"); + private final static QName _TcollectionIdref_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "idref"); + private final static QName _TcollectionArray_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "array"); + private final static QName _TcollectionMap_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "map"); + private final static QName _TcollectionList_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "list"); + private final static QName _TcollectionProps_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "props"); + private final static QName _TcollectionValue_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "value"); + private final static QName _TcollectionSet_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "set"); + private final static QName _TcollectionNull_QNAME = new QName("http://www.osgi.org/xmlns/blueprint/v1.0.0", "null"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.aries.blueprint.jaxb + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Tprop } + * + */ + public Tprop createTprop() { + return new Tprop(); + } + + /** + * Create an instance of {@link Tref } + * + */ + public Tref createTref() { + return new Tref(); + } + + /** + * Create an instance of {@link Tbean } + * + */ + public Tbean createTbean() { + return new Tbean(); + } + + /** + * Create an instance of {@link TtypeConverters } + * + */ + public TtypeConverters createTtypeConverters() { + return new TtypeConverters(); + } + + /** + * Create an instance of {@link TtypedCollection } + * + */ + public TtypedCollection createTtypedCollection() { + return new TtypedCollection(); + } + + /** + * Create an instance of {@link TinlinedService } + * + */ + public TinlinedService createTinlinedService() { + return new TinlinedService(); + } + + /** + * Create an instance of {@link TinlinedReferenceList } + * + */ + public TinlinedReferenceList createTinlinedReferenceList() { + return new TinlinedReferenceList(); + } + + /** + * Create an instance of {@link Targument } + * + */ + public Targument createTargument() { + return new Targument(); + } + + /** + * Create an instance of {@link Tinterfaces } + * + */ + public Tinterfaces createTinterfaces() { + return new Tinterfaces(); + } + + /** + * Create an instance of {@link Tblueprint } + * + */ + public Tblueprint createTblueprint() { + return new Tblueprint(); + } + + /** + * Create an instance of {@link Tproperty } + * + */ + public Tproperty createTproperty() { + return new Tproperty(); + } + + /** + * Create an instance of {@link TserviceReference } + * + */ + public TserviceReference createTserviceReference() { + return new TserviceReference(); + } + + /** + * Create an instance of {@link TserviceProperties } + * + */ + public TserviceProperties createTserviceProperties() { + return new TserviceProperties(); + } + + /** + * Create an instance of {@link TinlinedReference } + * + */ + public TinlinedReference createTinlinedReference() { + return new TinlinedReference(); + } + + /** + * Create an instance of {@link Tkey } + * + */ + public Tkey createTkey() { + return new Tkey(); + } + + /** + * Create an instance of {@link Tdescription } + * + */ + public Tdescription createTdescription() { + return new Tdescription(); + } + + /** + * Create an instance of {@link Tvalue } + * + */ + public Tvalue createTvalue() { + return new Tvalue(); + } + + /** + * Create an instance of {@link TreferenceList } + * + */ + public TreferenceList createTreferenceList() { + return new TreferenceList(); + } + + /** + * Create an instance of {@link TreferenceListener } + * + */ + public TreferenceListener createTreferenceListener() { + return new TreferenceListener(); + } + + /** + * Create an instance of {@link Treference } + * + */ + public Treference createTreference() { + return new Treference(); + } + + /** + * Create an instance of {@link Tservice } + * + */ + public Tservice createTservice() { + return new Tservice(); + } + + /** + * Create an instance of {@link Tnull } + * + */ + public Tnull createTnull() { + return new Tnull(); + } + + /** + * Create an instance of {@link TmapEntry } + * + */ + public TmapEntry createTmapEntry() { + return new TmapEntry(); + } + + /** + * Create an instance of {@link TregistrationListener } + * + */ + public TregistrationListener createTregistrationListener() { + return new TregistrationListener(); + } + + /** + * Create an instance of {@link TinlinedBean } + * + */ + public TinlinedBean createTinlinedBean() { + return new TinlinedBean(); + } + + /** + * Create an instance of {@link Tprops } + * + */ + public Tprops createTprops() { + return new Tprops(); + } + + /** + * Create an instance of {@link Tmap } + * + */ + public Tmap createTmap() { + return new Tmap(); + } + + /** + * Create an instance of {@link TservicePropertyEntry } + * + */ + public TservicePropertyEntry createTservicePropertyEntry() { + return new TservicePropertyEntry(); + } + + /** + * Create an instance of {@link Tcollection } + * + */ + public Tcollection createTcollection() { + return new Tcollection(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tblueprint }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "blueprint") + public JAXBElement createBlueprint(Tblueprint value) { + return new JAXBElement(_Blueprint_QNAME, Tblueprint.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Targument }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "argument", scope = Tbean.class) + public JAXBElement createTbeanArgument(Targument value) { + return new JAXBElement(_TbeanArgument_QNAME, Targument.class, Tbean.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tproperty }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "property", scope = Tbean.class) + public JAXBElement createTbeanProperty(Tproperty value) { + return new JAXBElement(_TbeanProperty_QNAME, Tproperty.class, Tbean.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Treference }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "reference", scope = TtypeConverters.class) + public JAXBElement createTtypeConvertersReference(Treference value) { + return new JAXBElement(_TtypeConvertersReference_QNAME, Treference.class, TtypeConverters.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tbean }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "bean", scope = TtypeConverters.class) + public JAXBElement createTtypeConvertersBean(Tbean value) { + return new JAXBElement(_TtypeConvertersBean_QNAME, Tbean.class, TtypeConverters.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tref }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "ref", scope = TtypeConverters.class) + public JAXBElement createTtypeConvertersRef(Tref value) { + return new JAXBElement(_TtypeConvertersRef_QNAME, Tref.class, TtypeConverters.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Treference }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "reference", scope = Tblueprint.class) + public JAXBElement createTblueprintReference(Treference value) { + return new JAXBElement(_TtypeConvertersReference_QNAME, Treference.class, Tblueprint.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TreferenceList }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "reference-list", scope = Tblueprint.class) + public JAXBElement createTblueprintReferenceList(TreferenceList value) { + return new JAXBElement(_TblueprintReferenceList_QNAME, TreferenceList.class, Tblueprint.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tbean }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "bean", scope = Tblueprint.class) + public JAXBElement createTblueprintBean(Tbean value) { + return new JAXBElement(_TtypeConvertersBean_QNAME, Tbean.class, Tblueprint.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tservice }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "service", scope = Tblueprint.class) + public JAXBElement createTblueprintService(Tservice value) { + return new JAXBElement(_TblueprintService_QNAME, Tservice.class, Tblueprint.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tref }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "idref", scope = Tcollection.class) + public JAXBElement createTcollectionIdref(Tref value) { + return new JAXBElement(_TcollectionIdref_QNAME, Tref.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tcollection }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "array", scope = Tcollection.class) + public JAXBElement createTcollectionArray(Tcollection value) { + return new JAXBElement(_TcollectionArray_QNAME, Tcollection.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tmap }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "map", scope = Tcollection.class) + public JAXBElement createTcollectionMap(Tmap value) { + return new JAXBElement(_TcollectionMap_QNAME, Tmap.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tcollection }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "list", scope = Tcollection.class) + public JAXBElement createTcollectionList(Tcollection value) { + return new JAXBElement(_TcollectionList_QNAME, Tcollection.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tprops }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "props", scope = Tcollection.class) + public JAXBElement createTcollectionProps(Tprops value) { + return new JAXBElement(_TcollectionProps_QNAME, Tprops.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TinlinedBean }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "bean", scope = Tcollection.class) + public JAXBElement createTcollectionBean(TinlinedBean value) { + return new JAXBElement(_TtypeConvertersBean_QNAME, TinlinedBean.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tvalue }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "value", scope = Tcollection.class) + public JAXBElement createTcollectionValue(Tvalue value) { + return new JAXBElement(_TcollectionValue_QNAME, Tvalue.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tref }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "ref", scope = Tcollection.class) + public JAXBElement createTcollectionRef(Tref value) { + return new JAXBElement(_TtypeConvertersRef_QNAME, Tref.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TinlinedService }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "service", scope = Tcollection.class) + public JAXBElement createTcollectionService(TinlinedService value) { + return new JAXBElement(_TblueprintService_QNAME, TinlinedService.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TinlinedReference }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "reference", scope = Tcollection.class) + public JAXBElement createTcollectionReference(TinlinedReference value) { + return new JAXBElement(_TtypeConvertersReference_QNAME, TinlinedReference.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TinlinedReferenceList }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "reference-list", scope = Tcollection.class) + public JAXBElement createTcollectionReferenceList(TinlinedReferenceList value) { + return new JAXBElement(_TblueprintReferenceList_QNAME, TinlinedReferenceList.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tcollection }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "set", scope = Tcollection.class) + public JAXBElement createTcollectionSet(Tcollection value) { + return new JAXBElement(_TcollectionSet_QNAME, Tcollection.class, Tcollection.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Tnull }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/blueprint/v1.0.0", name = "null", scope = Tcollection.class) + public JAXBElement createTcollectionNull(Tnull value) { + return new JAXBElement(_TcollectionNull_QNAME, Tnull.class, Tcollection.class, value); + } + +}