Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

[WFLY-1310] Allow repository URLs to be configured #4457

Merged
merged 1 commit into from 12 months ago

3 participants

Thomas Diesler jboss-as-pull-request Jaikiran
Thomas Diesler

No description provided.

jboss-as-pull-request
Collaborator

Triggering build using a merge of d6f13e7 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

jboss-as-pull-request
Collaborator

Build 6964 is now running using a merge of d6f13e7 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/6964

jboss-as-pull-request
Collaborator

Triggering build using a merge of 7e42873 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

jboss-as-pull-request
Collaborator

Triggering build using a merge of 33f5aa6 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

jboss-as-pull-request
Collaborator

Build 6973 is now running using a merge of 33f5aa6 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/6973

jboss-as-pull-request
Collaborator

Triggering build using a merge of 9c74f61 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

jboss-as-pull-request
Collaborator

Build 6981 is now running using a merge of 9c74f61 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/6981

jboss-as-pull-request
Collaborator

Triggering build using a merge of 1a3764a on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

jboss-as-pull-request
Collaborator

Build 6991 is now running using a merge of 1a3764a on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/6991

Jaikiran jaikiran merged commit 1a3764a into from May 06, 2013
Jaikiran jaikiran closed this May 06, 2013
Jaikiran
Owner

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 06, 2013
Thomas Diesler [WFLY-1310] Allow repository URLs to be configured 1a3764a
This page is out of date. Refresh to see the latest.
50  osgi/service/src/main/java/org/jboss/as/osgi/service/RepositoryService.java
@@ -22,10 +22,12 @@
22 22
 
23 23
 package org.jboss.as.osgi.service;
24 24
 
25  
-import static org.jboss.as.osgi.OSGiLogger.LOGGER;
26 25
 import static org.jboss.osgi.repository.XRepository.MODULE_IDENTITY_NAMESPACE;
  26
+import static org.jboss.osgi.repository.XRepository.SERVICE_NAMES;
27 27
 
28 28
 import java.io.File;
  29
+import java.util.Dictionary;
  30
+import java.util.Hashtable;
29 31
 
30 32
 import org.jboss.as.osgi.OSGiConstants;
31 33
 import org.jboss.as.server.ServerEnvironment;
@@ -45,9 +47,14 @@
45 47
 import org.jboss.osgi.repository.RepositoryStorageFactory;
46 48
 import org.jboss.osgi.repository.XRepository;
47 49
 import org.jboss.osgi.repository.core.FileBasedRepositoryStorage;
48  
-import org.jboss.osgi.repository.core.XRepositoryBuilder;
  50
+import org.jboss.osgi.repository.core.MavenRepository;
  51
+import org.jboss.osgi.repository.core.MavenRepository.ConfigurationPropertyProvider;
  52
+import org.jboss.osgi.repository.spi.AbstractPersistentRepository;
  53
+import org.jboss.osgi.repository.spi.AggregatingRepository;
49 54
 import org.jboss.osgi.resolver.XResource;
50 55
 import org.osgi.framework.BundleContext;
  56
+import org.osgi.framework.Constants;
  57
+import org.osgi.framework.ServiceRegistration;
51 58
 
