Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 担心在扩展JodaTime';的类型上使用java2ws不会出现参数构造函数问题;s可变区间_Xml_Jaxb_Cxf_Jodatime_Java2wsdl - Fatal编程技术网

Xml 担心在扩展JodaTime';的类型上使用java2ws不会出现参数构造函数问题;s可变区间

Xml 担心在扩展JodaTime';的类型上使用java2ws不会出现参数构造函数问题;s可变区间,xml,jaxb,cxf,jodatime,java2wsdl,Xml,Jaxb,Cxf,Jodatime,Java2wsdl,首先,我已经看过这里: 有关使用JAXB处理JodaTime类的一些可能帮助 我继承了一个代码库,其类的impl(和XML适配器)如下所示 当尝试为java2ws使用Apache CXF v2.7.2 Maven插件生成WSDL和客户端时,我得到以下结果: Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions org.joda.t

首先,我已经看过这里:

有关使用
JAXB
处理
JodaTime
类的一些可能帮助

我继承了一个代码库,其类的impl(和XML适配器)如下所示

当尝试为
java2ws
使用
Apache CXF v2.7.2 Maven插件
生成
WSDL
和客户端时,我得到以下结果:

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.joda.time.base.BaseInterval does not have a no-arg default constructor.
    this problem is related to the following location:
            at org.joda.time.base.BaseInterval
            at org.joda.time.MutableInterval
            at com.etp.commons.persistence.model.time.Period
好的,
Period
(以下)扩展了
MutableInterval
extends
BaseInterval
extends
AbstractInterval
,它在
JodaTime v2.1
中有一个受保护的无参数构造函数
Period
有一个公共的无参数构造函数,该构造函数调用
MutableInterval
的构造函数变量,并传入一些默认值

有关于如何进行的提示吗

package com.etp.commons.persistence.model.time;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.MutableInterval;
import org.joda.time.ReadableInstant;
import org.joda.time.ReadableInterval;

import com.etp.commons.persistence.model.jaxb.XMLPeriodAdapter;
import com.etp.commons.time.services.core.TimeDispatcher;

