Author: thomas.diesler(a)jboss.com
Date: 2009-06-19 11:11:39 -0400 (Fri, 19 Jun 2009)
New Revision: 90472
Added:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintContext.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintContextImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/JBossXBParser.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaBindingParser.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaResolverParser.java
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/MockBlueprintContext.java
Removed:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/JBossXBParser.java
Modified:
projects/jboss-osgi/trunk/blueprint/impl/pom.xml
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/TBlueprint.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/Tcollection.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanMetadataImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentMetadataImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/MetadataImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/RefMetadataImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/AllElementsParserTestCase.java
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicBeansParserTestCase.java
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicRootParserTestCase.java
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicServiceParserTestCase.java
Log:
Add BlueprintContext
Modified: projects/jboss-osgi/trunk/blueprint/impl/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-06-19 12:53:52 UTC (rev 90471)
+++ projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-06-19 15:11:39 UTC (rev 90472)
@@ -64,6 +64,7 @@
org.osgi.service.blueprint.*
</Export-Package>
<Import-Package>
+ javax.xml.bind.annotation,
org.apache.xerces.dom,
org.jboss.beans.metadata.*,
org.jboss.dependency.spi*,
@@ -71,6 +72,7 @@
org.jboss.osgi.common.log;version=1.0,
org.jboss.osgi.spi;version=1.0,
org.jboss.osgi.spi.service;version=1.0,
+ org.jboss.util.xml,
org.jboss.xb.*,
org.osgi.framework,
org.osgi.service.log,
Added:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintContext.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintContext.java
(rev 0)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintContext.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.osgi.blueprint;
+
+//$Id$
+
+import org.jboss.osgi.blueprint.parser.BlueprintParser;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * The context of the Blueprint implementation
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public interface BlueprintContext
+{
+ String XMLNS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
+
+ LogService getLog();
+
+ BundleContext getBundleContext();
+
+ BlueprintParser getBlueprintParser();
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -29,10 +29,9 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.reflect.ComponentMetadataImpl;
-import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.BeanMetadata;
@@ -57,14 +56,14 @@
public abstract class AbstractManager
{
protected LogService log;
- protected BundleContext context;
+ protected BlueprintContext context;
protected BlueprintContainer container;
private ComponentMetadata component;
- public AbstractManager(BundleContext context, BlueprintContainer container,
ComponentMetadata component)
+ public AbstractManager(BlueprintContext context, BlueprintContainer container,
ComponentMetadata component)
{
- this.log = new LogServiceTracker(context);
+ this.log = context.getLog();
this.context = context;
this.container = container;
this.component = component;
@@ -137,11 +136,11 @@
protected KernelController getKernelController()
{
- ServiceReference sref =
context.getServiceReference(MicrocontainerService.class.getName());
+ ServiceReference sref =
context.getBundleContext().getServiceReference(MicrocontainerService.class.getName());
if (sref == null)
throw new IllegalStateException("Cannot obtain
MicrocontainerService");
- MicrocontainerService service = (MicrocontainerService)context.getService(sref);
+ MicrocontainerService service =
(MicrocontainerService)context.getBundleContext().getService(sref);
KernelController controller = service.getRegisteredBean(KernelController.class,
BEAN_KERNEL_CONTROLLER);
if (controller == null)
throw new IllegalStateException("Cannot obtain KernelController");
@@ -149,7 +148,7 @@
return controller;
}
- static AbstractManager createManager(BundleContext context, BlueprintContainer
container, ComponentMetadata comp)
+ static AbstractManager createManager(BlueprintContext context, BlueprintContainer
container, ComponentMetadata comp)
{
AbstractManager manager = null;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -26,8 +26,8 @@
import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.reflect.BeanMetadataImpl;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.BeanMetadata;
@@ -56,7 +56,7 @@
private BeanMetadataImpl beanMetadata;
private BeanMetaData kernelBean;
- public BeanManager(BundleContext context, BlueprintContainer container, BeanMetadata
compMetadata)
+ public BeanManager(BlueprintContext context, BlueprintContainer container,
BeanMetadata compMetadata)
{
super(context, container, compMetadata);
this.beanMetadata = (BeanMetadataImpl)compMetadata;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -34,6 +34,7 @@
import java.util.Properties;
import java.util.Set;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.BlueprintParser;
import org.jboss.osgi.blueprint.reflect.BlueprintMetadata;
import org.osgi.framework.Bundle;
@@ -72,12 +73,12 @@
public static final String PROPERTY_BLUEPRINT_BUNDLE_SYMBOLIC_NAME =
"osgi.blueprint.container.symbolicname";
public static final String PROPERTY_BLUEPRINT_BUNDLE_VERSION =
"osgi.blueprint.container.version";
- private BundleContext context;
+ private BlueprintContext context;
private Bundle bundle;
private Map<String, AbstractManager> managers = new LinkedHashMap<String,
AbstractManager>();
- public BlueprintContainerImpl(BundleContext context, Bundle bundle)
+ public BlueprintContainerImpl(BlueprintContext context, Bundle bundle)
{
this.context = context;
this.bundle = bundle;
@@ -169,7 +170,7 @@
Properties props = new Properties();
props.setProperty(PROPERTY_BLUEPRINT_BUNDLE_SYMBOLIC_NAME, symbolicName);
props.setProperty(PROPERTY_BLUEPRINT_BUNDLE_VERSION, version);
- context.registerService(BlueprintContainer.class.getName(), this, props);
+ context.getBundleContext().registerService(BlueprintContainer.class.getName(),
this, props);
}
private void createManagers(BlueprintMetadata bpMetadata)
@@ -204,8 +205,8 @@
private BlueprintMetadata getBlueprintMetadata()
{
- BlueprintParser bpParser = new BlueprintParser(context);
- BlueprintMetadata bpMetadata = bpParser.getBlueprintMetadata(bundle);
+ BlueprintParser parser = context.getBlueprintParser();
+ BlueprintMetadata bpMetadata = parser.getBlueprintMetadata(bundle);
bpMetadata.initialize();
return bpMetadata;
}
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -27,8 +27,8 @@
import java.util.Collections;
import java.util.List;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.reflect.ServiceMetadataImpl;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.BeanMetadata;
@@ -53,7 +53,7 @@
private BeanManager anonymousBean;
private List<ServiceRegistration> serviceRegs = new
ArrayList<ServiceRegistration>();
- public ServiceManager(BundleContext context, BlueprintContainer container,
ServiceMetadata compMetadata)
+ public ServiceManager(BlueprintContext context, BlueprintContainer container,
ServiceMetadata compMetadata)
{
super(context, container, compMetadata);
this.serviceMetadata = (ServiceMetadataImpl)compMetadata;
@@ -94,7 +94,7 @@
Object targetBean = beanManager.getTargetBean();
for (String interf : serviceMetadata.getInterfaces())
{
- ServiceRegistration sreg = context.registerService(interf, targetBean, null);
+ ServiceRegistration sreg = context.getBundleContext().registerService(interf,
targetBean, null);
serviceRegs.add(sreg);
}
}
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -23,8 +23,8 @@
//$Id$
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.reflect.ServiceReferenceMetadataImpl;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
@@ -43,7 +43,7 @@
{
private ServiceReferenceMetadataImpl srefMetadata;
- public ServiceReferenceManager(BundleContext context, BlueprintContainer container,
ServiceReferenceMetadata compMetadata)
+ public ServiceReferenceManager(BlueprintContext context, BlueprintContainer container,
ServiceReferenceMetadata compMetadata)
{
super(context, container, compMetadata);
this.srefMetadata = (ServiceReferenceMetadataImpl)compMetadata;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -45,7 +45,7 @@
BlueprintService service = new BlueprintService(){};
context.registerService(BlueprintService.class.getName(), service, null);
- extender = new BlueprintExtender(context);
+ extender = new BlueprintExtender(new BlueprintContextImpl(context));
context.addBundleListener(extender);
}
Added:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintContextImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintContextImpl.java
(rev 0)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintContextImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.osgi.blueprint.extender;
+
+//$Id$
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.blueprint.parser.BlueprintParser;
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * The context of the Blueprint implementation
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public class BlueprintContextImpl implements BlueprintContext
+{
+ public static final String XMLNS_BLUEPRINT =
"http://www.osgi.org/xmlns/blueprint/v1.0.0";
+
+ private LogService log;
+ private BundleContext context;
+ private BlueprintParser parser;
+
+ public BlueprintContextImpl(BundleContext context)
+ {
+ this.log = new LogServiceTracker(context);
+ this.context = context;
+
+ this.parser = new BlueprintParser(this);
+ }
+
+ public LogService getLog()
+ {
+ return log;
+ }
+
+ public BundleContext getBundleContext()
+ {
+ return context;
+ }
+
+ public BlueprintParser getBlueprintParser()
+ {
+ return parser;
+ }
+
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintContextImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -31,9 +31,9 @@
import java.util.List;
import java.util.Map;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.container.BlueprintContainerImpl;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.Constants;
import org.osgi.framework.SynchronousBundleListener;
@@ -46,10 +46,10 @@
*/
public class BlueprintExtender implements SynchronousBundleListener
{
- private BundleContext context;
+ private BlueprintContext context;
private Map<String, BlueprintContainerImpl> containers = new
LinkedHashMap<String, BlueprintContainerImpl>();
- public BlueprintExtender(BundleContext context)
+ public BlueprintExtender(BlueprintContext context)
{
this.context = context;
}
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -26,12 +26,10 @@
import java.net.URL;
import java.util.Enumeration;
-import org.jboss.osgi.blueprint.parser.xb.JBossXBParser;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
import org.jboss.osgi.blueprint.reflect.BlueprintMetadata;
-import org.jboss.osgi.common.log.LogServiceTracker;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
//$Id$
@@ -45,12 +43,16 @@
public class BlueprintParser
{
private LogService log;
- private BundleContext context;
+ private BlueprintContext context;
+ private JBossXBParser parser;
- public BlueprintParser(BundleContext context)
+ public BlueprintParser(BlueprintContext context)
{
- this.log = new LogServiceTracker(context);
+ this.log = context.getLog();
this.context = context;
+
+ //this.parser = new SchemaResolverParser(context);
+ this.parser = new SchemaBindingParser(context);
}
@SuppressWarnings("unchecked")
@@ -71,7 +73,7 @@
for (String descriptor : descritors)
{
- TBlueprint aux = processDescriptor(bundle, descriptor);
+ TBlueprint aux = parse(bundle, descriptor);
tBlueprint = aux.merge(tBlueprint);
}
}
@@ -82,7 +84,7 @@
while (foundEntries.hasMoreElements())
{
URL nextEntry = foundEntries.nextElement();
- TBlueprint aux = processDescriptor(nextEntry);
+ TBlueprint aux = parse(nextEntry);
tBlueprint = aux.merge(tBlueprint);
}
}
@@ -93,15 +95,15 @@
return new BlueprintMetadata(context, tBlueprint);
}
- private TBlueprint processDescriptor(Bundle bundle, String descriptor)
+ public TBlueprint parse(Bundle bundle, String descriptor)
{
URL descriptorURL = bundle.getResource(descriptor);
- return processDescriptor(descriptorURL);
+ return parse(descriptorURL);
}
- private TBlueprint processDescriptor(URL descriptorURL)
+ public TBlueprint parse(URL descriptorURL)
{
- TBlueprint blueprint = new JBossXBParser().parse(descriptorURL);
+ TBlueprint blueprint = parser.parse(descriptorURL);
return blueprint;
}
}
\ No newline at end of file
Added:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/JBossXBParser.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/JBossXBParser.java
(rev 0)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/JBossXBParser.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.osgi.blueprint.parser;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+
+/**
+ * The SchemaBindingParser builds a JBossXB {@link SchemaBinding} from an annotated
blueprint.xsd
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public interface JBossXBParser
+{
+ /*
+ * Parse a blueprint descriptor
+ */
+ public TBlueprint parse(URL xmlURL);
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/JBossXBParser.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaBindingParser.java
(from rev 90471,
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/JBossXBParser.java)
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaBindingParser.java
(rev 0)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaBindingParser.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.osgi.blueprint.parser;
+
+//$Id$
+
+import java.net.URL;
+
+import org.apache.xerces.dom.DOMXSImplementationSourceImpl;
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.blueprint.BlueprintException;
+import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+/**
+ * The SchemaBindingParser builds a JBossXB {@link SchemaBinding} from an annotated
blueprint.xsd
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public class SchemaBindingParser implements JBossXBParser
+{
+ private SchemaBinding schemaBinding;
+
+ public SchemaBindingParser(BlueprintContext context)
+ {
+ //
https://jira.jboss.org/jira/browse/JBXB-202
+ // Inconsistent initialization of XSImplementation
+ //
+ // Please provide an JBossXB initialization entry point that is public and does not
make an assumption on the availability of the TCCL
+ //
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ ClassLoader bundleCL = getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(bundleCL);
+
+ // Make sure we import and can load the XSImplementation
+ // This is the code that is used in JBossXB Util.getXSImplementation()
+ bundleCL.loadClass(DOMXSImplementationSourceImpl.class.getName());
+
+ ClassLoader resourceLoader = getClass().getClassLoader();
+ URL schemaXSD =
resourceLoader.getResource("schema/blueprint-jbxb.xsd");
+ if (schemaXSD == null)
+ throw new BlueprintException("Cannot get blueprint schema from: " +
resourceLoader);
+
+ schemaBinding = XsdBinder.bind(schemaXSD.toExternalForm());
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalStateException("Cannot load: " +
DOMXSImplementationSourceImpl.class.getName());
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+
+ /*
+ * Parse a blueprint descriptor
+ */
+ public TBlueprint parse(URL xmlURL)
+ {
+ if (xmlURL == null)
+ throw new IllegalArgumentException("Cannot parse null descriptor
URL");
+
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ ClassLoader bundleCL = getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(bundleCL);
+
+ Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+ TBlueprint tBlueprint =
(TBlueprint)unmarshaller.unmarshal(xmlURL.toExternalForm(), schemaBinding);
+
+ return tBlueprint;
+ }
+ catch (JBossXBException ex)
+ {
+ throw new BlueprintException("Cannot parse blueprint descriptor: " +
xmlURL, ex);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+}
\ No newline at end of file
Added:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaResolverParser.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaResolverParser.java
(rev 0)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaResolverParser.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.osgi.blueprint.parser;
+
+//$Id$
+
+import static org.jboss.osgi.blueprint.BlueprintContext.XMLNS_BLUEPRINT;
+
+import java.net.URL;
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.blueprint.BlueprintException;
+import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.osgi.service.log.LogService;
+
+/**
+ * The Blueprint descriptor parser.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public class SchemaResolverParser implements JBossXBParser
+{
+ private SchemaBindingResolver resolver;
+
+ public SchemaResolverParser(BlueprintContext context)
+ {
+ JBossEntityResolver.registerEntity(XMLNS_BLUEPRINT, "blueprint.xsd");
+ resolver = new BlueprintSchemaResolver(context);
+ }
+
+ /*
+ * Parse a blueprint descriptor
+ */
+ public TBlueprint parse(URL xmlURL)
+ {
+ if (xmlURL == null)
+ throw new IllegalArgumentException("Cannot parse null descriptor
URL");
+
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ ClassLoader bundleCL = getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(bundleCL);
+
+ Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+ TBlueprint tBlueprint =
(TBlueprint)unmarshaller.unmarshal(xmlURL.toExternalForm(), resolver);
+
+ return tBlueprint;
+ }
+ catch (JBossXBException ex)
+ {
+ throw new BlueprintException("Cannot parse blueprint descriptor: " +
xmlURL, ex);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+
+ static class BlueprintSchemaResolver extends DefaultSchemaResolver
+ {
+ private LogService log;
+
+ public BlueprintSchemaResolver(BlueprintContext context)
+ {
+ this.log = context.getLog();
+
+ try
+ {
+ addClassBinding(BlueprintContext.XMLNS_BLUEPRINT,
TBlueprint.class.getName());
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot create schema resolver",
ex);
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/SchemaResolverParser.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/JBossXBParser.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/JBossXBParser.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/JBossXBParser.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -1,111 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.osgi.blueprint.parser.xb;
-
-//$Id$
-
-import java.net.URL;
-
-import org.apache.xerces.dom.DOMXSImplementationSourceImpl;
-import org.jboss.osgi.blueprint.BlueprintException;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
-
-/**
- * The Blueprint descriptor parser.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 13-May-2009
- */
-public class JBossXBParser
-{
- private static SchemaBinding schemaBinding;
-
- public JBossXBParser()
- {
- if (schemaBinding == null)
- {
- //
https://jira.jboss.org/jira/browse/JBXB-202
- // Inconsistent initialization of XSImplementation
- //
- // Please provide an JBossXB initialization entry point that is public and does
not make an assumption on the availability of the TCCL
- //
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- ClassLoader bundleCL = getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(bundleCL);
-
- // Make sure we import and can load the XSImplementation
- // This is the code that is used in JBossXB Util.getXSImplementation()
- bundleCL.loadClass(DOMXSImplementationSourceImpl.class.getName());
-
- ClassLoader resourceLoader = getClass().getClassLoader();
- URL schemaXSD =
resourceLoader.getResource("schema/blueprint-jbxb.xsd");
- if (schemaXSD == null)
- throw new BlueprintException("Cannot get blueprint schema from:
" + resourceLoader);
-
- schemaBinding = XsdBinder.bind(schemaXSD.toExternalForm());
- }
- catch (ClassNotFoundException ex)
- {
- throw new IllegalStateException("Cannot load: " +
DOMXSImplementationSourceImpl.class.getName());
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
- }
- }
-
- /*
- * Parse a blueprint descriptor
- */
- public TBlueprint parse(URL xmlURL)
- {
- if (xmlURL == null)
- throw new IllegalArgumentException("Cannot parse null descriptor
URL");
-
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- ClassLoader bundleCL = getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(bundleCL);
-
- Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
- TBlueprint tBlueprint =
(TBlueprint)unmarshaller.unmarshal(xmlURL.toExternalForm(), schemaBinding);
-
- return tBlueprint;
- }
- catch (JBossXBException ex)
- {
- throw new BlueprintException("Cannot parse blueprint descriptor: " +
xmlURL, ex);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
- }
-}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/TBlueprint.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/TBlueprint.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/TBlueprint.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -33,9 +33,13 @@
import java.util.Map;
import java.util.Set;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import org.jboss.osgi.spi.NotImplementedException;
+import org.jboss.xb.annotations.JBossXmlSchema;
import org.osgi.service.blueprint.container.NoSuchComponentException;
/**
@@ -52,6 +56,9 @@
* @author thomas.diesler(a)jboss.com
* @since 13-May-2009
*/
+@JBossXmlSchema(namespace="urn:jboss:policy:1.0", elementFormDefault=
XmlNsForm.QUALIFIED)
+@XmlRootElement(name="blueprint")
+@XmlType(name="Tblueprint")
public class TBlueprint
{
protected String description;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/Tcollection.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/Tcollection.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/parser/xb/Tcollection.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -26,7 +26,9 @@
import java.util.ArrayList;
import java.util.List;
+import javax.xml.bind.JAXBElement;
+
/**
*
*
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanMetadataImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanMetadataImpl.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanMetadataImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -25,9 +25,9 @@
import java.util.List;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TBean;
import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.reflect.BeanArgument;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.BeanProperty;
@@ -45,12 +45,12 @@
private ComponentMetadata parent;
private TBean tBean;
- public BeanMetadataImpl(BundleContext context, BlueprintMetadata blueprint, TBean
tBean)
+ public BeanMetadataImpl(BlueprintContext context, BlueprintMetadata blueprint, TBean
tBean)
{
this(context, blueprint, null, tBean);
}
- public BeanMetadataImpl(BundleContext context, BlueprintMetadata blueprint,
ComponentMetadata parent, TBean tBean)
+ public BeanMetadataImpl(BlueprintContext context, BlueprintMetadata blueprint,
ComponentMetadata parent, TBean tBean)
{
super(context, blueprint, tBean);
this.parent = parent;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -29,10 +29,10 @@
import java.util.List;
import java.util.Map;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
import org.jboss.osgi.blueprint.parser.xb.TComponent;
import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.container.NoSuchComponentException;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
@@ -51,12 +51,12 @@
*/
public class BlueprintMetadata
{
- private BundleContext context;
+ private BlueprintContext context;
private TBlueprint tBlueprint;
private Map<String, ComponentMetadata> components = new LinkedHashMap<String,
ComponentMetadata>();
- public BlueprintMetadata(BundleContext context, TBlueprint tBlueprint)
+ public BlueprintMetadata(BlueprintContext context, TBlueprint tBlueprint)
{
this.context = context;
this.tBlueprint = tBlueprint;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -23,11 +23,11 @@
// $Id$
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TBean;
import org.jboss.osgi.blueprint.parser.xb.TComponent;
import org.jboss.osgi.blueprint.parser.xb.TService;
import org.jboss.osgi.blueprint.parser.xb.TServiceReference;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
/**
@@ -38,11 +38,11 @@
*/
public class ComponentFactory
{
- private BundleContext context;
+ private BlueprintContext context;
private BlueprintMetadata blueprint;
private int anonymousId;
- public ComponentFactory(BundleContext context, BlueprintMetadata blueprint)
+ public ComponentFactory(BlueprintContext context, BlueprintMetadata blueprint)
{
this.context = context;
this.blueprint = blueprint;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentMetadataImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentMetadataImpl.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentMetadataImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -25,8 +25,8 @@
import java.util.List;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TComponent;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
/**
@@ -39,7 +39,7 @@
{
protected TComponent tComp;
- public ComponentMetadataImpl(BundleContext context, BlueprintMetadata blueprint,
TComponent tComp)
+ public ComponentMetadataImpl(BlueprintContext context, BlueprintMetadata blueprint,
TComponent tComp)
{
super(context, blueprint);
this.tComp = tComp;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/MetadataImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/MetadataImpl.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/MetadataImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -23,7 +23,7 @@
// $Id$
-import org.osgi.framework.BundleContext;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.osgi.service.blueprint.reflect.Metadata;
/**
@@ -34,10 +34,10 @@
*/
public class MetadataImpl implements Metadata
{
- protected BundleContext context;
+ protected BlueprintContext context;
protected BlueprintMetadata blueprint;
- public MetadataImpl(BundleContext context, BlueprintMetadata blueprint)
+ public MetadataImpl(BlueprintContext context, BlueprintMetadata blueprint)
{
this.context = context;
this.blueprint = blueprint;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/RefMetadataImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/RefMetadataImpl.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/RefMetadataImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -23,7 +23,7 @@
// $Id$
-import org.osgi.framework.BundleContext;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.osgi.service.blueprint.reflect.RefMetadata;
/**
@@ -36,7 +36,7 @@
{
private String refId;
- public RefMetadataImpl(BundleContext context, BlueprintMetadata blueprint, String
refId)
+ public RefMetadataImpl(BlueprintContext context, BlueprintMetadata blueprint, String
refId)
{
super(context, blueprint);
this.refId = refId;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -26,10 +26,10 @@
import java.util.Collection;
import java.util.List;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TAutoExportModes;
import org.jboss.osgi.blueprint.parser.xb.TService;
import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.reflect.MapEntry;
import org.osgi.service.blueprint.reflect.RegistrationListener;
import org.osgi.service.blueprint.reflect.ServiceMetadata;
@@ -46,7 +46,7 @@
private TService tService;
private Target target;
- public ServiceMetadataImpl(BundleContext context, BlueprintMetadata blueprint,
TService tService)
+ public ServiceMetadataImpl(BlueprintContext context, BlueprintMetadata blueprint,
TService tService)
{
super(context, blueprint, tService);
this.tService = tService;
Modified:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -26,10 +26,10 @@
import java.util.Collection;
import java.util.List;
+import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TAvailability;
import org.jboss.osgi.blueprint.parser.xb.TServiceReference;
import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.reflect.ReferenceListener;
import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
@@ -43,7 +43,7 @@
{
private TServiceReference tService;
- public ServiceReferenceMetadataImpl(BundleContext context, BlueprintMetadata
blueprint, TServiceReference tService)
+ public ServiceReferenceMetadataImpl(BlueprintContext context, BlueprintMetadata
blueprint, TServiceReference tService)
{
super(context, blueprint, tService);
this.tService = tService;
Added:
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/MockBlueprintContext.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/MockBlueprintContext.java
(rev 0)
+++
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/MockBlueprintContext.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint;
+
+//$Id$
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.blueprint.parser.BlueprintParser;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * A mock {@link BlueprintContext}
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public class MockBlueprintContext implements BlueprintContext
+{
+ public BlueprintParser getBlueprintParser()
+ {
+ throw new NotImplementedException();
+ }
+
+ public BundleContext getBundleContext()
+ {
+ throw new NotImplementedException();
+ }
+
+ public LogService getLog()
+ {
+ return new LogService()
+ {
+ public void log(int level, String message)
+ {
+ System.out.println(logLevel(level) + " - " + message);
+ }
+
+ public void log(int level, String message, Throwable ex)
+ {
+ System.out.println(logLevel(level) + " - " + message);
+ ex.printStackTrace(System.out);
+ }
+
+ public void log(ServiceReference arg0, int arg1, String arg2)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void log(ServiceReference arg0, int arg1, String arg2, Throwable arg3)
+ {
+ throw new NotImplementedException();
+ }
+ };
+ }
+
+ private String logLevel(int level)
+ {
+ String logLevel;
+ switch (level)
+ {
+ case LogService.LOG_DEBUG:
+ logLevel = "DEBUG";
+ break;
+ case LogService.LOG_INFO:
+ logLevel = "INFO";
+ break;
+ case LogService.LOG_WARNING:
+ logLevel = "WARN";
+ break;
+ case LogService.LOG_ERROR:
+ logLevel = "ERROR";
+ break;
+ default:
+ logLevel = "Level=" + level;
+ }
+ return logLevel;
+ }
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/MockBlueprintContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/AllElementsParserTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/AllElementsParserTestCase.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/AllElementsParserTestCase.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -30,7 +30,7 @@
import java.util.Collection;
import java.util.List;
-import org.jboss.osgi.blueprint.parser.xb.JBossXBParser;
+import org.jboss.osgi.blueprint.parser.BlueprintParser;
import org.jboss.osgi.blueprint.parser.xb.TAvailability;
import org.jboss.osgi.blueprint.parser.xb.TBean;
import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
@@ -40,6 +40,7 @@
import org.jboss.osgi.blueprint.parser.xb.TServiceReference;
import org.jboss.osgi.blueprint.parser.xb.TTypeConverters;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.test.osgi.blueprint.MockBlueprintContext;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -57,7 +58,7 @@
public static void beforeClass()
{
URL xmlURL = new
OSGiTestHelper().getResourceURL("parser/blueprint-all-elements.xml");
- blueprint = new JBossXBParser().parse(xmlURL);
+ blueprint = new BlueprintParser(new MockBlueprintContext()).parse(xmlURL);
}
@Test
Modified:
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicBeansParserTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicBeansParserTestCase.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicBeansParserTestCase.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -29,11 +29,12 @@
import java.net.URL;
import java.util.List;
-import org.jboss.osgi.blueprint.parser.xb.JBossXBParser;
+import org.jboss.osgi.blueprint.parser.BlueprintParser;
import org.jboss.osgi.blueprint.parser.xb.TBean;
import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
import org.jboss.osgi.blueprint.parser.xb.TComponent;
import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.test.osgi.blueprint.MockBlueprintContext;
import org.jboss.test.osgi.blueprint.parser.comp.BeanA;
import org.jboss.test.osgi.blueprint.parser.comp.BeanB;
import org.junit.Test;
@@ -50,7 +51,7 @@
public void testBasicBeans() throws Exception
{
URL xmlURL = getResourceURL("parser/blueprint-basic-beans.xml");
- TBlueprint blueprint = new JBossXBParser().parse(xmlURL);
+ TBlueprint blueprint = new BlueprintParser(new
MockBlueprintContext()).parse(xmlURL);
List<TComponent> compList = blueprint.getComponents();
assertTrue(compList.size() > 0);
Modified:
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicRootParserTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicRootParserTestCase.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicRootParserTestCase.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -29,10 +29,11 @@
import java.math.BigInteger;
import java.net.URL;
-import org.jboss.osgi.blueprint.parser.xb.JBossXBParser;
+import org.jboss.osgi.blueprint.parser.BlueprintParser;
import org.jboss.osgi.blueprint.parser.xb.TAvailability;
import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.test.osgi.blueprint.MockBlueprintContext;
import org.junit.Test;
/**
@@ -47,7 +48,7 @@
public void testBlueprintDefaultAttributes() throws Exception
{
URL xmlURL = getResourceURL("parser/blueprint-basic-root.xml");
- TBlueprint blueprint = new JBossXBParser().parse(xmlURL);
+ TBlueprint blueprint = new BlueprintParser(new
MockBlueprintContext()).parse(xmlURL);
// assert default attributes
assertEquals(TAvailability.MANDATORY, blueprint.getDefaultAvailability());
@@ -61,7 +62,7 @@
public void testBlueprintDescription() throws Exception
{
URL xmlURL = getResourceURL("parser/blueprint-basic-root.xml");
- TBlueprint blueprint = new JBossXBParser().parse(xmlURL);
+ TBlueprint blueprint = new BlueprintParser(new
MockBlueprintContext()).parse(xmlURL);
// assert description
assertEquals("some text", blueprint.getDescription());
Modified:
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicServiceParserTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicServiceParserTestCase.java 2009-06-19
12:53:52 UTC (rev 90471)
+++
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/parser/BasicServiceParserTestCase.java 2009-06-19
15:11:39 UTC (rev 90472)
@@ -29,12 +29,13 @@
import java.net.URL;
import java.util.List;
-import org.jboss.osgi.blueprint.parser.xb.JBossXBParser;
+import org.jboss.osgi.blueprint.parser.BlueprintParser;
import org.jboss.osgi.blueprint.parser.xb.TBean;
import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
import org.jboss.osgi.blueprint.parser.xb.TComponent;
import org.jboss.osgi.blueprint.parser.xb.TService;
import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.test.osgi.blueprint.MockBlueprintContext;
import org.jboss.test.osgi.blueprint.parser.comp.BeanA;
import org.jboss.test.osgi.blueprint.parser.comp.ServiceA;
import org.jboss.test.osgi.blueprint.parser.comp.ServiceB;
@@ -52,7 +53,7 @@
public void testBasicBeans() throws Exception
{
URL xmlURL = getResourceURL("parser/blueprint-basic-service.xml");
- TBlueprint blueprint = new JBossXBParser().parse(xmlURL);
+ TBlueprint blueprint = new BlueprintParser(new
MockBlueprintContext()).parse(xmlURL);
List<TComponent> compList = blueprint.getComponents();
assertTrue(compList.size() > 0);