52 59
 /**
53 60
  * The standalone {@link XRepository} service.
@@ -59,6 +66,7 @@
59 66
 
60 67
     private final InjectedValue<BundleContext> injectedSystemContext = new InjectedValue<BundleContext>();
61 68
     private final InjectedValue<ServerEnvironment> injectedServerEnvironment = new InjectedValue<ServerEnvironment>();
  69
+    private ServiceRegistration<?> registration;
62 70
     private XRepository repository;
63 71
 
64 72
     static ServiceController<?> addService(final ServiceTarget target) {
@@ -74,14 +82,14 @@ private RepositoryService() {
74 82
     }
75 83
 
76 84
     @Override
77  
-    public synchronized void start(StartContext context) throws StartException {
78  
-        ServiceController<?> serviceController = context.getController();
79  
-        LOGGER.tracef("Starting: %s in mode %s", serviceController.getName(), serviceController.getMode());
  85
+    public synchronized void start(StartContext startContext) throws StartException {
  86
+
  87
+        // Create the {@link RepositoryStorageFactory}
80 88
         final ServerEnvironment serverenv = injectedServerEnvironment.getValue();
81  
-        final File storageDir = new File(serverenv.getServerDataDir().getPath() + File.separator + "repository");
82 89
         RepositoryStorageFactory factory = new RepositoryStorageFactory() {
83 90
             @Override
84 91
             public RepositoryStorage create(XRepository repository) {
  92
+                File storageDir = new File(serverenv.getServerDataDir().getPath() + File.separator + "repository");
85 93
                 return new FileBasedRepositoryStorage(repository, storageDir) {
86 94
                     @Override
87 95
                     public XResource addResource(XResource res) throws RepositoryStorageException {
@@ -95,17 +103,33 @@ public XResource addResource(XResource res) throws RepositoryStorageException {
95 103
                 };
96 104
             }
97 105
         };
98  
-        BundleContext syscontext = injectedSystemContext.getValue();
99  
-        XRepositoryBuilder builder = XRepositoryBuilder.create(syscontext);
100  
-        builder.addRepository(new ModuleIdentityRepository(serverenv));
101  
-        builder.addRepositoryStorage(factory);
102  
-        repository = builder.addDefaultRepositories();
  106
+
  107
+        // Create the {@link ConfigurationPropertyProvider}
  108
+        final BundleContext syscontext = injectedSystemContext.getValue();
  109
+        ConfigurationPropertyProvider propProvider = new ConfigurationPropertyProvider() {
  110
+            @Override
  111
+            public String getProperty(String key, String defaultValue) {
  112
+                String value = syscontext.getProperty(key);
  113
+                return value != null ? value : defaultValue;
  114
+            }
  115
+        };
  116
+
  117
+        AggregatingRepository aggregator = new AggregatingRepository();
  118
+        aggregator.addRepository(new ModuleIdentityRepository(serverenv));
  119
+        aggregator.addRepository(new MavenRepository(propProvider));
  120
+        repository = new AbstractPersistentRepository(factory, aggregator);
  121
+
  122
+        // Register the top level repository
  123
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
  124
+        props.put(Constants.SERVICE_DESCRIPTION, repository.getName());
  125
+        registration = syscontext.registerService(SERVICE_NAMES, repository, props);
103 126
     }
104 127
 
105 128
     @Override
106 129
     public synchronized void stop(StopContext context) {
107  
-        ServiceController<?> serviceController = context.getController();
108  
-        LOGGER.tracef("Stopping: %s in mode %s", serviceController.getName(), serviceController.getMode());
  130
+        if (registration != null) {
  131
+            registration.unregister();
  132
+        }
109 133
         repository = null;
110 134
     }
111 135
 
2  pom.xml
@@ -193,7 +193,7 @@
193 193
         <version.org.jboss.osgi.logging>1.0.0.Final</version.org.jboss.osgi.logging>
194 194
         <version.org.jboss.osgi.metadata>3.0.0.CR1</version.org.jboss.osgi.metadata>
195 195
         <version.org.jboss.osgi.resolver>4.0.0.CR12</version.org.jboss.osgi.resolver>
196  
-        <version.org.jboss.osgi.repository>3.0.0.CR2</version.org.jboss.osgi.repository>
  196
+        <version.org.jboss.osgi.repository>3.0.0.CR3</version.org.jboss.osgi.repository>
197 197
         <version.org.jboss.osgi.spi>4.0.0.CR2</version.org.jboss.osgi.spi>
198 198
         <version.org.jboss.osgi.vfs>2.0.0.Alpha3</version.org.jboss.osgi.vfs>
199 199
         <version.org.jboss.remote-naming>1.0.6.Final</version.org.jboss.remote-naming>
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.