]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.aether/src/main/java/org/argeo/slc/aether/spring/RemoteRepositoryFactory.java
Move SLC Support
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.aether / src / main / java / org / argeo / slc / aether / spring / RemoteRepositoryFactory.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.aether.spring;
17
18 import org.sonatype.aether.repository.Authentication;
19 import org.sonatype.aether.repository.RemoteRepository;
20 import org.springframework.beans.factory.BeanNameAware;
21 import org.springframework.beans.factory.FactoryBean;
22
23 /** Simplifies the definition of a remote factory using Spring */
24 public class RemoteRepositoryFactory implements BeanNameAware, FactoryBean {
25 private String beanName;
26 private String id;
27 private String url;
28 private String type = "default";
29 private String username;
30 private String password;
31
32 public Object getObject() throws Exception {
33 RemoteRepository remoteRepository = new RemoteRepository(
34 id != null ? id : beanName, type, url);
35 if (username != null) {
36 Authentication authentication = new Authentication(username,
37 password);
38 remoteRepository.setAuthentication(authentication);
39 }
40 return remoteRepository;
41 }
42
43 public Class<?> getObjectType() {
44 return RemoteRepository.class;
45 }
46
47 public boolean isSingleton() {
48 return true;
49 }
50
51 public void setBeanName(String name) {
52 this.beanName = name;
53
54 }
55
56 public void setId(String id) {
57 this.id = id;
58 }
59
60 public void setUrl(String url) {
61 this.url = url;
62 }
63
64 public void setType(String type) {
65 this.type = type;
66 }
67
68 public void setUsername(String username) {
69 this.username = username;
70 }
71
72 public void setPassword(String password) {
73 this.password = password;
74 }
75
76 }