KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sample > registry > model > impl > ServiceImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.sample.registry.model.impl;
20
21 import java.util.Collections JavaDoc;
22 import java.util.List JavaDoc;
23 import org.sample.registry.model.RegistryComponent;
24 import org.sample.registry.model.RegistryVisitor;
25 import org.sample.registry.model.Service;
26 import org.sample.registry.model.ServiceProvider;
27 import org.sample.registry.model.ServiceType;
28 import org.w3c.dom.Element JavaDoc;
29
30 public class ServiceImpl extends RegistryComponentImpl.Named implements Service {
31     
32     public ServiceImpl(RegistryModelImpl model, Element JavaDoc e) {
33         super(model, e);
34     }
35     
36     public ServiceImpl(RegistryModelImpl model) {
37         this(model, createElementNS(model, RegistryQNames.SERVICE));
38     }
39
40     public Reference<ServiceType> getServiceType() {
41         String JavaDoc type = getAttribute(RegistryAttributes.TYPE);
42         if (type != null) {
43             return new Reference<ServiceType>(type, ServiceType.class, this);
44         } else {
45             return null;
46         }
47     }
48     
49     public void setServiceType(Reference<ServiceType> type) {
50         String JavaDoc v = type == null ? null : type.getRefString();
51         setAttribute(SERVICE_TYPE_PROPERTY, RegistryAttributes.TYPE, v);
52     }
53     
54     public Integer JavaDoc getCapacity() {
55         String JavaDoc v = getAttribute(RegistryAttributes.CAPACITY);
56         if (v != null) {
57             return Integer.valueOf(v);
58         } else {
59             return null;
60         }
61     }
62     
63     public void setCapacity(Integer JavaDoc capacity) {
64         super.setAttribute(CAPACITY_PROPERTY, RegistryAttributes.CAPACITY, capacity);
65     }
66     
67     public ServiceProvider getProvider() {
68         return getChild(ServiceProvider.class);
69     }
70     
71     public void setProvider(ServiceProvider provider) {
72         List JavaDoc<Class JavaDoc<? extends RegistryComponent>> empty = Collections.emptyList();
73         setChild(ServiceProvider.class, SERVICE_PROVIDER_PROPERTY, provider, empty);
74     }
75
76     public void accept(RegistryVisitor visitor) {
77         visitor.visit(this);
78     }
79 }
80
Popular Tags