@XmlType
@XmlJavaTypeAdapter(value=XMLPeriodAdapter.class)
public class Period extends MutableInterval implements Comparable<Period>{

private static final long serialVersionUID = 1L;

public static boolean endpointInclusive = true;
public static DateTime defaultEffectiveInstant = new DateTime(1900,1,1,0,0,0,0, DateTimeZone.forID("GMT"));
public static DateTime defaultTerminationInstant = new DateTime(9999,12,31,0,0,0,0, DateTimeZone.forID("GMT"));
public static Period defaultEffectiveInterval = new Period();       

@Override
public boolean contains(ReadableInstant time){
    if (endpointInclusive){
        return this.getStartMillis() < time.getMillis() && this.getEndMillis() >= time.getMillis();
    }else{
        return super.contains(time);
    }
}

@Override
public boolean contains(long time){
    if (endpointInclusive){
        return this.getStartMillis() < time && this.getEndMillis() >= time;
    }else{
        return super.contains(time);
    }
}

@Override
public boolean containsNow(){
    long time = TimeDispatcher.defaultTimeDispatcher.getCurrentTimeMillis();
    if (endpointInclusive){         
        return this.getStartMillis() < time && this.getEndMillis() >= time;
    }else{
        return super.contains(time);
    }
}

public DateTime getInclusiveTerminalInstant(){
    if (endpointInclusive){
        return this.getEnd();
    }else{
        return this.getStart();
    }
}

public Period getOverlap(Period period){
    if (!this.overlaps(period)){
        return null;
    }else if (this.contains(period)){
        return new Period(period);
    }else if (period.contains(this)){
        return new Period(this);
    }else{
        if (this.getStartMillis() < period.getStartMillis()){
            return new Period(period.getStart(),this.getEnd());
        }else{
            return new Period(this.getStart(),period.getEnd());
        }
    }
}

public Period offsetByJodaPeriod(org.joda.time.Period period, boolean reverse){
    Period p = null; 
    if (reverse){
        p = new Period(getStart().minus(period),getEnd().minus(period));
    }else{
        p = new Period(getStart().plus(period),getEnd().plus(period));
    }   
    return p;
}

public static List<Period> merge(List<Period> periods){
    List<Period> result = new ArrayList<Period>();
    periods = getDistinctPeriods(periods);
    Collections.sort(periods);

    DateTime start = null;
    DateTime end = null;
    for (Period period : periods){
        if (start == null){
            start = period.getStart();
            end = period.getEnd();
        }else{
            if (period.getStart().isEqual(end)){
                end = period.getEnd();
            }else{
                result.add(new Period(start,end));
                start = period.getStart();
                end = period.getEnd();
            }
        }
    }
    if (start != null){
        result.add(new Period(start,end));
    }
    return result;
}

public static Period getExtentPeriod(Collection<Period> periods){
    DateTime start = null;
    DateTime end = null;
    for (Period period : periods){
        if (start == null || start.getMillis() > period.getStartMillis()){
            start = period.getStart();
        }
        if (end == null || end.getMillis() < period.getEndMillis()){
            end = period.getEnd();
        }
    }
    return new Period(start,end);
}

public static Period getEnclosingPeriod(DateTime instant, FrequencyUnitType unit){

    DateTime start = unit.truncate(instant);
    DateTime end = start.plus(unit.getJodaPeriod());

    return new Period(start,end);

}

public Period subtractOverlap(Period period){
    if (this.overlaps(period)){
        if (period.contains(this)){
            return null;
        }else if (this.contains(period)){
            throw new IllegalArgumentException("Period contains target period. More than one period would result from subtract");
        }else if (this.getStartMillis() < period.getStartMillis()){
            return new Period(this.getStart(),period.getStart());
        }else if (this.getEndMillis() > period.getStartMillis()){
            return new Period(period.getEnd(),this.getEnd());
        }       
    }
    return this;
}

public Period subtractOverhang(Period period){
    if (this.overlaps(period)){
        if (period.contains(this)){
            return this;
        }else if (this.contains(period)){
            return new Period(period.getStart(),period.getEnd());
        }else if (this.getStartMillis() < period.getStartMillis()){
            return new Period(period.getStart(),this.getEnd());
        }else if (this.getEndMillis() > period.getStartMillis()){
            return new Period(this.getStart(),period.getEnd());
        }
    }
    return null;
}

/**
 * Returns the smallest period that is common to all of the passed periods and contains the passed time.
 *  
 * @param periods
 * @param time
 * @return
 */
public static Period getSmallestCommonIntersection(Collection<Period> periods, DateTime time){
    Period smallest = new Period();
    for (Period period : periods){
        if (!period.contains(time)){
            return null;
        }
        if (smallest.getStartMillis() < period.getStartMillis()){
            smallest.setStart(period.getStart());
        }
        if (smallest.getEndMillis() > period.getEndMillis()){
            smallest.setEnd(period.getEnd());
        }
    }
    return smallest;
}

public static List<? extends PeriodDatedObject> getCollectionWithinPeriod(Collection<? extends PeriodDatedObject> collection, Period effectivePeriod){
    List<PeriodDatedObject> effectiveObs = new ArrayList<PeriodDatedObject>();
    for (PeriodDatedObject ob : collection){
        if (ob.getPeriod().overlaps(effectivePeriod)){
            effectiveObs.add(ob);
        }
    }
    return effectiveObs;
}    

public static List<? extends PeriodDatedObject> getCollectionAtInstant(Collection<? extends PeriodDatedObject> collection, DateTime effectiveInstant){
    List<PeriodDatedObject> effectiveObs = new ArrayList<PeriodDatedObject>();
    for (PeriodDatedObject ob : collection){
        if (ob.getPeriod().contains(effectiveInstant)){
            effectiveObs.add(ob);
        }
    }
    return effectiveObs;
}

public static PeriodDatedObject getMemberAtInstant(Collection<? extends PeriodDatedObject> collection, DateTime effectiveInstant){
    for (PeriodDatedObject ob : collection){
        if (ob.getPeriod().contains(effectiveInstant)){
            return ob;
        }
    }
    return null;
}

public List<Period> getGaps(List<Period> periods){
    Collections.sort(periods);      
    List<Period> gaps = new ArrayList<Period>();

    DateTime contiguousTo = this.getStart();

    for (Period period : periods){
        if (period.getStart().getMillis() <= this.getStart().getMillis()){
            contiguousTo = period.getEnd();
        }else if (period.getStart().isEqual(contiguousTo)){
            contiguousTo = period.getEnd();
        }else if (period.getStartMillis() > contiguousTo.getMillis()){
            Period gap = new Period(contiguousTo, period.getStart());
            contiguousTo = period.getEnd();
            gaps.add(gap);
        }
    }

    if (contiguousTo.getMillis() < this.getEnd().getMillis()){
        Period gap = new Period(contiguousTo, this.getEnd());
        gaps.add(gap);
    }

    return gaps;
}

/**
 * Returns a list of distinct periods that results from overlaying the list 
 * of input periods. Non-contiguous periods will not be returned
 * 
 * @param periods
 * @return
 */
public static List<Period> getDistinctPeriods(Collection<Period> periods){

    Set<Long> instants = new HashSet<Long>();

    for (Period period : periods){
        instants.add(period.getStart().getMillis());
        instants.add(period.getEnd().getMillis());
    }

    List<Long> sorted = new ArrayList<Long>(instants);      
    Collections.sort(sorted);

    List<Period> distinctPeriods = new ArrayList<Period>();
    Period period = null;
    for (int i=0;i<sorted.size();i++){
        if (period != null){
            period.setEnd(new DateTime(sorted.get(i)));
            distinctPeriods.add(period);
        }
        period = new Period();
        period.setStart(new DateTime(sorted.get(i)));           
    }

    List<Period> emptyPeriods = new ArrayList<Period>();
    for (Period distinctPeriod : distinctPeriods){
        boolean empty = true;
        for (Period actualPeriod : periods){
            if (actualPeriod.contains(distinctPeriod)){
                empty = false;
                break;
            }
        }
        if (empty){
            emptyPeriods.add(distinctPeriod);
        }
    }
    distinctPeriods.removeAll(emptyPeriods);

    return distinctPeriods;
}

public boolean abuts(Period period){
    return this.getStartMillis() == period.getEndMillis() || this.getEndMillis() == period.getStartMillis();
}

public DateTime getStartDate(){
    return this.getStart();
}

public void setStartDate(DateTime date){
    this.setStart(date);
}

public DateTime getEndDate(){
    return this.getEnd();
}

public void setEndDate(DateTime date){
    this.setEnd(date);
}

public Period(){
    super(defaultEffectiveInstant,defaultTerminationInstant);
}   

public Period(DateTime start, DateTime end){
    super(start,end);
}

public Period(long start, long end) {
    super(start,end);
}

public Period(ReadableInterval period) {
    super(period.getStart(),period.getEnd());
}

@Override
public int hashCode() {
    final int prime = 31;
    int result = prime;
    result = prime * result + new Long(this.getStartMillis()).hashCode();
    result = prime * result + new Long(this.getEndMillis()).hashCode();
    return result;
}

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (!Period.class.isAssignableFrom(obj.getClass()))
        return false;
    Period other = (Period) obj;
    if (this.getEnd() == null) {
        if (other.getEnd() != null)
            return false;
    } else if (!this.getEnd().isEqual(other.getEnd()))
        return false;
    if (this.getStart() == null) {
        if (other.getStart() != null)
            return false;
    } else if (!this.getStart().isEqual(other.getStart()))
        return false;
    return true;
}

