001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019 package org.apache.james.domainlist.lib;
020
021 import javax.annotation.Resource;
022 import javax.management.NotCompliantMBeanException;
023 import javax.management.StandardMBean;
024
025 import org.apache.james.domainlist.api.DomainList;
026 import org.apache.james.domainlist.api.DomainListException;
027 import org.apache.james.domainlist.api.DomainListManagementMBean;
028
029 public class DomainListManagement extends StandardMBean implements DomainListManagementMBean {
030
031 private DomainList domainList;
032
033 public DomainListManagement() throws NotCompliantMBeanException {
034 super(DomainListManagementMBean.class);
035 }
036
037 @Resource(name = "domainlist")
038 public void setDomainList(DomainList domainList) {
039 this.domainList = domainList;
040
041 }
042
043 public void addDomain(String domain) throws Exception {
044 try {
045 domainList.addDomain(domain);
046 } catch (DomainListException e) {
047 throw new Exception(e.getMessage());
048 }
049 }
050
051 public boolean containsDomain(String domain) throws Exception {
052 try {
053
054 return domainList.containsDomain(domain);
055 } catch (DomainListException e) {
056 throw new Exception(e.getMessage());
057 }
058 }
059
060 public String[] getDomains() throws Exception {
061 try {
062
063 return domainList.getDomains();
064 } catch (DomainListException e) {
065 throw new Exception(e.getMessage());
066 }
067 }
068
069 public void removeDomain(String domain) throws Exception {
070 try {
071
072 domainList.removeDomain(domain);
073 } catch (DomainListException e) {
074 throw new Exception(e.getMessage());
075 }
076 }
077
078 public String getDefaultDomain() throws Exception {
079 try {
080
081 return domainList.getDefaultDomain();
082 } catch (DomainListException e) {
083 throw new Exception(e.getMessage());
084 }
085 }
086
087 }