public int compareByEnd(Period o) {
    return o.getEnd().compareTo(this.getEnd());
}

@Override
public int compareTo(Period o) {
    int compare = this.getStart().compareTo(o.getStart());      
    return compare;
}    

public String toString(){
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZZ");
    return fmt.format(this.getStart().toDate()) + "-" + fmt.format(this.getEnd().toDate());
}

public String toString(String format){
    SimpleDateFormat fmt = new SimpleDateFormat(format);
    return fmt.format(this.getStart().toDate()) + "-" + fmt.format(this.getEnd().toDate());
}

public boolean containsIncludingEndpoints(DateTime next) {
    return contains(next) || getStart().isEqual(next) || getEnd().isEqual(next);
}
}
package com.etp.commons.persistence.model.time;
导入java.text.simpleDataFormat;
导入java.util.ArrayList;
导入java.util.Collection;
导入java.util.Collections;
导入java.util.HashSet;
导入java.util.List;
导入java.util.Set;
导入javax.xml.bind.annotation.XmlType;
导入javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
导入org.joda.time.DateTime;
导入org.joda.time.DateTimeZone;
导入org.joda.time.MutableInterval;
导入org.joda.time.ReadableInstant;
导入org.joda.time.ReadableInterval;
导入com.etp.commons.persistence.model.jaxb.XMLPeriodAdapter;
导入com.etp.commons.time.services.core.TimeDispatcher;
@XmlType
@XmlJavaTypeAdapter(值=XMLPeriodAdapter.class)
公共类周期扩展了可变间隔{
私有静态最终长serialVersionUID=1L;
公共静态布尔endpointInclusive=true;
public static DateTime defaultEffectiveInstant=新的日期时间(1900,1,1,0,0,0,DateTimeZone.forID(“GMT”);
public static DateTime defaultterminationstant=new DateTime(9999,12,31,0,0,0,DateTimeZone.forID(“GMT”);
公共静态期间defaultEffectiveInterval=新期间();
@凌驾
公共布尔包含(ReadableInstant time){
如果(包括端点){
返回this.getStartMillis()=time.getMillis();
}否则{
返回super.contains(时间);
}
}
@凌驾
公共布尔包含(长时间){
如果(包括端点){
返回this.getStartMillis()=time;
}否则{
返回super.contains(时间);
}
}
@凌驾
公共布尔值(){
long time=TimeDispatcher.defaultTimeDispatcher.getCurrentTimeMillis();
如果(包括端点){
返回this.getStartMillis()=time;
}否则{
返回super.contains(时间);
}
}
public DateTime getInclusiveTerminalInstant(){
如果(包括端点){
返回这个.getEnd();
}否则{
返回这个.getStart();
}
}
公共期间getOverlap(期间){
如果(!此.重叠(期间)){
返回null;
}else if(此.包含(期间)){
返回新期间(期间);
}else if(period.contains(this)){
返回新期间(本);
}否则{
if(this.getStartMillis()period.getStartMillis()){
start=period.getStart();
}
if(end==null | | end.getMillis()period.getStartMillis()){
返回新期间(Period.getEnd(),this.getEnd());
}       
}
归还这个;
}
公共期间减去悬置(期间){
如果(本次重叠(期间)){
如果(期间包含(本)){
归还这个;
}else if(此.包含(期间)){
返回新期间(Period.getStart(),Period.getEnd());
package com.etp.commons.persistence.model.jaxb;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import com.etp.commons.persistence.model.time.Period;

public class XMLPeriodAdapter extends XmlAdapter<String, Period> {

/*
@Override
public Period unmarshal(JAXBAdaptedPeriod v) throws Exception {
    return new Period(new DateTime(v.getStart().getTime()), new DateTime(v.getEnd().getTime()));
}

@Override
public JAXBAdaptedPeriod marshal(Period v) throws Exception {
    JAXBAdaptedPeriod  period = new JAXBAdaptedPeriod();

    if(v!=null){
        period.setStart(v.getStart().toDate());
        period.setEnd(v.getEnd().toDate());
    }

    return period;
}
 */

@Override
public Period unmarshal(final String v) throws Exception {
    final int dashIndex = v.indexOf('-');
    final long start = Long.valueOf(v.substring(0, dashIndex));
    final long end = Long.valueOf(v.substring(dashIndex + 1));
    return new Period(start, end);
}

@Override
public String marshal(final Period v) throws Exception {
    return v.getStartMillis() + "-" + v.getEndMillis();
}
}
@WebService(targetNamespace="http://www.foo.com/DerivationModelServices")
public interface DerivationModelService extends InternalDerivationModelService{


public Determinant getDeterminant(DeterminantQueryParameters params) throws PersistenceServiceException;



public DeterminantDefinition getDeterminantDefinition(DeterminantDefinitionQueryParameters params) throws PersistenceServiceException;



public Group getGroup(GroupQueryParameters params) throws Exception;    

public AttributeDefinition getAttributeDefinition(AttributeDefinitionQueryParameters params) throws PersistenceServiceException;

public void saveGroup(Group group) throws PersistenceServiceException;

public void saveDeterminant(Determinant determinant) throws PersistenceServiceException;

public DerivationModel getDerivationModel(DerivationModelQueryParameters model) throws PersistenceServiceException; 

public void saveReportDefinition(ReportDefinition def);

public PagedQueryResults<ReportDefinition> getReportDefinitions(ReportDefinitionsQueryParameters params);

public ReportDefinition getReportDefinition(ReportDefinitionQueryParameters params);

    }
@XmlType
@XmlJavaTypeAdapter(value=XMLPeriodAdapter.class)
class Response  
{    
   private Period period;  

   // another fields  
   // setters/getters
}  
   @WebMethod  
   public void wsMethod(@WebParam   
                        @XmlJavaTypeAdapter(XMLPeriodAdapter.class)   Period period){}

   @WebMethod  
   @WebResult
   @XmlJavaTypeAdapter(XMLPeriodAdapter.class)
   public Period wsMethod(){}